@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.
Files changed (158) hide show
  1. package/.babelrc +12 -0
  2. package/.turbo/turbo-check-types.log +2 -0
  3. package/.turbo/turbo-lint.log +12 -0
  4. package/.turbo/turbo-test.log +4084 -0
  5. package/.vscode/settings.json +4 -0
  6. package/eslint.config.mjs +4 -0
  7. package/jest.config.json +10 -0
  8. package/jest.setup.js +2 -0
  9. package/package.json +53 -0
  10. package/src/components/Accordion/Accordion.css.ts +29 -0
  11. package/src/components/Accordion/Accordion.spec.tsx +6 -0
  12. package/src/components/Accordion/Accordion.tsx +44 -0
  13. package/src/components/Accordion/AccordionContent.css.ts +29 -0
  14. package/src/components/Accordion/AccordionContent.tsx +87 -0
  15. package/src/components/Accordion/AccordionContext.ts +9 -0
  16. package/src/components/Accordion/AccordionTrigger.css.ts +46 -0
  17. package/src/components/Accordion/AccordionTrigger.tsx +41 -0
  18. package/src/components/Accordion/index.ts +3 -0
  19. package/src/components/Alert/index.tsx +25 -0
  20. package/src/components/Box/Box.css.ts +18 -0
  21. package/src/components/Box/Box.spec.tsx +6 -0
  22. package/src/components/Box/index.tsx +41 -0
  23. package/src/components/Button/Button.css.ts +241 -0
  24. package/src/components/Button/Button.spec.tsx +30 -0
  25. package/src/components/Button/index.tsx +60 -0
  26. package/src/components/Card/Card.css.ts +93 -0
  27. package/src/components/Card/Card.spec.tsx +24 -0
  28. package/src/components/Card/Card.tsx +41 -0
  29. package/src/components/Card/CardContent.css.ts +8 -0
  30. package/src/components/Card/CardContent.tsx +23 -0
  31. package/src/components/Card/CardInteraction.css.ts +11 -0
  32. package/src/components/Card/CardInteraction.tsx +36 -0
  33. package/src/components/Card/CardThumbnail.css.ts +6 -0
  34. package/src/components/Card/CardThumbnail.tsx +23 -0
  35. package/src/components/Card/index.ts +4 -0
  36. package/src/components/Chip/Chip.css.ts +75 -0
  37. package/src/components/Chip/Chip.spec.tsx +6 -0
  38. package/src/components/Chip/Chip.tsx +37 -0
  39. package/src/components/Chip/index.ts +1 -0
  40. package/src/components/Confirm/index.tsx +44 -0
  41. package/src/components/Dialog/Dialog.css.ts +25 -0
  42. package/src/components/Dialog/Dialog.spec.tsx +26 -0
  43. package/src/components/Dialog/Dialog.tsx +30 -0
  44. package/src/components/Dialog/DialogContent.css.ts +16 -0
  45. package/src/components/Dialog/DialogContent.tsx +26 -0
  46. package/src/components/Dialog/DialogFooter.css.ts +20 -0
  47. package/src/components/Dialog/DialogFooter.tsx +26 -0
  48. package/src/components/Dialog/DialogHeader.css.ts +31 -0
  49. package/src/components/Dialog/DialogHeader.tsx +37 -0
  50. package/src/components/Dialog/index.ts +4 -0
  51. package/src/components/Navigation/Navigation.spec.tsx +19 -0
  52. package/src/components/Navigation/NavigationAside.css.ts +7 -0
  53. package/src/components/Navigation/NavigationAside.tsx +23 -0
  54. package/src/components/Navigation/NavigationBar.css.ts +42 -0
  55. package/src/components/Navigation/NavigationBar.tsx +25 -0
  56. package/src/components/Navigation/NavigationContainer.css.ts +11 -0
  57. package/src/components/Navigation/NavigationContainer.tsx +26 -0
  58. package/src/components/Navigation/NavigationDrawer.css.ts +61 -0
  59. package/src/components/Navigation/NavigationDrawer.tsx +67 -0
  60. package/src/components/Navigation/NavigationItem.css.ts +43 -0
  61. package/src/components/Navigation/NavigationItem.tsx +24 -0
  62. package/src/components/Navigation/NavigationLogo.css.ts +5 -0
  63. package/src/components/Navigation/NavigationLogo.tsx +28 -0
  64. package/src/components/Navigation/NavigationMenu.css.ts +23 -0
  65. package/src/components/Navigation/NavigationMenu.tsx +25 -0
  66. package/src/components/Navigation/index.ts +7 -0
  67. package/src/components/Range/Range.css.ts +132 -0
  68. package/src/components/Range/Range.spec.tsx +6 -0
  69. package/src/components/Range/Range.tsx +90 -0
  70. package/src/components/Range/index.ts +1 -0
  71. package/src/components/ScrollArea/ScrollArea.css.ts +40 -0
  72. package/src/components/ScrollArea/ScrollArea.spec.tsx +6 -0
  73. package/src/components/ScrollArea/ScrollArea.tsx +68 -0
  74. package/src/components/ScrollArea/index.ts +1 -0
  75. package/src/components/Select/Select.css.ts +22 -0
  76. package/src/components/Select/Select.spec.tsx +65 -0
  77. package/src/components/Select/Select.tsx +111 -0
  78. package/src/components/Select/SelectContext.ts +59 -0
  79. package/src/components/Select/SelectOption.css.ts +14 -0
  80. package/src/components/Select/SelectOption.tsx +40 -0
  81. package/src/components/Select/SelectOptionList.css.ts +68 -0
  82. package/src/components/Select/SelectOptionList.tsx +59 -0
  83. package/src/components/Select/SelectTrigger.css.ts +73 -0
  84. package/src/components/Select/SelectTrigger.tsx +49 -0
  85. package/src/components/Select/index.tsx +2 -0
  86. package/src/components/Skeleton/Skeleton.css.ts +26 -0
  87. package/src/components/Skeleton/Skeleton.spec.tsx +6 -0
  88. package/src/components/Skeleton/index.tsx +27 -0
  89. package/src/components/Table/Table.css.ts +10 -0
  90. package/src/components/Table/Table.spec.tsx +12 -0
  91. package/src/components/Table/Table.tsx +27 -0
  92. package/src/components/Table/TableBody.tsx +14 -0
  93. package/src/components/Table/TableCell.css.ts +43 -0
  94. package/src/components/Table/TableCell.tsx +30 -0
  95. package/src/components/Table/TableHead.css.ts +10 -0
  96. package/src/components/Table/TableHead.tsx +30 -0
  97. package/src/components/Table/TableHeader.tsx +14 -0
  98. package/src/components/Table/TableRow.css.ts +3 -0
  99. package/src/components/Table/TableRow.tsx +24 -0
  100. package/src/components/Table/index.ts +6 -0
  101. package/src/components/Tabs/Tabs.spec.tsx +46 -0
  102. package/src/components/Tabs/Tabs.tsx +34 -0
  103. package/src/components/Tabs/TabsContent.tsx +32 -0
  104. package/src/components/Tabs/TabsList.css.ts +11 -0
  105. package/src/components/Tabs/TabsList.tsx +25 -0
  106. package/src/components/Tabs/TabsProvider.tsx +17 -0
  107. package/src/components/Tabs/TabsTrigger.css.ts +38 -0
  108. package/src/components/Tabs/TabsTrigger.tsx +43 -0
  109. package/src/components/Tabs/index.ts +4 -0
  110. package/src/components/TextField/TextField.css.ts +81 -0
  111. package/src/components/TextField/TextField.spec.tsx +6 -0
  112. package/src/components/TextField/index.tsx +38 -0
  113. package/src/components/Toast/Toast.css.ts +79 -0
  114. package/src/components/Toast/Toast.spec.tsx +6 -0
  115. package/src/components/Toast/index.tsx +48 -0
  116. package/src/components/Typography/Typography.css.ts +17 -0
  117. package/src/components/Typography/Typography.spec.tsx +35 -0
  118. package/src/components/Typography/index.tsx +57 -0
  119. package/src/components/index.ts +18 -0
  120. package/src/contexts/UIProvider.tsx +30 -0
  121. package/src/contexts/index.ts +1 -0
  122. package/src/hooks/index.ts +5 -0
  123. package/src/hooks/useDialog/index.tsx +51 -0
  124. package/src/hooks/useDialog/useDialog.spec.tsx +80 -0
  125. package/src/hooks/useMouseScroll/index.ts +63 -0
  126. package/src/hooks/usePointerSlider/index.ts +79 -0
  127. package/src/hooks/useRipple/index.tsx +152 -0
  128. package/src/hooks/useRipple/ripple.css.ts +40 -0
  129. package/src/hooks/useToast/ToastContainer.css.ts +12 -0
  130. package/src/hooks/useToast/ToastContainer.tsx +11 -0
  131. package/src/hooks/useToast/ToastProvider.tsx +131 -0
  132. package/src/hooks/useToast/index.ts +15 -0
  133. package/src/index.ts +8 -0
  134. package/src/styles/globalStyle.css.ts +36 -0
  135. package/src/styles/index.ts +4 -0
  136. package/src/styles/layers.css.ts +4 -0
  137. package/src/styles/overlay.css.ts +40 -0
  138. package/src/styles/sprinkles.css.ts +149 -0
  139. package/src/styles/sx.ts +13 -0
  140. package/src/tests/uiTest.tsx +54 -0
  141. package/src/themes/darkTheme.css.ts +30 -0
  142. package/src/themes/index.ts +3 -0
  143. package/src/themes/lightTheme.css.ts +30 -0
  144. package/src/themes/theme.css.ts +32 -0
  145. package/src/tokens/index.ts +5 -0
  146. package/src/tokens/scale/color.ts +604 -0
  147. package/src/tokens/semantic/breakpoint.ts +6 -0
  148. package/src/tokens/semantic/color.ts +10 -0
  149. package/src/tokens/semantic/spacing.ts +9 -0
  150. package/src/tokens/semantic/typography.ts +32 -0
  151. package/src/types/index.ts +1 -0
  152. package/src/types/ui.types.ts +26 -0
  153. package/src/utils/index.ts +1 -0
  154. package/src/utils/sprinklesUtils.ts +28 -0
  155. package/src/utils/styleUtils.css.ts +109 -0
  156. package/tsconfig.json +11 -0
  157. package/turbo/generators/config.ts +30 -0
  158. package/turbo/generators/templates/component.hbs +8 -0
