-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathjsrepo.config.ts
More file actions
163 lines (152 loc) · 4.68 KB
/
jsrepo.config.ts
File metadata and controls
163 lines (152 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { defineConfig, type RegistryItem } from 'jsrepo';
import { output } from '@jsrepo/shadcn';
import { type Category, componentMetadata, type Variant } from './src/constants/Information';
// Components that have non-code assets which should use manual dependency resolution.
// Key format: `${category}/${title}` to keep it unique.
const MANUAL_ASSETS: Record<string, { path: string; dependencyResolution: 'manual' }[]> = {
'Components/Lanyard': [
{ path: 'card.glb', dependencyResolution: 'manual' },
{ path: 'lanyard.png', dependencyResolution: 'manual' }
]
// Example: if ModelViewer had a model file you wanted to mark as manual too:
// 'Components/ModelViewer': [
// { path: 'model.glb', dependencyResolution: 'manual' }
// ]
};
export default defineConfig({
registry: {
name: '@react-bits',
description:
'An open source collection of animated, interactive & fully customizable React components for building stunning, memorable user interfaces.',
homepage: 'https://reactbits.dev',
authors: ['David Haz'],
bugs: 'https://github.com/DavidHDev/react-bits/issues',
repository: 'https://github.com/DavidHDev/react-bits',
tags: [
'react',
'javascript',
'components',
'web',
'reactjs',
'css-animations',
'component-library',
'ui-components',
'3d',
'ui-library',
'tailwind',
'tailwindcss',
'components',
'components-library'
],
excludeDeps: ['react'],
outputs: [output({ dir: 'public/r', format: true })],
items: [
...Object.values(componentMetadata).map(component =>
defineComponent({
title: component.name,
description: component.description,
category: component.category,
categories: [component.category],
meta: component.meta,
variants: component.variants
})
)
].flat()
}
});
/**
* Define a component to be exposed from the registry. Creates the 4 different variants of the component and ensures the correct files are included.
*
* @param title The title of the component.
* @param description The description of the component.
* @param category The category of the component.
* @param categories Organize the component into multiple categories.
* @param meta Optional meta data for the component.
* @param variants The variants of the component that are available through the registry (default: all variants)
* @returns An array of RegistryItem objects.
*/
function defineComponent({
title,
description,
category,
categories,
meta,
variants = ['JS-CSS', 'JS-TW', 'TS-CSS', 'TS-TW']
}: {
title: string;
description: string;
category: Category;
categories?: string[];
meta?: Record<string, string>;
variants?: readonly Variant[];
}): RegistryItem[] {
const baseItem: Omit<RegistryItem, 'files' | 'name'> = {
title,
description,
type: 'registry:component',
categories: [category, ...(categories ?? [])],
meta
};
// Unique key for this component in MANUAL_ASSETS
const key = `${category}/${title}`;
const manualFiles = MANUAL_ASSETS[key] && MANUAL_ASSETS[key].length > 0 ? MANUAL_ASSETS[key] : [];
const withManualFiles = (basePath: string) =>
manualFiles.length > 0
? [
{
path: basePath,
files: manualFiles
}
]
: [
{
path: basePath
}
];
// this might warrant a bit of explanation
// basically we check if the variant is included in the variants array and if so we return the item as part of an array
// otherwise we return an empty array
// we then spread that array empty or otherwise into the return array
return [
// JS + CSS
...(variants.includes('JS-CSS')
? [
{
...baseItem,
name: `${baseItem.title}-JS-CSS`,
files: withManualFiles(`src/content/${category}/${title}`)
}
]
: []),
// JS + Tailwind
...(variants.includes('JS-TW')
? [
{
...baseItem,
name: `${baseItem.title}-JS-TW`,
files: withManualFiles(`src/tailwind/${category}/${title}`)
}
]
: []),
// TS + CSS
...(variants.includes('TS-CSS')
? [
{
...baseItem,
name: `${baseItem.title}-TS-CSS`,
files: withManualFiles(`src/ts-default/${category}/${title}`)
}
]
: []),
// TS + Tailwind
...(variants.includes('TS-TW')
? [
{
...baseItem,
name: `${baseItem.title}-TS-TW`,
files: withManualFiles(`src/ts-tailwind/${category}/${title}`)
}
]
: [])
];
}