@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
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { createVar } 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
|
-
|
|
11
|
-
const semanticColors = semanticColor.reduce(
|
|
12
|
-
(prev, color) => ({
|
|
13
|
-
...prev,
|
|
14
|
-
[color]: styleWithLayer({
|
|
15
|
-
vars: {
|
|
16
|
-
[backgroundVar]: theme.color[color],
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
}),
|
|
20
|
-
{} as Record<(typeof semanticColor)[number], string>,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const scaleColors = SCALE_COLOR.reduce(
|
|
24
|
-
(prev, value) => ({
|
|
25
|
-
...prev,
|
|
26
|
-
[value]: styleWithLayer({
|
|
27
|
-
vars: {
|
|
28
|
-
[backgroundVar]: theme.color[value][500],
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
}),
|
|
32
|
-
{} as Record<ScaleColor, string>,
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
export const textField = recipeWithLayer({
|
|
36
|
-
base: {
|
|
37
|
-
padding: '0.75em 0.5em',
|
|
38
|
-
border: `1px solid`,
|
|
39
|
-
borderColor: ` rgb(${theme.color.border})`,
|
|
40
|
-
|
|
41
|
-
backgroundColor: `rgb(${theme.color.background})`,
|
|
42
|
-
|
|
43
|
-
color: `rgb(${theme.color.foreground})`,
|
|
44
|
-
|
|
45
|
-
transition: 'border-color 0.15s ease, color 0.15s ease',
|
|
46
|
-
|
|
47
|
-
outline: 'none',
|
|
48
|
-
|
|
49
|
-
':focus': {
|
|
50
|
-
borderColor: `rgb(${backgroundVar})`,
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
':disabled': {
|
|
54
|
-
color: `rgb(${theme.color['muted-foreground']})`,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
variants: {
|
|
58
|
-
color: {
|
|
59
|
-
...semanticColors,
|
|
60
|
-
...scaleColors,
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
size: {
|
|
64
|
-
sm: {
|
|
65
|
-
borderRadius: theme.borderRadius,
|
|
66
|
-
|
|
67
|
-
fontSize: '0.875em',
|
|
68
|
-
},
|
|
69
|
-
md: {
|
|
70
|
-
borderRadius: theme.borderRadius,
|
|
71
|
-
|
|
72
|
-
fontSize: '1em',
|
|
73
|
-
},
|
|
74
|
-
lg: {
|
|
75
|
-
borderRadius: theme.borderRadius,
|
|
76
|
-
|
|
77
|
-
fontSize: '1.125em',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
|
|
5
|
-
import { sx } from '#styles';
|
|
6
|
-
import type { UIComponent } from '#types';
|
|
7
|
-
|
|
8
|
-
import * as s from './TextField.css';
|
|
9
|
-
|
|
10
|
-
interface TextFieldProps extends UIComponent<'input', typeof s.textField> {
|
|
11
|
-
type?: React.HTMLInputTypeAttribute;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
15
|
-
(
|
|
16
|
-
{
|
|
17
|
-
className,
|
|
18
|
-
type = 'text',
|
|
19
|
-
size = 'md',
|
|
20
|
-
color = 'primary',
|
|
21
|
-
sx: propSx,
|
|
22
|
-
...props
|
|
23
|
-
},
|
|
24
|
-
ref,
|
|
25
|
-
) => {
|
|
26
|
-
return (
|
|
27
|
-
<input
|
|
28
|
-
ref={ref}
|
|
29
|
-
type={type}
|
|
30
|
-
className={clsx(className, s.textField({ size, color }), sx(propSx))}
|
|
31
|
-
{...props}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
TextField.displayName = 'TextField';
|
|
37
|
-
|
|
38
|
-
export { s as textFieldCss };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { createVar, keyframes } from '@vanilla-extract/css';
|
|
2
|
-
|
|
3
|
-
import { recipeWithLayer, styleWithLayer } from '#styleUtils';
|
|
4
|
-
import { theme } from '#themes';
|
|
5
|
-
import { semanticColor } from '#tokens';
|
|
6
|
-
|
|
7
|
-
const colorVar = createVar();
|
|
8
|
-
const foregroundVar = createVar();
|
|
9
|
-
|
|
10
|
-
const semanticColors = semanticColor.reduce(
|
|
11
|
-
(prev, color) => ({
|
|
12
|
-
...prev,
|
|
13
|
-
[color]: styleWithLayer({
|
|
14
|
-
vars: {
|
|
15
|
-
[colorVar]: theme.color[color],
|
|
16
|
-
[foregroundVar]: theme.color[`${color}-foreground`],
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
}),
|
|
20
|
-
{} as Record<(typeof semanticColor)[number], string>,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const fill = keyframes({
|
|
24
|
-
'0%': {
|
|
25
|
-
transform: 'scaleX(0)',
|
|
26
|
-
},
|
|
27
|
-
'100%': {
|
|
28
|
-
transform: 'scaleX(1)',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export const progress = recipeWithLayer({
|
|
33
|
-
base: {
|
|
34
|
-
position: 'absolute',
|
|
35
|
-
inset: '0',
|
|
36
|
-
|
|
37
|
-
width: '100%',
|
|
38
|
-
|
|
39
|
-
backgroundColor: `rgba(${foregroundVar}, 0.25)`,
|
|
40
|
-
|
|
41
|
-
transformOrigin: '0 0',
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
variants: {
|
|
45
|
-
animation: {
|
|
46
|
-
true: {
|
|
47
|
-
animationName: fill,
|
|
48
|
-
animationTimingFunction: 'linear',
|
|
49
|
-
animationIterationCount: '1',
|
|
50
|
-
animationFillMode: 'forwards',
|
|
51
|
-
},
|
|
52
|
-
false: {
|
|
53
|
-
display: 'none',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export const toast = recipeWithLayer({
|
|
60
|
-
base: {
|
|
61
|
-
position: 'relative',
|
|
62
|
-
overflow: 'hidden',
|
|
63
|
-
|
|
64
|
-
padding: '0.875em',
|
|
65
|
-
|
|
66
|
-
backgroundColor: `rgb(${colorVar})`,
|
|
67
|
-
|
|
68
|
-
color: `rgb(${foregroundVar})`,
|
|
69
|
-
whiteSpace: 'nowrap',
|
|
70
|
-
wordBreak: 'break-all',
|
|
71
|
-
|
|
72
|
-
cursor: 'pointer',
|
|
73
|
-
},
|
|
74
|
-
variants: {
|
|
75
|
-
color: {
|
|
76
|
-
...semanticColors,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
|
|
5
|
-
import { Box } from '#components';
|
|
6
|
-
import { sx } from '#styles';
|
|
7
|
-
import type { UIComponent } from '#types';
|
|
8
|
-
|
|
9
|
-
import * as s from './Toast.css';
|
|
10
|
-
|
|
11
|
-
interface ToastProps extends UIComponent<'div', typeof s.toast> {
|
|
12
|
-
duration?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const Toast = forwardRef<HTMLDivElement, ToastProps>(
|
|
16
|
-
(
|
|
17
|
-
{
|
|
18
|
-
children,
|
|
19
|
-
color = 'accent',
|
|
20
|
-
className,
|
|
21
|
-
duration = 0,
|
|
22
|
-
sx: propSx,
|
|
23
|
-
...props
|
|
24
|
-
},
|
|
25
|
-
ref,
|
|
26
|
-
) => {
|
|
27
|
-
return (
|
|
28
|
-
<Box
|
|
29
|
-
ref={ref}
|
|
30
|
-
boxShadow="accent-sm"
|
|
31
|
-
rounded
|
|
32
|
-
className={clsx(s.toast({ color }), className, sx(propSx))}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
<div
|
|
36
|
-
className={s.progress({ animation: duration !== 0 })}
|
|
37
|
-
style={{
|
|
38
|
-
animationDuration: duration > 0 ? `${duration}ms` : undefined,
|
|
39
|
-
}}
|
|
40
|
-
></div>
|
|
41
|
-
<span style={{ position: 'relative' }}>{children}</span>
|
|
42
|
-
</Box>
|
|
43
|
-
);
|
|
44
|
-
},
|
|
45
|
-
);
|
|
46
|
-
Toast.displayName = 'Toast';
|
|
47
|
-
|
|
48
|
-
export { s as toastCss };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { recipeWithLayer } from '#styleUtils';
|
|
2
|
-
|
|
3
|
-
export const typography = recipeWithLayer({
|
|
4
|
-
base: {
|
|
5
|
-
margin: '0',
|
|
6
|
-
},
|
|
7
|
-
variants: {
|
|
8
|
-
isEllipsis: {
|
|
9
|
-
true: {
|
|
10
|
-
overflow: 'hidden',
|
|
11
|
-
|
|
12
|
-
whiteSpace: 'nowrap',
|
|
13
|
-
textOverflow: 'ellipsis',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
|
|
3
|
-
import { cleanup, render, screen } from '@testing-library/react';
|
|
4
|
-
|
|
5
|
-
import { Typography } from '#components';
|
|
6
|
-
|
|
7
|
-
import { uiTest } from '../../tests/uiTest';
|
|
8
|
-
|
|
9
|
-
describe('Typogrphy 컴포넌트', () => {
|
|
10
|
-
uiTest(Typography, 'Typography');
|
|
11
|
-
|
|
12
|
-
test('기본적으로 p태그로 출력한다.', () => {
|
|
13
|
-
render(<Typography>test</Typography>);
|
|
14
|
-
expect(screen.getByText('test').tagName.toLowerCase()).toBe('p');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('as에 전달된 알맞은 태그로 출력한다.', () => {
|
|
18
|
-
const tags: ComponentProps<typeof Typography>['as'][] = [
|
|
19
|
-
'p',
|
|
20
|
-
'h1',
|
|
21
|
-
'h2',
|
|
22
|
-
'h3',
|
|
23
|
-
'h4',
|
|
24
|
-
'h5',
|
|
25
|
-
'h6',
|
|
26
|
-
'span',
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
for (const tag of tags) {
|
|
30
|
-
cleanup();
|
|
31
|
-
render(<Typography as={tag}>test</Typography>);
|
|
32
|
-
expect(screen.getByText('test').tagName.toLowerCase()).toBe(tag);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
|
|
5
|
-
import { sprinkles, type SprinklesProps } from '#styles';
|
|
6
|
-
import { type UIComponent } from '#types';
|
|
7
|
-
|
|
8
|
-
import * as s from './Typography.css';
|
|
9
|
-
|
|
10
|
-
type TypographyElement = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';
|
|
11
|
-
|
|
12
|
-
type TypographyProps<T extends TypographyElement = TypographyElement> = Omit<
|
|
13
|
-
UIComponent<T, typeof s.typography> & {
|
|
14
|
-
as?: T;
|
|
15
|
-
color?: SprinklesProps['color'];
|
|
16
|
-
fontSize?: SprinklesProps['fontSize'];
|
|
17
|
-
fontWeight?: SprinklesProps['fontWeight'];
|
|
18
|
-
lineHeight?: SprinklesProps['lineHeight'];
|
|
19
|
-
},
|
|
20
|
-
'ref'
|
|
21
|
-
>;
|
|
22
|
-
|
|
23
|
-
export const Typography = forwardRef<HTMLParagraphElement, TypographyProps>(
|
|
24
|
-
(
|
|
25
|
-
{
|
|
26
|
-
children,
|
|
27
|
-
as: Component = 'p',
|
|
28
|
-
className,
|
|
29
|
-
color = 'foreground',
|
|
30
|
-
fontSize = 'md',
|
|
31
|
-
fontWeight = 'normal',
|
|
32
|
-
lineHeight,
|
|
33
|
-
isEllipsis = false,
|
|
34
|
-
sx,
|
|
35
|
-
...props
|
|
36
|
-
},
|
|
37
|
-
ref,
|
|
38
|
-
) => {
|
|
39
|
-
return (
|
|
40
|
-
<Component
|
|
41
|
-
ref={ref}
|
|
42
|
-
className={clsx(
|
|
43
|
-
s.typography({ isEllipsis }),
|
|
44
|
-
sprinkles({ color, fontSize, fontWeight, lineHeight }),
|
|
45
|
-
sx && sprinkles(sx),
|
|
46
|
-
className,
|
|
47
|
-
)}
|
|
48
|
-
{...props}
|
|
49
|
-
>
|
|
50
|
-
{children}
|
|
51
|
-
</Component>
|
|
52
|
-
);
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
Typography.displayName = 'Typography';
|
|
56
|
-
|
|
57
|
-
export { s as typographyCss };
|
package/src/components/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export * from './Accordion';
|
|
2
|
-
export * from './Alert';
|
|
3
|
-
export * from './Box';
|
|
4
|
-
export * from './Button';
|
|
5
|
-
export * from './Card';
|
|
6
|
-
export * from './Chip';
|
|
7
|
-
export * from './Confirm';
|
|
8
|
-
export * from './Dialog';
|
|
9
|
-
export * from './Navigation';
|
|
10
|
-
export * from './Range';
|
|
11
|
-
export * from './ScrollArea';
|
|
12
|
-
export * from './Select';
|
|
13
|
-
export * from './Skeleton';
|
|
14
|
-
export * from './Table';
|
|
15
|
-
export * from './Tabs';
|
|
16
|
-
export * from './TextField';
|
|
17
|
-
export * from './Toast';
|
|
18
|
-
export * from './Typography';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import { OverlayProvider, type OverlayOption } from '@kimdw-rtk/utils';
|
|
6
|
-
|
|
7
|
-
import { ToastProvider } from '#hooks';
|
|
8
|
-
|
|
9
|
-
import * as overlayStyle from '../styles/overlay.css';
|
|
10
|
-
|
|
11
|
-
interface UIProviderProps {
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
overlayUnmountOn?: OverlayOption['unmountOn'];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const UIProvider = ({
|
|
17
|
-
children,
|
|
18
|
-
overlayUnmountOn = 'transitionEnd',
|
|
19
|
-
}: UIProviderProps) => {
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
<OverlayProvider
|
|
23
|
-
className={{ ...overlayStyle }}
|
|
24
|
-
unmountOn={overlayUnmountOn}
|
|
25
|
-
>
|
|
26
|
-
<ToastProvider>{children}</ToastProvider>
|
|
27
|
-
</OverlayProvider>
|
|
28
|
-
</>
|
|
29
|
-
);
|
|
30
|
-
};
|
package/src/contexts/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './UIProvider';
|
package/src/hooks/index.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ReactNode, useCallback, useMemo, useRef } from 'react';
|
|
4
|
-
|
|
5
|
-
import { useOverlay } from '@kimdw-rtk/utils';
|
|
6
|
-
|
|
7
|
-
import { Alert, Confirm } from '#components';
|
|
8
|
-
|
|
9
|
-
export const useDialog = () => {
|
|
10
|
-
const { push } = useOverlay();
|
|
11
|
-
const dialogRef = useRef<{ close: () => void }>(null);
|
|
12
|
-
|
|
13
|
-
const alert = useCallback(
|
|
14
|
-
(message: ReactNode) => {
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
push(<Alert>{message}</Alert>, { onClose: () => resolve(true) });
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
[push],
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const confirm = useCallback(
|
|
23
|
-
(message: ReactNode): Promise<boolean> => {
|
|
24
|
-
return new Promise((resolve) => {
|
|
25
|
-
const handleConfirm = () => {
|
|
26
|
-
resolve(true);
|
|
27
|
-
dialogRef.current?.close();
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const handleCancle = () => {
|
|
31
|
-
resolve(false);
|
|
32
|
-
dialogRef.current?.close();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
push(
|
|
36
|
-
<Confirm
|
|
37
|
-
ref={dialogRef}
|
|
38
|
-
onConfirm={handleConfirm}
|
|
39
|
-
onCancle={handleCancle}
|
|
40
|
-
>
|
|
41
|
-
{message}
|
|
42
|
-
</Confirm>,
|
|
43
|
-
{ onClose: () => resolve(false) },
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
[push],
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
return useMemo(() => ({ alert, confirm }), [alert, confirm]);
|
|
51
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { act, render, screen, waitFor } from '@testing-library/react';
|
|
2
|
-
|
|
3
|
-
import { UIProvider } from '#contexts';
|
|
4
|
-
import { useDialog } from '#hooks';
|
|
5
|
-
|
|
6
|
-
describe('useDialog 테스트', () => {
|
|
7
|
-
const mockFn = jest.fn();
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
const TestComponent = () => {
|
|
11
|
-
const { alert, confirm } = useDialog();
|
|
12
|
-
|
|
13
|
-
const handleConfirmClick = async () => {
|
|
14
|
-
mockFn(await confirm('confirm'));
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<>
|
|
19
|
-
<button onClick={() => alert('alert')}>alert click</button>
|
|
20
|
-
<button onClick={handleConfirmClick}>confirm click</button>
|
|
21
|
-
</>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
render(
|
|
26
|
-
<UIProvider overlayUnmountOn={'exit'}>
|
|
27
|
-
<TestComponent />
|
|
28
|
-
</UIProvider>,
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('확인 버튼을 누르면 alert을 닫을 수 있다.', async () => {
|
|
33
|
-
const alertButton = screen.getByRole('button', { name: 'alert click' });
|
|
34
|
-
|
|
35
|
-
expect(screen.queryByText('alert')).not.toBeInTheDocument();
|
|
36
|
-
|
|
37
|
-
act(() => {
|
|
38
|
-
alertButton.click();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
expect(screen.getByText('alert')).toBeInTheDocument();
|
|
42
|
-
|
|
43
|
-
const okButton = screen.getByRole('button', { name: '확인' });
|
|
44
|
-
act(() => {
|
|
45
|
-
okButton.click();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
expect(screen.queryByText('alert')).not.toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it.skip('confirm의 확인 버튼을 누르면 true, 취소 버튼을 누르면 false를 반환한다.', async () => {
|
|
52
|
-
const confirmButton = screen.getByRole('button', { name: 'confirm click' });
|
|
53
|
-
|
|
54
|
-
act(() => {
|
|
55
|
-
confirmButton.click();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const okButton = screen.getByRole('button', { name: '확인' });
|
|
59
|
-
act(() => {
|
|
60
|
-
okButton.click();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
await waitFor(() => {
|
|
64
|
-
expect(mockFn.mock.calls[0][0]).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
act(() => {
|
|
68
|
-
confirmButton.click();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const cancelButton = screen.getByRole('button', { name: '취소' });
|
|
72
|
-
act(() => {
|
|
73
|
-
cancelButton.click();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
await waitFor(() => {
|
|
77
|
-
expect(mockFn.mock.calls[1][0]).toBe(false);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 마우스를 사용하는 환경에서도 드래그로 가로 스크롤을 할 수 있게 만드는 hook
|
|
7
|
-
*/
|
|
8
|
-
export const useMouseScroll = <T extends React.RefObject<HTMLElement | null>>(
|
|
9
|
-
ref: T,
|
|
10
|
-
): void => {
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const element = ref.current;
|
|
13
|
-
let isDown = false,
|
|
14
|
-
startX = 0,
|
|
15
|
-
startLeft = 0;
|
|
16
|
-
|
|
17
|
-
if (element === null) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const handleMouseDown = (e: MouseEvent) => {
|
|
22
|
-
if (!element.contains(e.target as Node)) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
isDown = true;
|
|
27
|
-
|
|
28
|
-
startLeft = element.scrollLeft;
|
|
29
|
-
startX = e.x;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const handleMouseMove = (e: MouseEvent) => {
|
|
33
|
-
if (!isDown) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
element.scrollLeft = startLeft + startX - e.x;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const handleMouseUp = () => {
|
|
41
|
-
isDown = false;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const handleWheel = (e: WheelEvent) => {
|
|
45
|
-
element.scrollTo({
|
|
46
|
-
left: element.scrollLeft + e.deltaY,
|
|
47
|
-
behavior: 'smooth',
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
window.addEventListener('mousedown', handleMouseDown);
|
|
52
|
-
window.addEventListener('mousemove', handleMouseMove);
|
|
53
|
-
window.addEventListener('mouseup', handleMouseUp);
|
|
54
|
-
element.addEventListener('wheel', handleWheel);
|
|
55
|
-
|
|
56
|
-
return () => {
|
|
57
|
-
window.removeEventListener('mousedown', handleMouseDown);
|
|
58
|
-
window.removeEventListener('mousemove', handleMouseMove);
|
|
59
|
-
window.removeEventListener('mouseup', handleMouseUp);
|
|
60
|
-
element.removeEventListener('wheel', handleWheel);
|
|
61
|
-
};
|
|
62
|
-
}, [ref]);
|
|
63
|
-
};
|