Skip to content

Commit 055658f

Browse files
committed
Change tags to categories
1 parent 42a1b62 commit 055658f

10 files changed

Lines changed: 38 additions & 36 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A web-based TailwindCSS visual builder for creating and sharing components with
88
- 📦 **Component Library**: Browse and manage blocks and templates
99
- 🔍 **Live Preview**: Preview components in a new window with TailwindCSS
1010
- 📋 **Copy to Clipboard**: Easy copying of component HTML code
11-
- 🏷️ **Tagging System**: Organize components with tags
11+
- 🏷️ **Category System**: Organize components with categories
1212
- 🚀 **Build System**: Generate distribution files for CDN deployment
1313
- 📱 **Responsive Design**: Built with modern UI components from shadcn/ui
1414

@@ -48,7 +48,7 @@ bun run dev
4848
- **Name**: Display name for your component
4949
- **Type**: Choose between "Blocks" or "Templates"
5050
- **Author**: Your name or organization
51-
- **Tags**: Comma-separated tags (e.g., "header, hero, call-to-action")
51+
- **Categories**: Comma-separated categories (e.g., "header, hero, call-to-action")
5252
- **HTML Code**: Your TailwindCSS component code
5353

5454
3. Click "Create" to save your component
@@ -110,7 +110,7 @@ Each component includes metadata in `metadata.json`:
110110
{
111111
"id": "component-id",
112112
"name": "Component Name",
113-
"tags": ["tag1", "tag2", "tag3"],
113+
"categories": ["category1", "category2", "category3"],
114114
"author": "Author Name"
115115
}
116116
```

contents/blocks/feat/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "feat",
33
"name": "feat",
4-
"tags": [
4+
"categories": [
55
"header"
66
],
77
"author": "Yo"

contents/blocks/feature-02/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "feature-02",
33
"name": "Feature 02",
4-
"tags": [
4+
"categories": [
55
"card",
66
"feature",
77
"showcase"

contents/blocks/hero-section/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "hero-section",
33
"name": "Hero Section",
4-
"tags": [
4+
"categories": [
55
"hero",
66
"call-to-action"
77
],

contents/templates/landing-01/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "landing-01",
33
"name": "landing-01",
4-
"tags": [
4+
"categories": [
55
"landing"
66
],
77
"author": "Yo"
91.6 KB
Loading

src/components/ComponentBuilder.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ function ComponentCard({
300300
</CardHeader>
301301
<CardContent className="pt-0">
302302
<div className="flex flex-wrap gap-1 mb-3">
303-
{component.metadata.tags.map((tag) => (
304-
<Badge key={tag} variant="secondary" className="text-xs">
305-
{tag}
303+
{component.metadata.categories.map((category) => (
304+
<Badge key={category} variant="secondary" className="text-xs">
305+
{category}
306306
</Badge>
307307
))}
308308
</div>

src/components/ComponentForm.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import {
2222
} from '@/components/ui/select';
2323
import type { Component } from '../types/component';
2424

25-
// Predefined tag options for components
26-
const TAG_OPTIONS: Option[] = [
25+
// Predefined category options for components
26+
const CATEGORY_OPTIONS: Option[] = [
2727
{ value: 'header', label: 'Header' },
2828
{ value: 'hero', label: 'Hero' },
2929
{ value: 'navigation', label: 'Navigation' },
@@ -80,14 +80,14 @@ const TAG_OPTIONS: Option[] = [
8080
const componentSchema = z.object({
8181
name: z.string().min(1, 'Name is required'),
8282
type: z.enum(['blocks', 'templates']),
83-
tags: z
83+
categories: z
8484
.array(
8585
z.object({
8686
value: z.string(),
8787
label: z.string()
8888
})
8989
)
90-
.min(1, 'At least one tag is required'),
90+
.min(1, 'At least one category is required'),
9191
author: z.string().min(1, 'Author is required')
9292
});
9393

@@ -118,34 +118,34 @@ export function ComponentForm({
118118
defaultValues: {
119119
name: editingComponent?.metadata.name || '',
120120
type: editingComponent?.type || 'blocks',
121-
tags:
122-
editingComponent?.metadata.tags?.map((tag) => ({
123-
value: tag,
124-
label: tag.charAt(0).toUpperCase() + tag.slice(1)
121+
categories:
122+
editingComponent?.metadata.categories?.map((category) => ({
123+
value: category,
124+
label: category.charAt(0).toUpperCase() + category.slice(1)
125125
})) || [],
126126
author: editingComponent?.metadata.author || ''
127127
}
128128
});
129129

130130
const watchedType = watch('type');
131-
const watchedTags = watch('tags');
131+
const watchedCategories = watch('categories');
132132

133133
React.useEffect(() => {
134134
if (editingComponent) {
135135
reset({
136136
name: editingComponent.metadata.name,
137137
type: editingComponent.type,
138-
tags: editingComponent.metadata.tags.map((tag) => ({
139-
value: tag,
140-
label: tag.charAt(0).toUpperCase() + tag.slice(1)
138+
categories: editingComponent.metadata.categories.map((category) => ({
139+
value: category,
140+
label: category.charAt(0).toUpperCase() + category.slice(1)
141141
})),
142142
author: editingComponent.metadata.author
143143
});
144144
} else {
145145
reset({
146146
name: '',
147147
type: 'blocks',
148-
tags: [],
148+
categories: [],
149149
author: ''
150150
});
151151
}
@@ -159,7 +159,7 @@ export function ComponentForm({
159159
metadata: {
160160
id: newId,
161161
name: data.name,
162-
tags: data.tags.map((tag) => tag.value),
162+
categories: data.categories.map((category) => category.value),
163163
author: data.author
164164
},
165165
html: '<div class="p-4 bg-gray-100 rounded-lg">\n <!-- Start building your component here -->\n <p class="text-gray-600">Your component content goes here...</p>\n</div>',
@@ -223,25 +223,27 @@ export function ComponentForm({
223223
</div>
224224

225225
<div>
226-
<Label htmlFor="tags">Tags</Label>
226+
<Label htmlFor="categories">Categories</Label>
227227
<MultipleSelector
228-
value={watchedTags as Option[]}
229-
onChange={(options) => setValue('tags', options)}
230-
defaultOptions={TAG_OPTIONS}
231-
placeholder="Select tags for your component..."
228+
value={watchedCategories as Option[]}
229+
onChange={(options) => setValue('categories', options)}
230+
defaultOptions={CATEGORY_OPTIONS}
231+
placeholder="Select categories for your component..."
232232
emptyIndicator={
233233
<p className="text-center text-sm leading-10 text-muted-foreground">
234-
No tags found.
234+
No categories found.
235235
</p>
236236
}
237237
className="mt-1"
238238
maxSelected={4}
239239
onMaxSelected={(maxLimit) => {
240-
console.log(`You can select up to ${maxLimit} tags`);
240+
console.log(`You can select up to ${maxLimit} categories`);
241241
}}
242242
/>
243-
{errors.tags && (
244-
<p className="text-sm text-red-500 mt-1">{errors.tags.message}</p>
243+
{errors.categories && (
244+
<p className="text-sm text-red-500 mt-1">
245+
{errors.categories.message}
246+
</p>
245247
)}
246248
</div>
247249

src/hooks/useComponents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function useComponents() {
150150
};
151151

152152
useEffect(() => {
153-
loadComponents(1, 12, 'blocks');
153+
loadComponents(1, 12, 'all');
154154
}, [loadComponents]);
155155

156156
return {

src/types/component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface ComponentMetadata {
22
id: string;
33
name: string;
4-
tags: string[];
4+
categories: string[];
55
author: string;
66
}
77

@@ -16,6 +16,6 @@ export interface ComponentFormData {
1616
name: string;
1717
type: 'blocks' | 'templates';
1818
html: string;
19-
tags: string;
19+
categories: string;
2020
author: string;
2121
}

0 commit comments

Comments
 (0)