@@ -0,0 +1,40 @@
1
+ import { globalStyle, style } from '@vanilla-extract/css';
2
+
3
+ export const enter = style({
4
+ opacity: '1 !important',
5
+ transition: 'all 0.2s ease',
6
+ });
7
+
8
+ export const base = style({
9
+ display: 'flex',
10
+ alignItems: 'center',
11
+ justifyContent: 'center',
12
+ position: 'fixed',
13
+ inset: '0',
14
+ zIndex: '100',
15
+
16
+ backgroundColor: '#00000080',
17
+
18
+ opacity: '0',
19
+ });
20
+
21
+ export const exit = style({
22
+ opacity: '0 !important',
23
+ transition: 'all 0.2s ease',
24
+
25
+ pointerEvents: 'none',
26
+ });
27
+
28
+ globalStyle(`${enter} > div`, {
29
+ transform: 'scale(1) !important',
30
+ transition: 'all 0.2s ease',
31
+ });
32
+
33
+ globalStyle(`${base} > div`, {
34
+ transform: 'scale(0.9)',
35
+ });
36
+
37
+ globalStyle(`${exit} > div`, {
38
+ transform: 'scale(0.9) !important',
39
+ transition: 'all 0.2s ease',
40
+ });
@@ -0,0 +1,149 @@
1
+ import { createSprinkles, defineProperties } from '@vanilla-extract/sprinkles';
2
+
3
+ import { sprinklesLayer } from '#styles';
4
+ import { theme } from '#themes';
5
+ import { breakpoint, lightColor, spacing, typography } from '#tokens';
6
+
7
+ type ColorName = keyof typeof lightColor;
8
+ type ColorScale<C extends ColorName> = keyof (typeof lightColor)[C];
9
+ type Color = Record<`${ColorName}-${ColorScale<ColorName>}`, string>;
10
+ type SemanticColor = Record<keyof typeof theme.color, string>;
11
+
12
+ const colors = Object.assign(
13
+ {},
14
+ ...[
15
+ ...Object.entries(lightColor).reduce(
16
+ (prev, [name, scales]) => [
17
+ ...prev,
18
+ ...Object.entries(scales).map(
19
+ ([scale, value]) =>
20
+ ({ [`${name}-${scale}`]: `rgb(${value})` }) as Color,
21
+ ),
22
+ ],
23
+ [] as Color[],
24
+ ),
25
+ ...Object.entries(theme.color).map(
26
+ ([name, value]) => ({ [name]: `rgb(${value})` }) as SemanticColor,
27
+ ),
28
+ ],
29
+ ) as Record<keyof Color | keyof SemanticColor, string>;
30
+
31
+ export const colorProperties = defineProperties({
32
+ '@layer': sprinklesLayer,
33
+ properties: {
34
+ color: colors,
35
+ borderColor: colors,
36
+ backgroundColor: colors,
37
+ },
38
+ });
39
+
40
+ const size = {
41
+ auto: 'auto',
42
+ '0': '0',
43
+ '100%': '100%',
44
+ '5em': '5em',
45
+ '10em': '10em',
46
+ '15em': '15em',
47
+ '20em': '20em',
48
+ '25em': '25em',
49
+ };
50
+
51
+ export const boxProperties = defineProperties({
52
+ '@layer': sprinklesLayer,
53
+ conditions: {
54
+ mobile: {},
55
+ desktop: { '@media': 'screen and (min-width: 1024px)' },
56
+ },
57
+ defaultCondition: 'mobile',
58
+ properties: {
59
+ display: ['flex', 'block', 'none', 'inline', 'inline-block', 'inline-flex'],
60
+ flexDirection: ['row', 'column', 'row-reverse', 'column-reverse'],
61
+ flexWrap: ['nowrap', 'wrap', 'wrap-reverse', 'revert', 'revert-layer'],
62
+ flexShrink: {
63
+ '0': 0,
64
+ '1': 1,
65
+ },
66
+ flexGrow: {
67
+ '0': 0,
68
+ '1': 1,
69
+ },
70
+ flexBasis: size,
71
+ justifyContent: [
72
+ 'stretch',
73
+ 'flex-start',
74
+ 'center',
75
+ 'flex-end',
76
+ 'space-around',
77
+ 'space-between',
78
+ ],
79
+ alignItems: ['stretch', 'flex-start', 'center', 'flex-end'],
80
+ gap: spacing,
81
+ paddingTop: spacing,
82
+ paddingBottom: spacing,
83
+ paddingLeft: spacing,
84
+ paddingRight: spacing,
85
+ marginTop: spacing,
86
+ marginBottom: spacing,
87
+ marginLeft: spacing,
88
+ marginRight: spacing,
89
+ boxShadow: {
90
+ 'border-sm': `0 0 0.5rem 0.0625rem rgba(${theme.color.border}, 0.33)`,
91
+ 'border-md': `0 0 1rem 0.1875rem rgba(${theme.color.border}, 0.33)`,
92
+ 'border-lg': `0 0 1.5rem 0.375rem rgba(${theme.color.border}, 0.33)`,
93
+ 'accent-sm': `0 0 0.5rem 0.0625rem rgb(${theme.color.accent})`,
94
+ 'accent-md': `0 0 1rem 0.125rem rgb(${theme.color.accent})`,
95
+ 'accent-lg': `0 0 1.5rem 0.375rem rgb(${theme.color.accent})`,
96
+ },
97
+ borderRadius: {
98
+ none: '0',
99
+ sm: `calc(${theme.borderRadius} * 0.75)`,
100
+ md: theme.borderRadius,
101
+ lg: `calc(${theme.borderRadius} * 1.5)`,
102
+ },
103
+ width: size,
104
+ height: size,
105
+ },
106
+ shorthands: {
107
+ padding: ['paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight'],
108
+ paddingX: ['paddingLeft', 'paddingRight'],
109
+ paddingY: ['paddingTop', 'paddingBottom'],
110
+ margin: ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'],
111
+ marginX: ['marginLeft', 'marginRight'],
112
+ marginY: ['marginTop', 'marginBottom'],
113
+ },
114
+ });
115
+
116
+ export const typographyProperties = defineProperties({
117
+ '@layer': sprinklesLayer,
118
+ conditions: {
119
+ mobile: {},
120
+ desktop: { '@media': `screen and (min-width: ${breakpoint.md}px)` },
121
+ },
122
+ defaultCondition: 'mobile',
123
+ properties: {
124
+ lineHeight: typography.lineHeight,
125
+ fontSize: typography.size,
126
+ fontWeight: typography.weight,
127
+ wordBreak: ['break-all', 'break-word', 'keep-all'],
128
+ },
129
+ });
130
+
131
+ export const miscProperties = defineProperties({
132
+ '@layer': sprinklesLayer,
133
+ properties: {
134
+ cursor: {
135
+ pointer: 'pointer',
136
+ 'not-allowed': 'not-allowed',
137
+ default: 'default',
138
+ },
139
+ },
140
+ });
141
+
142
+ export const sprinkles = createSprinkles(
143
+ boxProperties,
144
+ colorProperties,
145
+ typographyProperties,
146
+ miscProperties,
147
+ );
148
+
149
+ export type SprinklesProps = Parameters<typeof sprinkles>[0];
@@ -0,0 +1,13 @@
1
+ import { sprinkles } from '#styles';
2
+
3
+ export const sx = (param?: Parameters<typeof sprinkles>[0] | string) => {
4
+ if (param === undefined) {
5
+ return '';
6
+ }
7
+
8
+ if (typeof param === 'string') {
9
+ return param;
10
+ }
11
+
12
+ return sprinkles(param);
13
+ };
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+
5
+ import { sprinkles } from '#styles';
6
+
7
+ //eslint-disable-next-line
8
+ export const uiTest = <T extends HTMLElement>(
9
+ Component: React.ComponentType<any>,
10
+ name: string,
11
+ ) => {
12
+ describe(`${name} UI`, () => {
13
+ test('컴포넌트가 렌더링된다.', () => {
14
+ render(<Component data-testid="component" />);
15
+ expect(screen.getByTestId('component')).toBeInTheDocument();
16
+ });
17
+
18
+ test('sprinkles을 사용할 수 있다.', () => {
19
+ render(
20
+ <Component
21
+ className={sprinkles({ margin: 'md' })}
22
+ data-testid="component"
23
+ />,
24
+ );
25
+ expect(screen.getByTestId('component')).toHaveClass(
26
+ sprinkles({ margin: 'md' }),
27
+ );
28
+ });
29
+
30
+ test('sx를 사용할 수 있다.', () => {
31
+ render(<Component sx={{ margin: 'md' }} data-testid="component" />);
32
+ expect(screen.getByTestId('component')).toHaveClass(
33
+ sprinkles({ margin: 'md' }),
34
+ );
35
+ });
36
+
37
+ test('className을 적용할 수 있다.', () => {
38
+ render(<Component className="test" data-testid="component" />);
39
+ expect(screen.getByTestId('component')).toHaveClass('test');
40
+ });
41
+
42
+ test('inline style을 적용할 수 있다.', () => {
43
+ render(<Component style={{ color: 'red' }} data-testid="component" />);
44
+ expect(screen.getByTestId('component')).toHaveStyle({ color: 'red' });
45
+ });
46
+
47
+ test('ref를 적용할 수 있다.', () => {
48
+ const ref = React.createRef<T>();
49
+ render(<Component ref={ref} />);
50
+
51
+ expect(ref.current).not.toBeNull();
52
+ });
53
+ });
54
+ };
@@ -0,0 +1,30 @@
1
+ import { darkColor } from '../tokens/scale/color';
2
+
3
+ export const darkThemeVars = {
4
+ borderRadius: '6px',
5
+ color: {
6
+ background: '12, 12, 14',
7
+ foreground: '238, 238, 238',
8
+ primary: '36, 81, 173',
9
+ 'primary-foreground': '238, 238, 238',
10
+ secondary: '32, 38, 45',
11
+ 'secondary-foreground': '212, 212, 213',
12
+ muted: '30, 36, 44',
13
+ 'muted-foreground': '102, 112, 133',
14
+ accent: '41, 52, 67',
15
+ 'accent-foreground': '186, 212, 255',
16
+ border: '38, 43, 51',
17
+ 'border.weak': '32, 32, 32',
18
+ card: '23, 23, 25',
19
+ 'card-foreground': '238, 238, 238',
20
+ 'card.gradient': '255, 255, 255',
21
+ success: '22, 163, 74',
22
+ 'success-foreground': '255, 255, 255',
23
+ danger: '220, 38, 38',
24
+ 'danger-foreground': '255, 255, 255',
25
+ warning: '202, 138, 4',
26
+ 'warning-foreground': '30, 23, 0',
27
+ shadow: '0, 0, 0',
28
+ ...darkColor,
29
+ },
30
+ };
@@ -0,0 +1,3 @@
1
+ export * from './darkTheme.css';
2
+ export * from './lightTheme.css';
3
+ export { theme } from './theme.css';
@@ -0,0 +1,30 @@
1
+ import { lightColor } from '../tokens/scale/color';
2
+
3
+ export const lightThemeVars = {
4
+ borderRadius: '6px',
5
+ color: {
6
+ background: '255, 255, 255',
7
+ foreground: '10, 10, 11',
8
+ primary: '42, 122, 255',
9
+ 'primary-foreground': '240, 248, 255',
10
+ secondary: '240, 242, 245',
11
+ 'secondary-foreground': '48, 48, 49',
12
+ muted: '234, 239, 245',
13
+ 'muted-foreground': '120, 120, 120',
14
+ accent: '216, 226, 239',
15
+ 'accent-foreground': '32, 32, 33',
16
+ border: '203, 213, 225',
17
+ 'border.weak': '220, 229, 237',
18
+ card: '244, 247, 255',
19
+ 'card-foreground': '10, 10, 11',
20
+ 'card.gradient': '179, 195, 255',
21
+ success: '34, 197, 94',
22
+ 'success-foreground': '255, 255, 255',
23
+ danger: '239, 68, 68',
24
+ 'danger-foreground': '255, 255, 255',
25
+ warning: '251, 191, 36',
26
+ 'warning-foreground': '49, 36, 0',
27
+ shadow: '188, 188, 188',
28
+ ...lightColor,
29
+ },
30
+ };
@@ -0,0 +1,32 @@
1
+ import { createThemeContract } from '@vanilla-extract/css';
2
+
3
+ import { semanticColor } from '#tokens';
4
+
5
+ import { lightColor } from '../tokens/scale/color';
6
+
7
+ const semanticColors = semanticColor.reduce(
8
+ (prev, current) => ({
9
+ ...prev,
10
+ [current]: null,
11
+ [`${current}-foreground`]: null,
12
+ }),
13
+ {},
14
+ ) as Record<
15
+ | (typeof semanticColor)[number]
16
+ | `${(typeof semanticColor)[number]}-foreground`,
17
+ null
18
+ >;
19
+
20
+ export const theme = createThemeContract({
21
+ borderRadius: null,
22
+ color: {
23
+ background: null,
24
+ foreground: null,
25
+ border: null,
26
+ 'border.weak': null,
27
+ 'card.gradient': null,
28
+ shadow: null,
29
+ ...semanticColors,
30
+ ...lightColor,
31
+ },
32
+ });
@@ -0,0 +1,5 @@
1
+ export { lightColor, darkColor } from './scale/color';
2
+ export { breakpoint } from './semantic/breakpoint';
3
+ export { semanticColor } from './semantic/color';
4
+ export { spacing } from './semantic/spacing';
5
+ export { typography } from './semantic/typography';