@kimdw-rtk/ui 0.0.0 → 0.0.2
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/package.json +6 -2
- package/.babelrc +0 -12
- package/.turbo/turbo-check-types.log +0 -2
- package/.turbo/turbo-lint.log +0 -12
- package/.turbo/turbo-test.log +0 -4084
- package/.vscode/settings.json +0 -4
- package/eslint.config.mjs +0 -4
- package/jest.config.json +0 -10
- package/jest.setup.js +0 -2
- package/src/components/Accordion/Accordion.css.ts +0 -29
- package/src/components/Accordion/Accordion.spec.tsx +0 -6
- package/src/components/Accordion/Accordion.tsx +0 -44
- package/src/components/Accordion/AccordionContent.css.ts +0 -29
- package/src/components/Accordion/AccordionContent.tsx +0 -87
- package/src/components/Accordion/AccordionContext.ts +0 -9
- package/src/components/Accordion/AccordionTrigger.css.ts +0 -46
- package/src/components/Accordion/AccordionTrigger.tsx +0 -41
- package/src/components/Accordion/index.ts +0 -3
- package/src/components/Alert/index.tsx +0 -25
- package/src/components/Box/Box.css.ts +0 -18
- package/src/components/Box/Box.spec.tsx +0 -6
- package/src/components/Box/index.tsx +0 -41
- package/src/components/Button/Button.css.ts +0 -241
- package/src/components/Button/Button.spec.tsx +0 -30
- package/src/components/Button/index.tsx +0 -60
- package/src/components/Card/Card.css.ts +0 -93
- package/src/components/Card/Card.spec.tsx +0 -24
- package/src/components/Card/Card.tsx +0 -41
- package/src/components/Card/CardContent.css.ts +0 -8
- package/src/components/Card/CardContent.tsx +0 -23
- package/src/components/Card/CardInteraction.css.ts +0 -11
- package/src/components/Card/CardInteraction.tsx +0 -36
- package/src/components/Card/CardThumbnail.css.ts +0 -6
- package/src/components/Card/CardThumbnail.tsx +0 -23
- package/src/components/Card/index.ts +0 -4
- package/src/components/Chip/Chip.css.ts +0 -75
- package/src/components/Chip/Chip.spec.tsx +0 -6
- package/src/components/Chip/Chip.tsx +0 -37
- package/src/components/Chip/index.ts +0 -1
- package/src/components/Confirm/index.tsx +0 -44
- package/src/components/Dialog/Dialog.css.ts +0 -25
- package/src/components/Dialog/Dialog.spec.tsx +0 -26
- package/src/components/Dialog/Dialog.tsx +0 -30
- package/src/components/Dialog/DialogContent.css.ts +0 -16
- package/src/components/Dialog/DialogContent.tsx +0 -26
- package/src/components/Dialog/DialogFooter.css.ts +0 -20
- package/src/components/Dialog/DialogFooter.tsx +0 -26
- package/src/components/Dialog/DialogHeader.css.ts +0 -31
- package/src/components/Dialog/DialogHeader.tsx +0 -37
- package/src/components/Dialog/index.ts +0 -4
- package/src/components/Navigation/Navigation.spec.tsx +0 -19
- package/src/components/Navigation/NavigationAside.css.ts +0 -7
- package/src/components/Navigation/NavigationAside.tsx +0 -23
- package/src/components/Navigation/NavigationBar.css.ts +0 -42
- package/src/components/Navigation/NavigationBar.tsx +0 -25
- package/src/components/Navigation/NavigationContainer.css.ts +0 -11
- package/src/components/Navigation/NavigationContainer.tsx +0 -26
- package/src/components/Navigation/NavigationDrawer.css.ts +0 -61
- package/src/components/Navigation/NavigationDrawer.tsx +0 -67
- package/src/components/Navigation/NavigationItem.css.ts +0 -43
- package/src/components/Navigation/NavigationItem.tsx +0 -24
- package/src/components/Navigation/NavigationLogo.css.ts +0 -5
- package/src/components/Navigation/NavigationLogo.tsx +0 -28
- package/src/components/Navigation/NavigationMenu.css.ts +0 -23
- package/src/components/Navigation/NavigationMenu.tsx +0 -25
- package/src/components/Navigation/index.ts +0 -7
- package/src/components/Range/Range.css.ts +0 -132
- package/src/components/Range/Range.spec.tsx +0 -6
- package/src/components/Range/Range.tsx +0 -90
- package/src/components/Range/index.ts +0 -1
- package/src/components/ScrollArea/ScrollArea.css.ts +0 -40
- package/src/components/ScrollArea/ScrollArea.spec.tsx +0 -6
- package/src/components/ScrollArea/ScrollArea.tsx +0 -68
- package/src/components/ScrollArea/index.ts +0 -1
- package/src/components/Select/Select.css.ts +0 -22
- package/src/components/Select/Select.spec.tsx +0 -65
- package/src/components/Select/Select.tsx +0 -111
- package/src/components/Select/SelectContext.ts +0 -59
- package/src/components/Select/SelectOption.css.ts +0 -14
- package/src/components/Select/SelectOption.tsx +0 -40
- package/src/components/Select/SelectOptionList.css.ts +0 -68
- package/src/components/Select/SelectOptionList.tsx +0 -59
- package/src/components/Select/SelectTrigger.css.ts +0 -73
- package/src/components/Select/SelectTrigger.tsx +0 -49
- package/src/components/Select/index.tsx +0 -2
- package/src/components/Skeleton/Skeleton.css.ts +0 -26
- package/src/components/Skeleton/Skeleton.spec.tsx +0 -6
- package/src/components/Skeleton/index.tsx +0 -27
- package/src/components/Table/Table.css.ts +0 -10
- package/src/components/Table/Table.spec.tsx +0 -12
- package/src/components/Table/Table.tsx +0 -27
- package/src/components/Table/TableBody.tsx +0 -14
- package/src/components/Table/TableCell.css.ts +0 -43
- package/src/components/Table/TableCell.tsx +0 -30
- package/src/components/Table/TableHead.css.ts +0 -10
- package/src/components/Table/TableHead.tsx +0 -30
- package/src/components/Table/TableHeader.tsx +0 -14
- package/src/components/Table/TableRow.css.ts +0 -3
- package/src/components/Table/TableRow.tsx +0 -24
- package/src/components/Table/index.ts +0 -6
- package/src/components/Tabs/Tabs.spec.tsx +0 -46
- package/src/components/Tabs/Tabs.tsx +0 -34
- package/src/components/Tabs/TabsContent.tsx +0 -32
- package/src/components/Tabs/TabsList.css.ts +0 -11
- package/src/components/Tabs/TabsList.tsx +0 -25
- package/src/components/Tabs/TabsProvider.tsx +0 -17
- package/src/components/Tabs/TabsTrigger.css.ts +0 -38
- package/src/components/Tabs/TabsTrigger.tsx +0 -43
- package/src/components/Tabs/index.ts +0 -4
- package/src/components/TextField/TextField.css.ts +0 -81
- package/src/components/TextField/TextField.spec.tsx +0 -6
- package/src/components/TextField/index.tsx +0 -38
- package/src/components/Toast/Toast.css.ts +0 -79
- package/src/components/Toast/Toast.spec.tsx +0 -6
- package/src/components/Toast/index.tsx +0 -48
- package/src/components/Typography/Typography.css.ts +0 -17
- package/src/components/Typography/Typography.spec.tsx +0 -35
- package/src/components/Typography/index.tsx +0 -57
- package/src/components/index.ts +0 -18
- package/src/contexts/UIProvider.tsx +0 -30
- package/src/contexts/index.ts +0 -1
- package/src/hooks/index.ts +0 -5
- package/src/hooks/useDialog/index.tsx +0 -51
- package/src/hooks/useDialog/useDialog.spec.tsx +0 -80
- package/src/hooks/useMouseScroll/index.ts +0 -63
- package/src/hooks/usePointerSlider/index.ts +0 -79
- package/src/hooks/useRipple/index.tsx +0 -152
- package/src/hooks/useRipple/ripple.css.ts +0 -40
- package/src/hooks/useToast/ToastContainer.css.ts +0 -12
- package/src/hooks/useToast/ToastContainer.tsx +0 -11
- package/src/hooks/useToast/ToastProvider.tsx +0 -131
- package/src/hooks/useToast/index.ts +0 -15
- package/src/index.ts +0 -8
- package/src/styles/globalStyle.css.ts +0 -36
- package/src/styles/index.ts +0 -4
- package/src/styles/layers.css.ts +0 -4
- package/src/styles/overlay.css.ts +0 -40
- package/src/styles/sprinkles.css.ts +0 -149
- package/src/styles/sx.ts +0 -13
- package/src/tests/uiTest.tsx +0 -54
- package/src/themes/darkTheme.css.ts +0 -30
- package/src/themes/index.ts +0 -3
- package/src/themes/lightTheme.css.ts +0 -30
- package/src/themes/theme.css.ts +0 -32
- package/src/tokens/index.ts +0 -5
- package/src/tokens/scale/color.ts +0 -604
- package/src/tokens/semantic/breakpoint.ts +0 -6
- package/src/tokens/semantic/color.ts +0 -10
- package/src/tokens/semantic/spacing.ts +0 -9
- package/src/tokens/semantic/typography.ts +0 -32
- package/src/types/index.ts +0 -1
- package/src/types/ui.types.ts +0 -26
- package/src/utils/index.ts +0 -1
- package/src/utils/sprinklesUtils.ts +0 -28
- package/src/utils/styleUtils.css.ts +0 -109
- package/tsconfig.json +0 -11
- package/turbo/generators/config.ts +0 -30
- package/turbo/generators/templates/component.hbs +0 -8
package/.vscode/settings.json
DELETED
package/eslint.config.mjs
DELETED
package/jest.config.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"testEnvironment": "jsdom",
|
|
3
|
-
"setupFilesAfterEnv": ["<rootDir>/jest.setup.js"],
|
|
4
|
-
"transform": {
|
|
5
|
-
"\\.css\\.ts$": "@vanilla-extract/jest-transform",
|
|
6
|
-
"^.+\\.(ts|tsx)?$": "ts-jest",
|
|
7
|
-
"^.+\\.[t|j]sx?$": "babel-jest"
|
|
8
|
-
},
|
|
9
|
-
"testPathIgnorePatterns": ["/node_modules/", "/dist/"]
|
|
10
|
-
}
|
package/jest.setup.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createVar } from '@vanilla-extract/css';
|
|
2
|
-
|
|
3
|
-
import { recipeWithLayer } from '#styleUtils';
|
|
4
|
-
import { theme } from '#themes';
|
|
5
|
-
|
|
6
|
-
export const paddingVar = createVar();
|
|
7
|
-
|
|
8
|
-
export const accordion = recipeWithLayer({
|
|
9
|
-
base: {
|
|
10
|
-
width: '100%',
|
|
11
|
-
borderBottom: `1px solid rgb(${theme.color.border})`,
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
variants: {
|
|
15
|
-
isPadding: {
|
|
16
|
-
true: {
|
|
17
|
-
vars: {
|
|
18
|
-
[paddingVar]: '0.75em',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
false: {
|
|
23
|
-
vars: {
|
|
24
|
-
[paddingVar]: '0.75em 0',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { forwardRef, useReducer } from 'react';
|
|
4
|
-
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
|
|
7
|
-
import { sx } from '#styles';
|
|
8
|
-
import type { UIComponent } from '#types';
|
|
9
|
-
|
|
10
|
-
import * as s from './Accordion.css';
|
|
11
|
-
import { AccordionContext, accordionReducer } from './AccordionContext';
|
|
12
|
-
|
|
13
|
-
interface AccordionProps extends UIComponent<'div', typeof s.accordion> {
|
|
14
|
-
isExpanded?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
|
|
18
|
-
(
|
|
19
|
-
{
|
|
20
|
-
children,
|
|
21
|
-
className,
|
|
22
|
-
isPadding = true,
|
|
23
|
-
isExpanded: initIsExpaned = false,
|
|
24
|
-
sx: propSx,
|
|
25
|
-
...props
|
|
26
|
-
},
|
|
27
|
-
ref,
|
|
28
|
-
) => {
|
|
29
|
-
const [isExpanded, dispatch] = useReducer(accordionReducer, initIsExpaned);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div
|
|
33
|
-
ref={ref}
|
|
34
|
-
className={clsx(s.accordion({ isPadding }), className, sx(propSx))}
|
|
35
|
-
{...props}
|
|
36
|
-
>
|
|
37
|
-
<AccordionContext.Provider value={{ isExpanded, dispatch }}>
|
|
38
|
-
{children}
|
|
39
|
-
</AccordionContext.Provider>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
Accordion.displayName = 'Accordion';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { recipeWithLayer, styleWithLayer } from '#styleUtils';
|
|
2
|
-
|
|
3
|
-
import { paddingVar } from './Accordion.css';
|
|
4
|
-
|
|
5
|
-
export const container = recipeWithLayer({
|
|
6
|
-
base: {
|
|
7
|
-
overflow: 'hidden',
|
|
8
|
-
|
|
9
|
-
transition: 'height 0.2s ease, opacity 0.2s ease',
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
variants: {
|
|
13
|
-
isExpanded: {
|
|
14
|
-
true: {
|
|
15
|
-
opacity: '1',
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
false: {
|
|
19
|
-
height: '0',
|
|
20
|
-
|
|
21
|
-
opacity: '0',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export const inner = styleWithLayer({
|
|
28
|
-
padding: paddingVar,
|
|
29
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type ReactNode,
|
|
5
|
-
useContext,
|
|
6
|
-
useEffect,
|
|
7
|
-
useLayoutEffect,
|
|
8
|
-
useRef,
|
|
9
|
-
} from 'react';
|
|
10
|
-
|
|
11
|
-
import * as s from './AccordionContent.css';
|
|
12
|
-
import { AccordionContext } from './AccordionContext';
|
|
13
|
-
|
|
14
|
-
interface AccordionContentProps {
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const AccordionContent = ({ children }: AccordionContentProps) => {
|
|
19
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
20
|
-
const accordionContext = useContext(AccordionContext);
|
|
21
|
-
const initRef = useRef<boolean>(true);
|
|
22
|
-
|
|
23
|
-
if (!accordionContext) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
'AccordionContent must be used within an Accordion component.',
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const { isExpanded } = accordionContext;
|
|
30
|
-
|
|
31
|
-
useLayoutEffect(() => {
|
|
32
|
-
const container = containerRef.current;
|
|
33
|
-
if (!container) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!isExpanded) {
|
|
38
|
-
container.style.height = `${container.scrollHeight}px`;
|
|
39
|
-
container.className = s.container({ isExpanded });
|
|
40
|
-
//eslint-disable-next-line
|
|
41
|
-
container.offsetTop;
|
|
42
|
-
container.style.height = '0';
|
|
43
|
-
initRef.current = false;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (initRef.current) {
|
|
48
|
-
container.style.height = 'auto';
|
|
49
|
-
} else {
|
|
50
|
-
container.style.height = `${container.scrollHeight}px`;
|
|
51
|
-
}
|
|
52
|
-
container.className = s.container({ isExpanded });
|
|
53
|
-
|
|
54
|
-
initRef.current = false;
|
|
55
|
-
}, [isExpanded]);
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
const container = containerRef.current;
|
|
59
|
-
if (!container) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const handleTransitionEnd = (e: TransitionEvent) => {
|
|
64
|
-
if (
|
|
65
|
-
e.target !== container ||
|
|
66
|
-
e.propertyName !== 'height' ||
|
|
67
|
-
!isExpanded
|
|
68
|
-
) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
container.style.height = 'auto';
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
container.addEventListener('transitionend', handleTransitionEnd);
|
|
76
|
-
|
|
77
|
-
return () => {
|
|
78
|
-
container.removeEventListener('transitionend', handleTransitionEnd);
|
|
79
|
-
};
|
|
80
|
-
}, [containerRef, isExpanded]);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<div ref={containerRef} className={s.container({ isExpanded })}>
|
|
84
|
-
<div className={s.inner}>{children}</div>
|
|
85
|
-
</div>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createContext, type Dispatch } from 'react';
|
|
2
|
-
|
|
3
|
-
export const AccordionContext = createContext<
|
|
4
|
-
{ isExpanded: boolean; dispatch: Dispatch<boolean> } | undefined
|
|
5
|
-
>(undefined);
|
|
6
|
-
|
|
7
|
-
export const accordionReducer = (_: boolean, action: boolean) => {
|
|
8
|
-
return action;
|
|
9
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { recipeWithLayer } from '#styleUtils';
|
|
2
|
-
|
|
3
|
-
import { paddingVar } from './Accordion.css';
|
|
4
|
-
|
|
5
|
-
export const triggerContainer = recipeWithLayer({
|
|
6
|
-
base: {
|
|
7
|
-
display: 'flex',
|
|
8
|
-
alignItems: 'center',
|
|
9
|
-
gap: '0.25em',
|
|
10
|
-
|
|
11
|
-
width: '100%',
|
|
12
|
-
padding: paddingVar,
|
|
13
|
-
|
|
14
|
-
cursor: 'pointer',
|
|
15
|
-
|
|
16
|
-
':hover': {
|
|
17
|
-
textDecoration: 'underline',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
variants: {
|
|
21
|
-
iconPosition: {
|
|
22
|
-
text: {},
|
|
23
|
-
right: {
|
|
24
|
-
justifyContent: 'space-between',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export const arrow = recipeWithLayer({
|
|
31
|
-
base: {
|
|
32
|
-
lineHeight: '0',
|
|
33
|
-
|
|
34
|
-
transition: 'transform 0.2s ease',
|
|
35
|
-
},
|
|
36
|
-
variants: {
|
|
37
|
-
expand: {
|
|
38
|
-
true: {
|
|
39
|
-
transform: 'rotate(-180deg)',
|
|
40
|
-
},
|
|
41
|
-
false: {
|
|
42
|
-
transform: 'rotate(0)',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ReactNode, useContext } from 'react';
|
|
4
|
-
|
|
5
|
-
import { ChevronDownIcon } from 'lucide-react';
|
|
6
|
-
|
|
7
|
-
import { AccordionContext } from './AccordionContext';
|
|
8
|
-
import * as s from './AccordionTrigger.css';
|
|
9
|
-
|
|
10
|
-
interface AccordionTriggerProps {
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
iconPosition?: 'text' | 'right';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const AccordionTrigger = ({
|
|
16
|
-
children,
|
|
17
|
-
iconPosition = 'right',
|
|
18
|
-
}: AccordionTriggerProps) => {
|
|
19
|
-
const accordionContext = useContext(AccordionContext);
|
|
20
|
-
|
|
21
|
-
if (!accordionContext) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
'AccordionTrigger must be used within an Accordion component.',
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const { dispatch, isExpanded } = accordionContext;
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div
|
|
31
|
-
className={s.triggerContainer({ iconPosition })}
|
|
32
|
-
aria-expanded={isExpanded}
|
|
33
|
-
onClick={() => dispatch(!isExpanded)}
|
|
34
|
-
>
|
|
35
|
-
<span>{children}</span>
|
|
36
|
-
<span className={s.arrow({ expand: isExpanded })}>
|
|
37
|
-
<ChevronDownIcon size="1em" />
|
|
38
|
-
</span>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useOverlay, usePreventKeyboardInput } from '@kimdw-rtk/utils';
|
|
4
|
-
|
|
5
|
-
import { Button, Dialog, DialogContent, DialogFooter } from '#components';
|
|
6
|
-
|
|
7
|
-
interface AlertProps {
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Alert = ({ children }: AlertProps) => {
|
|
12
|
-
const { close } = useOverlay();
|
|
13
|
-
usePreventKeyboardInput();
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Dialog>
|
|
17
|
-
<DialogContent>{children}</DialogContent>
|
|
18
|
-
<DialogFooter>
|
|
19
|
-
<Button size="sm" onClick={close}>
|
|
20
|
-
확인
|
|
21
|
-
</Button>
|
|
22
|
-
</DialogFooter>
|
|
23
|
-
</Dialog>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { recipeWithLayer } from '#styleUtils';
|
|
2
|
-
import { theme } from '#themes';
|
|
3
|
-
|
|
4
|
-
export const box = recipeWithLayer({
|
|
5
|
-
variants: {
|
|
6
|
-
flex: {
|
|
7
|
-
true: {
|
|
8
|
-
display: 'flex',
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
rounded: {
|
|
13
|
-
true: {
|
|
14
|
-
borderRadius: theme.borderRadius,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
|
|
5
|
-
import { sprinkles, sx, type SprinklesProps } from '#styles';
|
|
6
|
-
import type { UIComponent } from '#types';
|
|
7
|
-
import { filterSprinkles, omitSprinkles } from '#utils';
|
|
8
|
-
|
|
9
|
-
import * as s from './Box.css';
|
|
10
|
-
|
|
11
|
-
type BoxProps = UIComponent<'div', typeof s.box> & SprinklesProps;
|
|
12
|
-
|
|
13
|
-
export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
14
|
-
(
|
|
15
|
-
{
|
|
16
|
-
children,
|
|
17
|
-
flex = false,
|
|
18
|
-
rounded = false,
|
|
19
|
-
className,
|
|
20
|
-
sx: propSx,
|
|
21
|
-
...props
|
|
22
|
-
},
|
|
23
|
-
ref,
|
|
24
|
-
) => {
|
|
25
|
-
return (
|
|
26
|
-
<div
|
|
27
|
-
ref={ref}
|
|
28
|
-
className={clsx(
|
|
29
|
-
className,
|
|
30
|
-
s.box({ flex, rounded }),
|
|
31
|
-
sx(propSx),
|
|
32
|
-
sprinkles(filterSprinkles(props)),
|
|
33
|
-
)}
|
|
34
|
-
{...omitSprinkles(props)}
|
|
35
|
-
>
|
|
36
|
-
{children}
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
},
|
|
40
|
-
);
|
|
41
|
-
Box.displayName = 'Box';
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { createVar, globalStyle, keyframes, style } from '@vanilla-extract/css';
|
|
2
|
-
|
|
3
|
-
import { recipeWithLayer, styleWithLayer } from '#styleUtils';
|
|
4
|
-
import { theme } from '#themes';
|
|
5
|
-
import { semanticColor } from '#tokens';
|
|
6
|
-
|
|
7
|
-
import { SCALE_COLOR, type ScaleColor } from '../../tokens/scale/color';
|
|
8
|
-
|
|
9
|
-
const backgroundVar = createVar();
|
|
10
|
-
const foregroundVar = createVar();
|
|
11
|
-
|
|
12
|
-
const semanticColors = semanticColor.reduce(
|
|
13
|
-
(prev, color) => ({
|
|
14
|
-
...prev,
|
|
15
|
-
[color]: styleWithLayer({
|
|
16
|
-
vars: {
|
|
17
|
-
[backgroundVar]: theme.color[color],
|
|
18
|
-
[foregroundVar]: theme.color[`${color}-foreground`],
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
}),
|
|
22
|
-
{} as Record<(typeof semanticColor)[number], string>,
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const scaleColors = SCALE_COLOR.reduce(
|
|
26
|
-
(prev, value) => ({
|
|
27
|
-
...prev,
|
|
28
|
-
[value]: styleWithLayer({
|
|
29
|
-
vars: {
|
|
30
|
-
[backgroundVar]: theme.color[value][500],
|
|
31
|
-
[foregroundVar]: theme.color.background,
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
}),
|
|
35
|
-
{} as Record<ScaleColor, string>,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const pulse = keyframes({
|
|
39
|
-
'0%': {
|
|
40
|
-
backgroundPosition: '-300% 0',
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
'100%': {
|
|
44
|
-
backgroundPosition: '300% 0',
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export const span = recipeWithLayer({
|
|
49
|
-
base: {
|
|
50
|
-
lineHeight: '0',
|
|
51
|
-
},
|
|
52
|
-
variants: {
|
|
53
|
-
size: {
|
|
54
|
-
sm: {
|
|
55
|
-
fontSize: '0.875em',
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
md: {
|
|
59
|
-
fontSize: '1em',
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
lg: {
|
|
63
|
-
fontSize: '1.125em',
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
'icon-sm': {
|
|
67
|
-
fontSize: '1em',
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
'icon-md': {
|
|
71
|
-
fontSize: '1.25em',
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
'icon-lg': {
|
|
75
|
-
fontSize: '1.5em',
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
export const button = recipeWithLayer({
|
|
82
|
-
base: {
|
|
83
|
-
display: 'inline-flex',
|
|
84
|
-
alignItems: 'center',
|
|
85
|
-
justifyContent: 'center',
|
|
86
|
-
position: 'relative',
|
|
87
|
-
overflow: 'hidden',
|
|
88
|
-
|
|
89
|
-
border: '0',
|
|
90
|
-
borderRadius: theme.borderRadius,
|
|
91
|
-
|
|
92
|
-
fontSize: '1em',
|
|
93
|
-
|
|
94
|
-
transition: 'background-color 0.2s ease, color 0.2s ease',
|
|
95
|
-
|
|
96
|
-
cursor: 'pointer',
|
|
97
|
-
userSelect: 'none',
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
variants: {
|
|
101
|
-
hasIcon: {
|
|
102
|
-
true: {
|
|
103
|
-
gap: '0.5em',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
color: {
|
|
108
|
-
...semanticColors,
|
|
109
|
-
...scaleColors,
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
size: {
|
|
113
|
-
sm: {
|
|
114
|
-
height: '2.25em',
|
|
115
|
-
padding: '0 0.75em',
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
md: {
|
|
119
|
-
height: '2.5em',
|
|
120
|
-
padding: '0 0.875em',
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
lg: {
|
|
124
|
-
height: '2.75em',
|
|
125
|
-
padding: '0 1em',
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
'icon-sm': {
|
|
129
|
-
width: '2em',
|
|
130
|
-
height: '2em',
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
'icon-md': {
|
|
134
|
-
width: '2.5em',
|
|
135
|
-
height: '2.5em',
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
'icon-lg': {
|
|
139
|
-
width: '2.75em',
|
|
140
|
-
height: '2.75em',
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
variant: {
|
|
145
|
-
contained: {
|
|
146
|
-
boxShadow: `inset 0 0 0 1px rgba(255, 255, 255, 0.08)`,
|
|
147
|
-
backgroundColor: `rgb(${backgroundVar})`,
|
|
148
|
-
color: `rgb(${foregroundVar})`,
|
|
149
|
-
|
|
150
|
-
':disabled': {
|
|
151
|
-
backgroundColor: `rgb(${theme.color.muted})`,
|
|
152
|
-
|
|
153
|
-
color: `rgb(${theme.color['muted-foreground']})`,
|
|
154
|
-
|
|
155
|
-
cursor: 'default',
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
outlined: {
|
|
160
|
-
boxShadow: `inset 0 0 0 1px rgb(${backgroundVar})`,
|
|
161
|
-
backgroundColor: `rgb(${theme.color.background})`,
|
|
162
|
-
color: `rgb(${theme.color.foreground})`,
|
|
163
|
-
|
|
164
|
-
':disabled': {
|
|
165
|
-
backgroundColor: `rgb(${theme.color.muted})`,
|
|
166
|
-
|
|
167
|
-
color: `rgb(${theme.color['muted-foreground']})`,
|
|
168
|
-
|
|
169
|
-
cursor: 'default',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
ghost: {
|
|
174
|
-
background: 'transparent',
|
|
175
|
-
|
|
176
|
-
color: `rgb(${theme.color.foreground})`,
|
|
177
|
-
|
|
178
|
-
':hover': {
|
|
179
|
-
backgroundColor: `rgba(${backgroundVar}, 0.8)`,
|
|
180
|
-
|
|
181
|
-
color: `rgb(${foregroundVar})`,
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
':disabled': {
|
|
185
|
-
color: `rgb(${theme.color['muted-foreground']})`,
|
|
186
|
-
|
|
187
|
-
cursor: 'default',
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
glass: {
|
|
192
|
-
boxShadow: `inset 0 0 0 1px rgba(255, 255, 255, 0.08)`,
|
|
193
|
-
backgroundColor: `rgba(${backgroundVar}, 0.75)`,
|
|
194
|
-
backdropFilter: 'blur(1rem)',
|
|
195
|
-
|
|
196
|
-
color: `rgb(${theme.color.foreground})`,
|
|
197
|
-
|
|
198
|
-
':disabled': {
|
|
199
|
-
backgroundColor: `rgb(${theme.color.muted})`,
|
|
200
|
-
|
|
201
|
-
color: `rgb(${theme.color['muted-foreground']})`,
|
|
202
|
-
|
|
203
|
-
cursor: 'default',
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
pulse: {
|
|
209
|
-
true: {
|
|
210
|
-
'::after': {
|
|
211
|
-
content: '',
|
|
212
|
-
position: 'absolute',
|
|
213
|
-
inset: '0',
|
|
214
|
-
|
|
215
|
-
background:
|
|
216
|
-
'linear-gradient(90deg, transparent 30%, #ffffff33 65%, transparent 100%)',
|
|
217
|
-
backgroundSize: '300% 100%',
|
|
218
|
-
|
|
219
|
-
animation: `${pulse} 5s linear 0s infinite`,
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
export const icon = style({
|
|
227
|
-
lineHeight: '0',
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
globalStyle(`${icon} > *`, {
|
|
231
|
-
width: '1em',
|
|
232
|
-
height: '1em',
|
|
233
|
-
lineHeight: '0',
|
|
234
|
-
|
|
235
|
-
pointerEvents: 'none',
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
globalStyle(`${button.classNames.base} svg`, {
|
|
239
|
-
width: '1em',
|
|
240
|
-
height: '1em',
|
|
241
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
-
|
|
3
|
-
import { uiTest } from '../../tests/uiTest';
|
|
4
|
-
import { Button } from './';
|
|
5
|
-
|
|
6
|
-
describe('Button 컴포넌트', () => {
|
|
7
|
-
uiTest(Button, 'Button');
|
|
8
|
-
|
|
9
|
-
it('Button을 클릭하면 onClick이 호출되어야 한다', () => {
|
|
10
|
-
const handleClick = jest.fn();
|
|
11
|
-
render(<Button onClick={handleClick}>Click</Button>);
|
|
12
|
-
|
|
13
|
-
fireEvent.click(screen.getByRole('button', { name: 'Click' }));
|
|
14
|
-
|
|
15
|
-
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('disabled Button을 클릭하면 onClick이 호출되지 않아야 한다', () => {
|
|
19
|
-
const handleClick = jest.fn();
|
|
20
|
-
render(
|
|
21
|
-
<Button onClick={handleClick} disabled>
|
|
22
|
-
Click
|
|
23
|
-
</Button>,
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
fireEvent.click(screen.getByRole('button', { name: 'Click' }));
|
|
27
|
-
|
|
28
|
-
expect(handleClick).not.toHaveBeenCalledTimes(1);
|
|
29
|
-
});
|
|
30
|
-
});
|