@tipp/ui 1.4.8 → 1.4.9
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/dist/atoms/button.cjs +30 -10
- package/dist/atoms/button.cjs.map +1 -1
- package/dist/atoms/button.d.cts +3 -2
- package/dist/atoms/button.d.ts +3 -2
- package/dist/atoms/button.js +1 -1
- package/dist/atoms/dialog.cjs +30 -10
- package/dist/atoms/dialog.cjs.map +1 -1
- package/dist/atoms/dialog.js +2 -2
- package/dist/atoms/drawer.cjs +30 -10
- package/dist/atoms/drawer.cjs.map +1 -1
- package/dist/atoms/drawer.js +2 -2
- package/dist/atoms/field-error-wrapper.js +2 -2
- package/dist/atoms/index.cjs +30 -10
- package/dist/atoms/index.cjs.map +1 -1
- package/dist/atoms/index.d.cts +1 -0
- package/dist/atoms/index.d.ts +1 -0
- package/dist/atoms/index.js +60 -60
- package/dist/atoms/pagination.js +2 -2
- package/dist/chunk-3YBBMDHJ.js +60 -0
- package/dist/chunk-3YBBMDHJ.js.map +1 -0
- package/dist/chunk-7YPMSAU3.js +164 -0
- package/dist/chunk-7YPMSAU3.js.map +1 -0
- package/dist/chunk-BSG2Q4XC.js +192 -0
- package/dist/chunk-BSG2Q4XC.js.map +1 -0
- package/dist/chunk-EIAK47TI.js +77 -0
- package/dist/chunk-EIAK47TI.js.map +1 -0
- package/dist/chunk-EQC3MBY2.js +164 -0
- package/dist/chunk-EQC3MBY2.js.map +1 -0
- package/dist/chunk-GIUL45NR.js +63 -0
- package/dist/chunk-GIUL45NR.js.map +1 -0
- package/dist/chunk-KK6EZCIU.js +192 -0
- package/dist/chunk-KK6EZCIU.js.map +1 -0
- package/dist/chunk-LGWPZRFJ.js +340 -0
- package/dist/chunk-LGWPZRFJ.js.map +1 -0
- package/dist/chunk-TSVUJJVY.js +340 -0
- package/dist/chunk-TSVUJJVY.js.map +1 -0
- package/dist/chunk-WM3XQMNK.js +88 -0
- package/dist/chunk-WM3XQMNK.js.map +1 -0
- package/dist/chunk-XXODW32Q.js +63 -0
- package/dist/chunk-XXODW32Q.js.map +1 -0
- package/dist/index.cjs +30 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +77 -77
- package/dist/molecules/date-picker/index.js +2 -2
- package/dist/molecules/expand-table/index.js +28 -28
- package/dist/molecules/expand-table/row.js +27 -27
- package/dist/molecules/index.cjs +30 -10
- package/dist/molecules/index.cjs.map +1 -1
- package/dist/molecules/index.js +34 -34
- package/dist/molecules/learning-post.cjs +30 -10
- package/dist/molecules/learning-post.cjs.map +1 -1
- package/dist/molecules/learning-post.js +4 -4
- package/dist/molecules/navigation.cjs +30 -10
- package/dist/molecules/navigation.cjs.map +1 -1
- package/dist/molecules/navigation.js +28 -28
- package/dist/molecules/stepper.js +3 -3
- package/dist/molecules/tag-selector.cjs +30 -10
- package/dist/molecules/tag-selector.cjs.map +1 -1
- package/dist/molecules/tag-selector.js +28 -28
- package/package.json +1 -1
- package/src/atoms/button.tsx +39 -11
package/src/atoms/button.tsx
CHANGED
|
@@ -2,28 +2,56 @@ import {
|
|
|
2
2
|
Button as RadixButton,
|
|
3
3
|
type ButtonProps as RadixButtonProps,
|
|
4
4
|
} from '@radix-ui/themes';
|
|
5
|
+
import type { Breakpoint, Responsive } from '@radix-ui/themes/props';
|
|
5
6
|
import React, { forwardRef, useMemo } from 'react';
|
|
6
7
|
|
|
7
8
|
export type ButtonProps = Omit<RadixButtonProps, 'size' | 'variant'> & {
|
|
8
|
-
size?: 'small' | 'medium' | 'large'
|
|
9
|
+
size?: Responsive<'small' | 'medium' | 'large'>;
|
|
9
10
|
variant?: RadixButtonProps['variant'] | 'transparent';
|
|
10
11
|
};
|
|
11
12
|
|
|
13
|
+
const convertSizeStr = (size: ButtonProps['size']): '1' | '2' | '3' | '4' => {
|
|
14
|
+
switch (size) {
|
|
15
|
+
case 'small':
|
|
16
|
+
return '1';
|
|
17
|
+
case 'medium':
|
|
18
|
+
return '2';
|
|
19
|
+
case 'large':
|
|
20
|
+
return '3';
|
|
21
|
+
default:
|
|
22
|
+
return '2';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const convertSizeResponse = (
|
|
27
|
+
size: ButtonProps['size']
|
|
28
|
+
): RadixButtonProps['size'] => {
|
|
29
|
+
if (typeof size === 'string' || typeof size === 'undefined') {
|
|
30
|
+
return convertSizeStr(size);
|
|
31
|
+
}
|
|
32
|
+
const radixSize: RadixButtonProps['size'] = {};
|
|
33
|
+
let key: Breakpoint = 'initial';
|
|
34
|
+
for (key in radixSize) {
|
|
35
|
+
radixSize[key] = convertSizeStr(size[key]);
|
|
36
|
+
}
|
|
37
|
+
return radixSize;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const convertSize = (size: ButtonProps['size']): RadixButtonProps['size'] => {
|
|
41
|
+
if (typeof size === 'string') {
|
|
42
|
+
return convertSizeStr(size);
|
|
43
|
+
}
|
|
44
|
+
return convertSizeResponse(size);
|
|
45
|
+
};
|
|
46
|
+
|
|
12
47
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
13
48
|
(props, ref): React.ReactElement => {
|
|
14
49
|
const { size, style, variant, ...restProps } = props;
|
|
50
|
+
// string인 경우
|
|
51
|
+
//object인 경우
|
|
15
52
|
|
|
16
53
|
const radixSize = useMemo(() => {
|
|
17
|
-
|
|
18
|
-
case 'small':
|
|
19
|
-
return '1';
|
|
20
|
-
case 'medium':
|
|
21
|
-
return '2';
|
|
22
|
-
case 'large':
|
|
23
|
-
return '3';
|
|
24
|
-
default:
|
|
25
|
-
return '2';
|
|
26
|
-
}
|
|
54
|
+
return convertSize(size);
|
|
27
55
|
}, [size]);
|
|
28
56
|
|
|
29
57
|
const mergedStyle = useMemo<ButtonProps['style']>(() => {
|