@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.
Files changed (63) hide show
  1. package/dist/atoms/button.cjs +30 -10
  2. package/dist/atoms/button.cjs.map +1 -1
  3. package/dist/atoms/button.d.cts +3 -2
  4. package/dist/atoms/button.d.ts +3 -2
  5. package/dist/atoms/button.js +1 -1
  6. package/dist/atoms/dialog.cjs +30 -10
  7. package/dist/atoms/dialog.cjs.map +1 -1
  8. package/dist/atoms/dialog.js +2 -2
  9. package/dist/atoms/drawer.cjs +30 -10
  10. package/dist/atoms/drawer.cjs.map +1 -1
  11. package/dist/atoms/drawer.js +2 -2
  12. package/dist/atoms/field-error-wrapper.js +2 -2
  13. package/dist/atoms/index.cjs +30 -10
  14. package/dist/atoms/index.cjs.map +1 -1
  15. package/dist/atoms/index.d.cts +1 -0
  16. package/dist/atoms/index.d.ts +1 -0
  17. package/dist/atoms/index.js +60 -60
  18. package/dist/atoms/pagination.js +2 -2
  19. package/dist/chunk-3YBBMDHJ.js +60 -0
  20. package/dist/chunk-3YBBMDHJ.js.map +1 -0
  21. package/dist/chunk-7YPMSAU3.js +164 -0
  22. package/dist/chunk-7YPMSAU3.js.map +1 -0
  23. package/dist/chunk-BSG2Q4XC.js +192 -0
  24. package/dist/chunk-BSG2Q4XC.js.map +1 -0
  25. package/dist/chunk-EIAK47TI.js +77 -0
  26. package/dist/chunk-EIAK47TI.js.map +1 -0
  27. package/dist/chunk-EQC3MBY2.js +164 -0
  28. package/dist/chunk-EQC3MBY2.js.map +1 -0
  29. package/dist/chunk-GIUL45NR.js +63 -0
  30. package/dist/chunk-GIUL45NR.js.map +1 -0
  31. package/dist/chunk-KK6EZCIU.js +192 -0
  32. package/dist/chunk-KK6EZCIU.js.map +1 -0
  33. package/dist/chunk-LGWPZRFJ.js +340 -0
  34. package/dist/chunk-LGWPZRFJ.js.map +1 -0
  35. package/dist/chunk-TSVUJJVY.js +340 -0
  36. package/dist/chunk-TSVUJJVY.js.map +1 -0
  37. package/dist/chunk-WM3XQMNK.js +88 -0
  38. package/dist/chunk-WM3XQMNK.js.map +1 -0
  39. package/dist/chunk-XXODW32Q.js +63 -0
  40. package/dist/chunk-XXODW32Q.js.map +1 -0
  41. package/dist/index.cjs +30 -10
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +1 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +77 -77
  46. package/dist/molecules/date-picker/index.js +2 -2
  47. package/dist/molecules/expand-table/index.js +28 -28
  48. package/dist/molecules/expand-table/row.js +27 -27
  49. package/dist/molecules/index.cjs +30 -10
  50. package/dist/molecules/index.cjs.map +1 -1
  51. package/dist/molecules/index.js +34 -34
  52. package/dist/molecules/learning-post.cjs +30 -10
  53. package/dist/molecules/learning-post.cjs.map +1 -1
  54. package/dist/molecules/learning-post.js +4 -4
  55. package/dist/molecules/navigation.cjs +30 -10
  56. package/dist/molecules/navigation.cjs.map +1 -1
  57. package/dist/molecules/navigation.js +28 -28
  58. package/dist/molecules/stepper.js +3 -3
  59. package/dist/molecules/tag-selector.cjs +30 -10
  60. package/dist/molecules/tag-selector.cjs.map +1 -1
  61. package/dist/molecules/tag-selector.js +28 -28
  62. package/package.json +1 -1
  63. package/src/atoms/button.tsx +39 -11
@@ -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
- switch (size) {
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']>(() => {