@kimdw-rtk/ui 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +12 -0
- package/.turbo/turbo-check-types.log +2 -0
- package/.turbo/turbo-lint.log +12 -0
- package/.turbo/turbo-test.log +4084 -0
- package/.vscode/settings.json +4 -0
- package/eslint.config.mjs +4 -0
- package/jest.config.json +10 -0
- package/jest.setup.js +2 -0
- package/package.json +53 -0
- package/src/components/Accordion/Accordion.css.ts +29 -0
- package/src/components/Accordion/Accordion.spec.tsx +6 -0
- package/src/components/Accordion/Accordion.tsx +44 -0
- package/src/components/Accordion/AccordionContent.css.ts +29 -0
- package/src/components/Accordion/AccordionContent.tsx +87 -0
- package/src/components/Accordion/AccordionContext.ts +9 -0
- package/src/components/Accordion/AccordionTrigger.css.ts +46 -0
- package/src/components/Accordion/AccordionTrigger.tsx +41 -0
- package/src/components/Accordion/index.ts +3 -0
- package/src/components/Alert/index.tsx +25 -0
- package/src/components/Box/Box.css.ts +18 -0
- package/src/components/Box/Box.spec.tsx +6 -0
- package/src/components/Box/index.tsx +41 -0
- package/src/components/Button/Button.css.ts +241 -0
- package/src/components/Button/Button.spec.tsx +30 -0
- package/src/components/Button/index.tsx +60 -0
- package/src/components/Card/Card.css.ts +93 -0
- package/src/components/Card/Card.spec.tsx +24 -0
- package/src/components/Card/Card.tsx +41 -0
- package/src/components/Card/CardContent.css.ts +8 -0
- package/src/components/Card/CardContent.tsx +23 -0
- package/src/components/Card/CardInteraction.css.ts +11 -0
- package/src/components/Card/CardInteraction.tsx +36 -0
- package/src/components/Card/CardThumbnail.css.ts +6 -0
- package/src/components/Card/CardThumbnail.tsx +23 -0
- package/src/components/Card/index.ts +4 -0
- package/src/components/Chip/Chip.css.ts +75 -0
- package/src/components/Chip/Chip.spec.tsx +6 -0
- package/src/components/Chip/Chip.tsx +37 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/Confirm/index.tsx +44 -0
- package/src/components/Dialog/Dialog.css.ts +25 -0
- package/src/components/Dialog/Dialog.spec.tsx +26 -0
- package/src/components/Dialog/Dialog.tsx +30 -0
- package/src/components/Dialog/DialogContent.css.ts +16 -0
- package/src/components/Dialog/DialogContent.tsx +26 -0
- package/src/components/Dialog/DialogFooter.css.ts +20 -0
- package/src/components/Dialog/DialogFooter.tsx +26 -0
- package/src/components/Dialog/DialogHeader.css.ts +31 -0
- package/src/components/Dialog/DialogHeader.tsx +37 -0
- package/src/components/Dialog/index.ts +4 -0
- package/src/components/Navigation/Navigation.spec.tsx +19 -0
- package/src/components/Navigation/NavigationAside.css.ts +7 -0
- package/src/components/Navigation/NavigationAside.tsx +23 -0
- package/src/components/Navigation/NavigationBar.css.ts +42 -0
- package/src/components/Navigation/NavigationBar.tsx +25 -0
- package/src/components/Navigation/NavigationContainer.css.ts +11 -0
- package/src/components/Navigation/NavigationContainer.tsx +26 -0
- package/src/components/Navigation/NavigationDrawer.css.ts +61 -0
- package/src/components/Navigation/NavigationDrawer.tsx +67 -0
- package/src/components/Navigation/NavigationItem.css.ts +43 -0
- package/src/components/Navigation/NavigationItem.tsx +24 -0
- package/src/components/Navigation/NavigationLogo.css.ts +5 -0
- package/src/components/Navigation/NavigationLogo.tsx +28 -0
- package/src/components/Navigation/NavigationMenu.css.ts +23 -0
- package/src/components/Navigation/NavigationMenu.tsx +25 -0
- package/src/components/Navigation/index.ts +7 -0
- package/src/components/Range/Range.css.ts +132 -0
- package/src/components/Range/Range.spec.tsx +6 -0
- package/src/components/Range/Range.tsx +90 -0
- package/src/components/Range/index.ts +1 -0
- package/src/components/ScrollArea/ScrollArea.css.ts +40 -0
- package/src/components/ScrollArea/ScrollArea.spec.tsx +6 -0
- package/src/components/ScrollArea/ScrollArea.tsx +68 -0
- package/src/components/ScrollArea/index.ts +1 -0
- package/src/components/Select/Select.css.ts +22 -0
- package/src/components/Select/Select.spec.tsx +65 -0
- package/src/components/Select/Select.tsx +111 -0
- package/src/components/Select/SelectContext.ts +59 -0
- package/src/components/Select/SelectOption.css.ts +14 -0
- package/src/components/Select/SelectOption.tsx +40 -0
- package/src/components/Select/SelectOptionList.css.ts +68 -0
- package/src/components/Select/SelectOptionList.tsx +59 -0
- package/src/components/Select/SelectTrigger.css.ts +73 -0
- package/src/components/Select/SelectTrigger.tsx +49 -0
- package/src/components/Select/index.tsx +2 -0
- package/src/components/Skeleton/Skeleton.css.ts +26 -0
- package/src/components/Skeleton/Skeleton.spec.tsx +6 -0
- package/src/components/Skeleton/index.tsx +27 -0
- package/src/components/Table/Table.css.ts +10 -0
- package/src/components/Table/Table.spec.tsx +12 -0
- package/src/components/Table/Table.tsx +27 -0
- package/src/components/Table/TableBody.tsx +14 -0
- package/src/components/Table/TableCell.css.ts +43 -0
- package/src/components/Table/TableCell.tsx +30 -0
- package/src/components/Table/TableHead.css.ts +10 -0
- package/src/components/Table/TableHead.tsx +30 -0
- package/src/components/Table/TableHeader.tsx +14 -0
- package/src/components/Table/TableRow.css.ts +3 -0
- package/src/components/Table/TableRow.tsx +24 -0
- package/src/components/Table/index.ts +6 -0
- package/src/components/Tabs/Tabs.spec.tsx +46 -0
- package/src/components/Tabs/Tabs.tsx +34 -0
- package/src/components/Tabs/TabsContent.tsx +32 -0
- package/src/components/Tabs/TabsList.css.ts +11 -0
- package/src/components/Tabs/TabsList.tsx +25 -0
- package/src/components/Tabs/TabsProvider.tsx +17 -0
- package/src/components/Tabs/TabsTrigger.css.ts +38 -0
- package/src/components/Tabs/TabsTrigger.tsx +43 -0
- package/src/components/Tabs/index.ts +4 -0
- package/src/components/TextField/TextField.css.ts +81 -0
- package/src/components/TextField/TextField.spec.tsx +6 -0
- package/src/components/TextField/index.tsx +38 -0
- package/src/components/Toast/Toast.css.ts +79 -0
- package/src/components/Toast/Toast.spec.tsx +6 -0
- package/src/components/Toast/index.tsx +48 -0
- package/src/components/Typography/Typography.css.ts +17 -0
- package/src/components/Typography/Typography.spec.tsx +35 -0
- package/src/components/Typography/index.tsx +57 -0
- package/src/components/index.ts +18 -0
- package/src/contexts/UIProvider.tsx +30 -0
- package/src/contexts/index.ts +1 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useDialog/index.tsx +51 -0
- package/src/hooks/useDialog/useDialog.spec.tsx +80 -0
- package/src/hooks/useMouseScroll/index.ts +63 -0
- package/src/hooks/usePointerSlider/index.ts +79 -0
- package/src/hooks/useRipple/index.tsx +152 -0
- package/src/hooks/useRipple/ripple.css.ts +40 -0
- package/src/hooks/useToast/ToastContainer.css.ts +12 -0
- package/src/hooks/useToast/ToastContainer.tsx +11 -0
- package/src/hooks/useToast/ToastProvider.tsx +131 -0
- package/src/hooks/useToast/index.ts +15 -0
- package/src/index.ts +8 -0
- package/src/styles/globalStyle.css.ts +36 -0
- package/src/styles/index.ts +4 -0
- package/src/styles/layers.css.ts +4 -0
- package/src/styles/overlay.css.ts +40 -0
- package/src/styles/sprinkles.css.ts +149 -0
- package/src/styles/sx.ts +13 -0
- package/src/tests/uiTest.tsx +54 -0
- package/src/themes/darkTheme.css.ts +30 -0
- package/src/themes/index.ts +3 -0
- package/src/themes/lightTheme.css.ts +30 -0
- package/src/themes/theme.css.ts +32 -0
- package/src/tokens/index.ts +5 -0
- package/src/tokens/scale/color.ts +604 -0
- package/src/tokens/semantic/breakpoint.ts +6 -0
- package/src/tokens/semantic/color.ts +10 -0
- package/src/tokens/semantic/spacing.ts +9 -0
- package/src/tokens/semantic/typography.ts +32 -0
- package/src/types/index.ts +1 -0
- package/src/types/ui.types.ts +26 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/sprinklesUtils.ts +28 -0
- package/src/utils/styleUtils.css.ts +109 -0
- package/tsconfig.json +11 -0
- package/turbo/generators/config.ts +30 -0
- package/turbo/generators/templates/component.hbs +8 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { sprinkles } from '#styles';
|
|
2
|
+
|
|
3
|
+
type SprinklesKey =
|
|
4
|
+
typeof sprinkles.properties extends Set<infer U> ? U : never;
|
|
5
|
+
|
|
6
|
+
export const filterSprinkles = (props: { [key: string]: unknown }) => {
|
|
7
|
+
const result = {} as { [key in SprinklesKey]: unknown };
|
|
8
|
+
|
|
9
|
+
for (const key in props) {
|
|
10
|
+
if (sprinkles.properties.has(key as SprinklesKey)) {
|
|
11
|
+
result[key as SprinklesKey] = props[key];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return result as Parameters<typeof sprinkles>[0];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const omitSprinkles = (props: { [key: string]: unknown }) => {
|
|
19
|
+
const result = {} as { [key: string]: unknown };
|
|
20
|
+
|
|
21
|
+
for (const key in props) {
|
|
22
|
+
if (!sprinkles.properties.has(key as SprinklesKey)) {
|
|
23
|
+
result[key as SprinklesKey] = props[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { style, type StyleRule } from '@vanilla-extract/css';
|
|
2
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
3
|
+
|
|
4
|
+
import { componentsLayer } from '#styles';
|
|
5
|
+
|
|
6
|
+
type StyleRuleWithoutLayer =
|
|
7
|
+
| Omit<StyleRule, '@layer'>
|
|
8
|
+
| string
|
|
9
|
+
| (Omit<StyleRule, '@layer'> | string)[];
|
|
10
|
+
type RecipeStyleRuleWithoutLayer =
|
|
11
|
+
| Omit<StyleRule, '@layer'>
|
|
12
|
+
| string
|
|
13
|
+
| (Omit<StyleRule, '@layer'> | string)[];
|
|
14
|
+
type VariantDefinitions = Record<string, RecipeStyleRuleWithoutLayer>;
|
|
15
|
+
type BooleanMap<T> = T extends 'true' | 'false' ? boolean : T;
|
|
16
|
+
type VariantGroups = Record<string, VariantDefinitions>;
|
|
17
|
+
type VariantSelection<Variants extends VariantGroups> = {
|
|
18
|
+
[VariantGroup in keyof Variants]?:
|
|
19
|
+
| BooleanMap<keyof Variants[VariantGroup]>
|
|
20
|
+
| undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
interface CompoundVariant<Variants extends VariantGroups> {
|
|
24
|
+
variants: VariantSelection<Variants>;
|
|
25
|
+
style: RecipeStyleRuleWithoutLayer;
|
|
26
|
+
}
|
|
27
|
+
type PatternOptions<Variants extends VariantGroups> = {
|
|
28
|
+
base?: RecipeStyleRuleWithoutLayer;
|
|
29
|
+
variants?: Variants;
|
|
30
|
+
defaultVariants?: VariantSelection<Variants>;
|
|
31
|
+
compoundVariants?: Array<CompoundVariant<Variants>>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const styleWithLayer = (
|
|
35
|
+
rule: StyleRuleWithoutLayer,
|
|
36
|
+
layer: string = componentsLayer,
|
|
37
|
+
) => {
|
|
38
|
+
if (Array.isArray(rule)) {
|
|
39
|
+
return rule
|
|
40
|
+
.map((ruleItem) => {
|
|
41
|
+
if (typeof ruleItem === 'string') {
|
|
42
|
+
return ruleItem;
|
|
43
|
+
}
|
|
44
|
+
return style({ '@layer': { [layer]: ruleItem } });
|
|
45
|
+
})
|
|
46
|
+
.join(' ');
|
|
47
|
+
} else if (typeof rule === 'string') {
|
|
48
|
+
return rule;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return style({ '@layer': { [layer]: rule } });
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const recipeWithLayer = <Variants extends VariantGroups>(
|
|
55
|
+
options: PatternOptions<Variants>,
|
|
56
|
+
layer: string = componentsLayer,
|
|
57
|
+
) => {
|
|
58
|
+
const { base, compoundVariants, defaultVariants, variants } = options;
|
|
59
|
+
|
|
60
|
+
let layeredBase: RecipeStyleRuleWithoutLayer | undefined;
|
|
61
|
+
|
|
62
|
+
if (base) {
|
|
63
|
+
if (typeof base === 'string') {
|
|
64
|
+
layeredBase = base;
|
|
65
|
+
} else if (Array.isArray(base)) {
|
|
66
|
+
layeredBase = base
|
|
67
|
+
.map((rule) => {
|
|
68
|
+
if (typeof rule === 'string') {
|
|
69
|
+
return rule;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (Array.isArray(rule)) {
|
|
73
|
+
return rule.join(' ');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return style({ '@layer': { [layer]: rule } });
|
|
77
|
+
})
|
|
78
|
+
.join(' ');
|
|
79
|
+
} else {
|
|
80
|
+
layeredBase = style({ '@layer': { [layer]: base } });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let layeredVariants: Variants | undefined;
|
|
85
|
+
|
|
86
|
+
if (variants) {
|
|
87
|
+
layeredVariants = Object.entries(variants).reduce(
|
|
88
|
+
(prev, [variantKey, variantValue]) => {
|
|
89
|
+
return {
|
|
90
|
+
...prev,
|
|
91
|
+
[variantKey]: Object.entries(variantValue).reduce(
|
|
92
|
+
(prev, [key, value]) => {
|
|
93
|
+
return { ...prev, [key]: styleWithLayer(value, layer) };
|
|
94
|
+
},
|
|
95
|
+
{},
|
|
96
|
+
),
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
{} as Variants,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return recipe({
|
|
104
|
+
base: layeredBase,
|
|
105
|
+
compoundVariants,
|
|
106
|
+
defaultVariants,
|
|
107
|
+
variants: layeredVariants,
|
|
108
|
+
});
|
|
109
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@repo/typescript-config/react-library.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"types": ["@testing-library/jest-dom"],
|
|
7
|
+
"lib": ["ESNext", "DOM"]
|
|
8
|
+
},
|
|
9
|
+
"include": ["src"],
|
|
10
|
+
"exclude": ["node_modules", "dist"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PlopTypes } from '@turbo/gen';
|
|
2
|
+
|
|
3
|
+
// Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation
|
|
4
|
+
|
|
5
|
+
export default function generator(plop: PlopTypes.NodePlopAPI): void {
|
|
6
|
+
// A simple generator to add a new React component to the internal UI library
|
|
7
|
+
plop.setGenerator('react-component', {
|
|
8
|
+
description: 'Adds a new react component',
|
|
9
|
+
prompts: [
|
|
10
|
+
{
|
|
11
|
+
type: 'input',
|
|
12
|
+
name: 'name',
|
|
13
|
+
message: 'What is the name of the component?',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
actions: [
|
|
17
|
+
{
|
|
18
|
+
type: 'add',
|
|
19
|
+
path: 'src/{{kebabCase name}}.tsx',
|
|
20
|
+
templateFile: 'templates/component.hbs',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: 'append',
|
|
24
|
+
path: 'package.json',
|
|
25
|
+
pattern: /"exports": {(?<insertion>)/g,
|
|
26
|
+
template: ' "./{{kebabCase name}}": "./src/{{kebabCase name}}.tsx",',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
}
|