@ubie/vitals-ui-consumer 0.0.1

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 (170) hide show
  1. package/.storybook/main.ts +14 -0
  2. package/.storybook/preview.tsx +25 -0
  3. package/.storybook/vitest.setup.ts +7 -0
  4. package/dist/chunk-DKo7XVKm.mjs +33 -0
  5. package/dist/index.d.mts +1720 -0
  6. package/dist/index.d.mts.map +1 -0
  7. package/dist/index.mjs +10594 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/style.css +2299 -0
  10. package/package.json +47 -0
  11. package/src/components/Accordion/Accordion.module.css +75 -0
  12. package/src/components/Accordion/Accordion.spec.tsx +18 -0
  13. package/src/components/Accordion/Accordion.stories.tsx +61 -0
  14. package/src/components/Accordion/Accordion.tsx +89 -0
  15. package/src/components/ActionHalfModal/ActionHalfModal.module.css +180 -0
  16. package/src/components/ActionHalfModal/ActionHalfModal.spec.tsx +57 -0
  17. package/src/components/ActionHalfModal/ActionHalfModal.stories.tsx +469 -0
  18. package/src/components/ActionHalfModal/ActionHalfModal.tsx +269 -0
  19. package/src/components/ActionModal/ActionModal.module.css +145 -0
  20. package/src/components/ActionModal/ActionModal.spec.tsx +57 -0
  21. package/src/components/ActionModal/ActionModal.stories.tsx +302 -0
  22. package/src/components/ActionModal/ActionModal.tsx +232 -0
  23. package/src/components/Bold/Bold.module.css +4 -0
  24. package/src/components/Bold/Bold.spec.tsx +24 -0
  25. package/src/components/Bold/Bold.stories.tsx +54 -0
  26. package/src/components/Bold/Bold.tsx +31 -0
  27. package/src/components/Box/Box.module.css +46 -0
  28. package/src/components/Box/Box.spec.tsx +188 -0
  29. package/src/components/Box/Box.tsx +242 -0
  30. package/src/components/Button/Button.module.css +261 -0
  31. package/src/components/Button/Button.spec.tsx +82 -0
  32. package/src/components/Button/Button.tsx +99 -0
  33. package/src/components/Button/ButtonTypes.ts +107 -0
  34. package/src/components/Button/LinkButton.spec.tsx +86 -0
  35. package/src/components/Button/LinkButton.tsx +80 -0
  36. package/src/components/Button/VariantIcon.tsx +20 -0
  37. package/src/components/Button/useIcon.tsx +16 -0
  38. package/src/components/ButtonCard/ButtonCard.module.css +35 -0
  39. package/src/components/ButtonCard/ButtonCard.spec.tsx +18 -0
  40. package/src/components/ButtonCard/ButtonCard.stories.tsx +54 -0
  41. package/src/components/ButtonCard/ButtonCard.tsx +18 -0
  42. package/src/components/Center/Center.module.css +19 -0
  43. package/src/components/Center/Center.spec.tsx +143 -0
  44. package/src/components/Center/Center.tsx +108 -0
  45. package/src/components/Checkbox/Checkbox.module.css +124 -0
  46. package/src/components/Checkbox/Checkbox.spec.tsx +17 -0
  47. package/src/components/Checkbox/Checkbox.stories.tsx +213 -0
  48. package/src/components/Checkbox/Checkbox.tsx +50 -0
  49. package/src/components/CheckboxCard/CheckboxCard.module.css +102 -0
  50. package/src/components/CheckboxCard/CheckboxCard.spec.tsx +16 -0
  51. package/src/components/CheckboxCard/CheckboxCard.stories.tsx +205 -0
  52. package/src/components/CheckboxCard/CheckboxCard.tsx +53 -0
  53. package/src/components/CheckboxGroup/CheckboxGroup.module.css +16 -0
  54. package/src/components/CheckboxGroup/CheckboxGroup.spec.tsx +17 -0
  55. package/src/components/CheckboxGroup/CheckboxGroup.tsx +64 -0
  56. package/src/components/Color/Color.module.css +3 -0
  57. package/src/components/Color/Color.spec.tsx +24 -0
  58. package/src/components/Color/Color.stories.tsx +71 -0
  59. package/src/components/Color/Color.tsx +28 -0
  60. package/src/components/Divider/Divider.module.css +9 -0
  61. package/src/components/Divider/Divider.spec.tsx +42 -0
  62. package/src/components/Divider/Divider.stories.tsx +77 -0
  63. package/src/components/Divider/Divider.tsx +49 -0
  64. package/src/components/ErrorMessage/ErrorMessage.module.css +8 -0
  65. package/src/components/ErrorMessage/ErrorMessage.spec.tsx +12 -0
  66. package/src/components/ErrorMessage/ErrorMessage.tsx +20 -0
  67. package/src/components/Flex/Flex.module.css +24 -0
  68. package/src/components/Flex/Flex.spec.tsx +188 -0
  69. package/src/components/Flex/Flex.tsx +173 -0
  70. package/src/components/FlexItem/FlexItem.module.css +14 -0
  71. package/src/components/FlexItem/FlexItem.spec.tsx +84 -0
  72. package/src/components/FlexItem/FlexItem.tsx +106 -0
  73. package/src/components/Heading/Heading.module.css +131 -0
  74. package/src/components/Heading/Heading.tsx +86 -0
  75. package/src/components/HelperMessage/HelperMessage.module.css +8 -0
  76. package/src/components/HelperMessage/HelperMessage.tsx +15 -0
  77. package/src/components/Icon/Icon.module.css +6 -0
  78. package/src/components/Icon/Icon.spec.tsx +24 -0
  79. package/src/components/Icon/Icon.stories.tsx +100 -0
  80. package/src/components/Icon/Icon.tsx +101 -0
  81. package/src/components/Input/Input.module.css +51 -0
  82. package/src/components/Input/Input.spec.tsx +14 -0
  83. package/src/components/Input/Input.tsx +27 -0
  84. package/src/components/Label/Label.module.css +14 -0
  85. package/src/components/Label/Label.tsx +39 -0
  86. package/src/components/LinkCard/LinkCard.module.css +72 -0
  87. package/src/components/LinkCard/LinkCard.tsx +96 -0
  88. package/src/components/MessageHalfModal/MessageHalfModal.module.css +181 -0
  89. package/src/components/MessageHalfModal/MessageHalfModal.spec.tsx +73 -0
  90. package/src/components/MessageHalfModal/MessageHalfModal.stories.tsx +242 -0
  91. package/src/components/MessageHalfModal/MessageHalfModal.tsx +194 -0
  92. package/src/components/MessageModal/MessageModal.module.css +149 -0
  93. package/src/components/MessageModal/MessageModal.spec.tsx +57 -0
  94. package/src/components/MessageModal/MessageModal.stories.tsx +223 -0
  95. package/src/components/MessageModal/MessageModal.tsx +178 -0
  96. package/src/components/Pre/Pre.module.css +8 -0
  97. package/src/components/Pre/Pre.spec.tsx +11 -0
  98. package/src/components/Pre/Pre.stories.tsx +76 -0
  99. package/src/components/Pre/Pre.tsx +40 -0
  100. package/src/components/RadioButton/RadioButton.module.css +92 -0
  101. package/src/components/RadioButton/RadioButton.spec.tsx +25 -0
  102. package/src/components/RadioButton/RadioButton.tsx +55 -0
  103. package/src/components/RadioCard/RadioCard.module.css +109 -0
  104. package/src/components/RadioCard/RadioCard.tsx +61 -0
  105. package/src/components/RadioGroup/RadioGroup.module.css +16 -0
  106. package/src/components/RadioGroup/RadioGroup.spec.tsx +17 -0
  107. package/src/components/RadioGroup/RadioGroup.tsx +60 -0
  108. package/src/components/Select/Select.module.css +70 -0
  109. package/src/components/Select/Select.spec.tsx +12 -0
  110. package/src/components/Select/Select.tsx +56 -0
  111. package/src/components/Stack/Stack.module.css +10 -0
  112. package/src/components/Stack/Stack.spec.tsx +177 -0
  113. package/src/components/Stack/Stack.tsx +151 -0
  114. package/src/components/Stepper/Stepper.module.css +137 -0
  115. package/src/components/Stepper/Stepper.spec.tsx +198 -0
  116. package/src/components/Stepper/Stepper.stories.tsx +192 -0
  117. package/src/components/Stepper/Stepper.tsx +70 -0
  118. package/src/components/Stepper/StepperItem.tsx +113 -0
  119. package/src/components/Text/Text.module.css +168 -0
  120. package/src/components/Text/Text.tsx +192 -0
  121. package/src/components/TextArea/TextArea.module.css +46 -0
  122. package/src/components/TextArea/TextArea.spec.tsx +13 -0
  123. package/src/components/TextArea/TextArea.tsx +29 -0
  124. package/src/components/Toggle/Toggle.module.css +71 -0
  125. package/src/components/Toggle/Toggle.spec.tsx +21 -0
  126. package/src/components/Toggle/Toggle.tsx +56 -0
  127. package/src/font.ts +2 -0
  128. package/src/hooks/useScrollable.ts +58 -0
  129. package/src/icons/AppleIcon.tsx +14 -0
  130. package/src/icons/GoogleIcon.tsx +27 -0
  131. package/src/icons/LINEIcon.tsx +16 -0
  132. package/src/index.ts +35 -0
  133. package/src/sharedComponents/RequiredLabel/RequiredLabel.module.css +10 -0
  134. package/src/sharedComponents/RequiredLabel/RequiredLabel.tsx +8 -0
  135. package/src/sharedComponents/VisuallyHidden/VisuallyHidden.module.css +15 -0
  136. package/src/sharedComponents/VisuallyHidden/VisuallyHidden.tsx +22 -0
  137. package/src/stories/Accordion.stories.portable.ts +4 -0
  138. package/src/stories/Box.stories.tsx +474 -0
  139. package/src/stories/Button.stories.tsx +262 -0
  140. package/src/stories/Center.stories.tsx +126 -0
  141. package/src/stories/ErrorMessage.stories.tsx +19 -0
  142. package/src/stories/Flex.stories.tsx +345 -0
  143. package/src/stories/Form.stories.tsx +83 -0
  144. package/src/stories/Heading.stories.tsx +263 -0
  145. package/src/stories/HelperMessage.stories.tsx +22 -0
  146. package/src/stories/Input.stories.tsx +145 -0
  147. package/src/stories/Label.stories.tsx +32 -0
  148. package/src/stories/LinkButton.stories.tsx +207 -0
  149. package/src/stories/LinkCard.stories.tsx +90 -0
  150. package/src/stories/RadioButton.stories.tsx +168 -0
  151. package/src/stories/RadioCard.stories.tsx +236 -0
  152. package/src/stories/Select.stories.tsx +97 -0
  153. package/src/stories/Stack.stories.tsx +167 -0
  154. package/src/stories/Text.stories.tsx +396 -0
  155. package/src/stories/TextArea.stories.tsx +49 -0
  156. package/src/stories/Toggle.stories.tsx +30 -0
  157. package/src/test/vitest-jest-dom.d.ts +12 -0
  158. package/src/types/attributes.ts +6 -0
  159. package/src/types/global.d.ts +11 -0
  160. package/src/types/icon.ts +3 -0
  161. package/src/types/style.ts +254 -0
  162. package/src/utils/component.ts +8 -0
  163. package/src/utils/style.spec.ts +57 -0
  164. package/src/utils/style.ts +387 -0
  165. package/src/utils/types.ts +8 -0
  166. package/tsconfig.json +18 -0
  167. package/tsconfig.spec-lint.tsbuildinfo +1 -0
  168. package/tsconfig.tsbuildinfo +1 -0
  169. package/vite.config.ts +50 -0
  170. package/vitest.shims.d.ts +1 -0
@@ -0,0 +1,188 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import { Box } from "./Box";
3
+
4
+ describe("<Box>", () => {
5
+ it("has all the margins through m prop", () => {
6
+ render(
7
+ <Box m="xxs" data-testid="box">
8
+ Test
9
+ </Box>,
10
+ );
11
+ const div = screen.getByTestId("box");
12
+
13
+ expect(div).toHaveStyle("--margin-top: var(--size-spacing-xxs)");
14
+ expect(div).toHaveStyle("--margin-right: var(--size-spacing-xxs)");
15
+ expect(div).toHaveStyle("--margin-bottom: var(--size-spacing-xxs)");
16
+ expect(div).toHaveStyle("--margin-left: var(--size-spacing-xxs)");
17
+ });
18
+
19
+ it("has a horizontal margins through mx prop", () => {
20
+ render(
21
+ <Box mx="xxs" data-testid="box">
22
+ Test
23
+ </Box>,
24
+ );
25
+ const div = screen.getByTestId("box");
26
+
27
+ expect(div).toHaveStyle("--margin-top: 0");
28
+ expect(div).toHaveStyle("--margin-right: var(--size-spacing-xxs)");
29
+ expect(div).toHaveStyle("--margin-bottom: 0");
30
+ expect(div).toHaveStyle("--margin-left: var(--size-spacing-xxs)");
31
+ });
32
+
33
+ it("has a vertical margins of through my prop", () => {
34
+ render(
35
+ <Box my="xxs" data-testid="box">
36
+ Test
37
+ </Box>,
38
+ );
39
+ const div = screen.getByTestId("box");
40
+
41
+ expect(div).toHaveStyle("--margin-top: var(--size-spacing-xxs)");
42
+ expect(div).toHaveStyle("--margin-right: 0");
43
+ expect(div).toHaveStyle("--margin-bottom: var(--size-spacing-xxs)");
44
+ expect(div).toHaveStyle("--margin-left: 0");
45
+ });
46
+
47
+ it("has all margins through individual margin props", () => {
48
+ render(
49
+ <Box mt="xxs" mr="xs" mb="sm" ml="md" data-testid="box">
50
+ Test
51
+ </Box>,
52
+ );
53
+ const div = screen.getByTestId("box");
54
+
55
+ expect(div).toHaveStyle("--margin-top: var(--size-spacing-xxs)");
56
+ expect(div).toHaveStyle("--margin-right: var(--size-spacing-xs)");
57
+ expect(div).toHaveStyle("--margin-bottom: var(--size-spacing-sm)");
58
+ expect(div).toHaveStyle("--margin-left: var(--size-spacing-md)");
59
+ });
60
+
61
+ it("gives priority to individual margin props", () => {
62
+ render(
63
+ <Box m="xxs" mx="xs" my="xs" mt="sm" mr="md" mb="lg" ml="xl" data-testid="box">
64
+ Test
65
+ </Box>,
66
+ );
67
+ const div = screen.getByTestId("box");
68
+
69
+ expect(div).toHaveStyle("--margin-top: var(--size-spacing-sm)");
70
+ expect(div).toHaveStyle("--margin-right: var(--size-spacing-md)");
71
+ expect(div).toHaveStyle("--margin-bottom: var(--size-spacing-lg)");
72
+ expect(div).toHaveStyle("--margin-left: var(--size-spacing-xl)");
73
+ });
74
+
75
+ it("has all the paddings through p prop", () => {
76
+ render(
77
+ <Box p="xxs" data-testid="box">
78
+ Test
79
+ </Box>,
80
+ );
81
+ const div = screen.getByTestId("box");
82
+
83
+ expect(div).toHaveStyle("--padding-top: var(--size-spacing-xxs)");
84
+ expect(div).toHaveStyle("--padding-right: var(--size-spacing-xxs)");
85
+ expect(div).toHaveStyle("--padding-bottom: var(--size-spacing-xxs)");
86
+ expect(div).toHaveStyle("--padding-left: var(--size-spacing-xxs)");
87
+ });
88
+
89
+ it("has a horizontal paddings through px prop", () => {
90
+ render(
91
+ <Box px="xxs" data-testid="box">
92
+ Test
93
+ </Box>,
94
+ );
95
+ const div = screen.getByTestId("box");
96
+
97
+ expect(div).toHaveStyle("--padding-top: 0");
98
+ expect(div).toHaveStyle("--padding-right: var(--size-spacing-xxs)");
99
+ expect(div).toHaveStyle("--padding-bottom: 0");
100
+ expect(div).toHaveStyle("--padding-left: var(--size-spacing-xxs)");
101
+ });
102
+
103
+ it("has a vertical paddings of through px prop", () => {
104
+ render(
105
+ <Box py="xxs" data-testid="box">
106
+ Test
107
+ </Box>,
108
+ );
109
+ const div = screen.getByTestId("box");
110
+
111
+ expect(div).toHaveStyle("--padding-top: var(--size-spacing-xxs)");
112
+ expect(div).toHaveStyle("--padding-right: 0");
113
+ expect(div).toHaveStyle("--padding-bottom: var(--size-spacing-xxs)");
114
+ expect(div).toHaveStyle("--padding-left: 0");
115
+ });
116
+
117
+ it("has all paddings through individual padding props", () => {
118
+ render(
119
+ <Box pt="xxs" pr="xs" pb="sm" pl="md" data-testid="box">
120
+ Test
121
+ </Box>,
122
+ );
123
+ const div = screen.getByTestId("box");
124
+
125
+ expect(div).toHaveStyle("--padding-top: var(--size-spacing-xxs)");
126
+ expect(div).toHaveStyle("--padding-right: var(--size-spacing-xs)");
127
+ expect(div).toHaveStyle("--padding-bottom: var(--size-spacing-sm)");
128
+ expect(div).toHaveStyle("--padding-left: var(--size-spacing-md)");
129
+ });
130
+
131
+ it("gives priority to individual padding props", () => {
132
+ render(
133
+ <Box p="xxs" px="xs" py="xs" pt="sm" pr="md" pb="lg" pl="xl" data-testid="box">
134
+ Test
135
+ </Box>,
136
+ );
137
+ const div = screen.getByTestId("box");
138
+
139
+ expect(div).toHaveStyle("--padding-top: var(--size-spacing-sm)");
140
+ expect(div).toHaveStyle("--padding-right: var(--size-spacing-md)");
141
+ expect(div).toHaveStyle("--padding-bottom: var(--size-spacing-lg)");
142
+ expect(div).toHaveStyle("--padding-left: var(--size-spacing-xl)");
143
+ });
144
+
145
+ it("receives width", () => {
146
+ render(
147
+ <Box width="100px" data-testid="flex-item">
148
+ Test
149
+ </Box>,
150
+ );
151
+ const div = screen.getByTestId("flex-item");
152
+
153
+ expect(div).toHaveStyle("--width: 100px");
154
+ });
155
+
156
+ it("converted to 100% if full is received in width prop", () => {
157
+ render(
158
+ <Box width="full" data-testid="flex-item">
159
+ Test
160
+ </Box>,
161
+ );
162
+ const div = screen.getByTestId("flex-item");
163
+
164
+ expect(div).toHaveStyle("--width: 100%");
165
+ });
166
+
167
+ it("receives max-width", () => {
168
+ render(
169
+ <Box maxWidth="100px" data-testid="flex-item">
170
+ Test
171
+ </Box>,
172
+ );
173
+ const div = screen.getByTestId("flex-item");
174
+
175
+ expect(div).toHaveStyle("--max-width: 100px");
176
+ });
177
+
178
+ it("receives min-width", () => {
179
+ render(
180
+ <Box minWidth="100px" data-testid="flex-item">
181
+ Test
182
+ </Box>,
183
+ );
184
+ const div = screen.getByTestId("flex-item");
185
+
186
+ expect(div).toHaveStyle("--min-width: 100px");
187
+ });
188
+ });
@@ -0,0 +1,242 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import styles from "./Box.module.css";
5
+ import {
6
+ backgroundColorVariable,
7
+ borderVariables,
8
+ colorVariable,
9
+ cssFontSizeToken,
10
+ cssLeadingToken,
11
+ marginVariables,
12
+ paddingVariables,
13
+ radiusVariables,
14
+ widthVariables,
15
+ } from "../../utils/style";
16
+ import { HTMLTagname } from "../../utils/types";
17
+ import type { CustomDataAttributeProps } from "../../types/attributes";
18
+ import type {
19
+ BackgroundColorVariant,
20
+ BodyFontSize,
21
+ BodyLeading,
22
+ BorderVariant,
23
+ MarginProps,
24
+ PaddingProps,
25
+ RadiusProp,
26
+ TextColorVariant,
27
+ TextType,
28
+ WidthProps,
29
+ } from "../../types/style";
30
+ import type { CSSProperties, FC, ReactNode } from "react";
31
+
32
+ type Width = WidthProps["width"];
33
+
34
+ type BaseProps = {
35
+ /**
36
+ * Box内に表示するコンテンツやコンポーネント
37
+ */
38
+ children?: ReactNode;
39
+ /**
40
+ * レンダリングされるHTML要素
41
+ * @default div
42
+ */
43
+ as?: HTMLTagname;
44
+ /**
45
+ * 背景色
46
+ */
47
+ backgroundColor?: BackgroundColorVariant;
48
+ /**
49
+ * ボーダーの種類
50
+ */
51
+ border?: BorderVariant;
52
+ /**
53
+ * 幅を指定。fullは後方互換のため残している
54
+ * @default 'auto'
55
+ */
56
+ width?: "full" | Width;
57
+ /**
58
+ * 内包するテキストをボールドとするかどうか。指定しない場合は親要素のスタイルを継承、trueでボールド、falseとするとnormal
59
+ */
60
+ textBold?: boolean;
61
+ /**
62
+ * 文字色の抽象値
63
+ */
64
+ textColor?: TextColorVariant;
65
+ /**
66
+ * テキストの配置。指定しない場合、親要素の配置を継承
67
+ */
68
+ textAlign?: "left" | "center" | "right";
69
+ /**
70
+ * 領域が狭い場合でも、テキストを折り返えさない
71
+ */
72
+ textNoWrap?: boolean;
73
+ /**
74
+ * inline-blockとして扱う
75
+ */
76
+ inline?: boolean;
77
+ } & PaddingProps &
78
+ MarginProps &
79
+ RadiusProp &
80
+ Omit<WidthProps, "width"> &
81
+ CustomDataAttributeProps;
82
+
83
+ type PropsWithoutText = BaseProps & {
84
+ /**
85
+ * 配下に含むテキストの種類
86
+ */
87
+ textType?: undefined;
88
+ /**
89
+ * 配下に含むテキストのフォントサイズの抽象値。合わせてtextTypeの指定が必須で、typeに応じた値が指定可能
90
+ */
91
+ textSize?: never;
92
+ /**
93
+ * 配下に含むテキストの行送りの抽象値(`line-height`)。合わせてtextTypeとtextSizeの指定が必須で、typeに応じた値が指定可能
94
+ */
95
+ textLeading?: never;
96
+ };
97
+
98
+ type PropsWithTextBody = BaseProps & {
99
+ /**
100
+ * 配下に含むテキストの種類
101
+ */
102
+ textType: Extract<TextType, "body">;
103
+ /**
104
+ * 配下に含むテキストのフォントサイズの抽象値。合わせてtextTypeの指定が必須で、typeに応じた値が指定可能
105
+ */
106
+ textSize?: BodyFontSize;
107
+ /**
108
+ * 配下に含むテキストの行送りの抽象値(`line-height`)。合わせてtextTypeとtextSizeの指定が必須で、typeに応じた値が指定可能
109
+ */
110
+ textLeading?: BodyLeading;
111
+ };
112
+
113
+ /**
114
+ * If type is not specified, an empty object is returned because it is unknown how it is to be styled, i.e. it is not styled.
115
+ * If type is specified but size or leading is not, specify default values (md or default.)
116
+ */
117
+ export const textStyleVariables = ({
118
+ type,
119
+ size: _size,
120
+ leading: _leading,
121
+ }:
122
+ | {
123
+ type: undefined;
124
+ size: never;
125
+ leading: never;
126
+ }
127
+ | {
128
+ type: Extract<TextType, "body">;
129
+ size: BodyFontSize | undefined;
130
+ leading: BodyLeading | undefined;
131
+ }): CSSProperties => {
132
+ if (type == null) return {};
133
+
134
+ const size = _size == null ? "md" : _size;
135
+ const leading = _leading == null ? "default" : _leading;
136
+
137
+ switch (type) {
138
+ case "body":
139
+ return {
140
+ "--text-size": size ? cssFontSizeToken({ type, size }) : "inherit",
141
+ "--text-leading": leading
142
+ ? cssLeadingToken({ type, size: size || "md", leading })
143
+ : "inherit",
144
+ } as CSSProperties;
145
+ default:
146
+ // eslint-disable-next-line no-case-declarations
147
+ const _: never = type;
148
+ }
149
+
150
+ return {};
151
+ };
152
+
153
+ const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
154
+
155
+ export const Box: FC<PropsWithoutText | PropsWithTextBody> = ({
156
+ as: BoxComponent = "div",
157
+ children,
158
+ p,
159
+ px,
160
+ py,
161
+ pt,
162
+ pr,
163
+ pb,
164
+ pl,
165
+ m,
166
+ mx,
167
+ my,
168
+ mt,
169
+ mr,
170
+ mb,
171
+ ml,
172
+ radius,
173
+ backgroundColor,
174
+ border,
175
+ width: _width,
176
+ minWidth,
177
+ maxWidth,
178
+ inline = false,
179
+ textType,
180
+ textSize,
181
+ textLeading,
182
+ textColor,
183
+ textBold,
184
+ textAlign,
185
+ textNoWrap,
186
+ ...props
187
+ }) => {
188
+ let _textVariables: CSSProperties = {};
189
+
190
+ if (textType === "body") {
191
+ _textVariables = textStyleVariables({ type: textType, size: textSize, leading: textLeading });
192
+ }
193
+
194
+ const width = _width === "full" ? "100%" : _width;
195
+
196
+ return (
197
+ <BoxComponent
198
+ className={clsx([
199
+ styles.box,
200
+ width && styles.widthFull,
201
+ inline && styles.inline,
202
+ textBold && styles.textBold,
203
+ textBold === false && styles.textNormal,
204
+ textAlign && styles[`text${capitalize(textAlign)}`],
205
+ textNoWrap && styles.textNoWrap,
206
+ ])}
207
+ style={{
208
+ ...paddingVariables({
209
+ p,
210
+ px,
211
+ py,
212
+ pt,
213
+ pr,
214
+ pb,
215
+ pl,
216
+ }),
217
+ ...marginVariables({
218
+ m,
219
+ mx,
220
+ my,
221
+ mt,
222
+ mr,
223
+ mb,
224
+ ml,
225
+ }),
226
+ ...radiusVariables(radius),
227
+ ..._textVariables,
228
+ ...colorVariable(textColor),
229
+ ...borderVariables(border),
230
+ ...backgroundColorVariable(backgroundColor),
231
+ ...widthVariables({
232
+ width,
233
+ minWidth,
234
+ maxWidth,
235
+ }),
236
+ }}
237
+ {...props}
238
+ >
239
+ {children}
240
+ </BoxComponent>
241
+ );
242
+ };
@@ -0,0 +1,261 @@
1
+ .button {
2
+ --border-width: 1px;
3
+
4
+ position: relative;
5
+ box-sizing: border-box;
6
+ display: inline-grid;
7
+ grid-template-columns: 1fr auto 1fr;
8
+ align-items: center;
9
+ justify-content: center;
10
+ width: auto;
11
+ min-width: var(--min-width);
12
+ min-height: var(--height);
13
+ padding: var(--padding-y) var(--padding-x);
14
+ margin: var(--margin-top) var(--margin-right) var(--margin-bottom) var(--margin-left);
15
+ font-size: var(--font-size);
16
+ font-weight: bold;
17
+ hyphens: auto;
18
+ line-height: var(--line-height);
19
+ color: var(--text);
20
+ text-align: center;
21
+ text-decoration: none;
22
+ overflow-wrap: anywhere;
23
+ white-space: var(--white-space, "normal");
24
+ appearance: none;
25
+ cursor: pointer;
26
+ background-color: var(--bg);
27
+ border-color: var(--border-color);
28
+ border-style: solid;
29
+ border-width: var(--border-width);
30
+ border-radius: var(--height);
31
+ transition: 0.3s cubic-bezier(0.22, 1, 0.36, 1);
32
+ }
33
+
34
+ .button:focus-visible {
35
+ outline: solid var(--focus-ring, var(--color-ubie-blue-500)) 2px;
36
+ }
37
+
38
+ .button.loading {
39
+ cursor: wait;
40
+ }
41
+
42
+ @media (hover: hover) {
43
+ .button:hover:not(.loading) {
44
+ color: var(--text-hover);
45
+ cursor: pointer;
46
+ background-color: var(--bg-hover);
47
+ border-color: var(--border-color-hover);
48
+ }
49
+ }
50
+
51
+ .label {
52
+ display: inline-flex;
53
+ grid-column: 2;
54
+ align-items: center;
55
+ justify-content: center;
56
+ }
57
+
58
+ .disabled {
59
+ padding: calc(var(--padding-y) + var(--border-width)) calc(var(--padding-x) + var(--border-width));
60
+ color: var(--text-disabled);
61
+ pointer-events: none;
62
+ cursor: not-allowed;
63
+ background-color: var(--bg-disabled);
64
+ border-color: var(--border-color-disabled);
65
+ border-width: 0;
66
+ }
67
+
68
+ .loadingLabel {
69
+ position: absolute;
70
+ inset: 0;
71
+ display: flex;
72
+ align-items: center;
73
+ justify-content: center;
74
+ }
75
+
76
+ .children.loading {
77
+ opacity: 0;
78
+ }
79
+
80
+ /* Variant */
81
+
82
+ .primary {
83
+ --text: var(--color-ubie-white);
84
+ --text-hover: var(--color-ubie-white);
85
+ --text-disabled: var(--color-placeholder);
86
+ --bg: var(--color-primary);
87
+ --bg-hover: var(--color-ubie-blue-800);
88
+ --bg-disabled: var(--color-outline-variant);
89
+ --border-color: var(--color-primary);
90
+ --border-color-hover: var(--color-ubie-blue-800);
91
+ --border-color-disabled: var(--color-outline-variant);
92
+ --focus-ring: var(--color-ubie-pink-500);
93
+ }
94
+
95
+ .secondary {
96
+ --text: var(--color-on-surface);
97
+ --text-hover: var(--color-on-surface);
98
+ --text-disabled: var(--color-placeholder);
99
+ --bg: var(--color-surface-container);
100
+ --bg-hover: var(--color-outline-variant);
101
+ --bg-disabled: var(--color-outline-variant);
102
+ --border-color: var(--color-outline);
103
+ --border-color-hover: var(--color-outline);
104
+ --border-color-disabled: var(--color-outline-variant);
105
+ }
106
+
107
+ .alert {
108
+ --text: var(--color-ubie-white);
109
+ --text-hover: var(--color-ubie-white);
110
+ --text-disabled: var(--color-placeholder);
111
+ --bg: var(--color-error);
112
+ --bg-hover: var(--color-ubie-red-800);
113
+ --bg-disabled: var(--color-outline-variant);
114
+ --border-color: var(--color-error);
115
+ --border-color-hover: var(--color-ubie-red-800);
116
+ --border-color-disabled: var(--color-outline-variant);
117
+ }
118
+
119
+ .text {
120
+ --text: var(--color-ubie-blue-600);
121
+ --text-hover: var(--color-ubie-blue-700);
122
+ --text-disabled: var(--color-placeholder);
123
+ --bg: transparent;
124
+ --bg-hover: var(--color-ubie-blue-100);
125
+ --bg-disabled: transparent;
126
+ --border-color: transparent;
127
+ --border-color-hover: var(--color-ubie-blue-100);
128
+ --border-color-disabled: var(--color-outline-variant);
129
+ }
130
+
131
+ .textAlert {
132
+ --text: var(--color-ubie-red-800);
133
+ --text-hover: var(--color-ubie-red-700);
134
+ --text-disabled: var(--color-placeholder);
135
+ --bg: transparent;
136
+ --bg-hover: var(--color-error-container);
137
+ --bg-disabled: transparent;
138
+ --border-color: transparent;
139
+ --border-color-hover: var(--color-error-container);
140
+ --border-color-disabled: var(--color-outline-variant);
141
+ }
142
+
143
+ .authGoogle {
144
+ --text: var(--color-on-surface);
145
+ --text-hover: var(--color-on-surface);
146
+ --text-disabled: var(--color-on-surface);
147
+ --bg: #fff;
148
+ --bg-hover: #fff;
149
+ --bg-disabled: #e2e2e2;
150
+ --border-color: #9ca0a8;
151
+ --border-color-hover: #9ca0a8;
152
+ --border-color-disabled: #9ca0a8;
153
+ }
154
+
155
+ .authLINE {
156
+ --text: #fff;
157
+ --text-hover: #fff;
158
+ --text-disabled: #fff;
159
+ --bg: #06c755;
160
+ --bg-hover: #06c755;
161
+ --bg-disabled: #06c755;
162
+ --border-color: #06c755;
163
+ --border-color-hover: #06c755;
164
+ --border-color-disabled: #06c755;
165
+ }
166
+
167
+ .authApple {
168
+ --text: #fff;
169
+ --text-hover: #fff;
170
+ --text-disabled: #fff;
171
+ --bg: #000;
172
+ --bg-hover: #000;
173
+ --bg-disabled: #000;
174
+ --border-color: #000;
175
+ --border-color-hover: #000;
176
+ --border-color-disabled: #000;
177
+ }
178
+
179
+ /* Size */
180
+
181
+ .large {
182
+ --min-width: 112px;
183
+ --height: 56px;
184
+ --padding-x: 22px;
185
+ --padding-y: 8px;
186
+ --font-size: var(--text-button-lg-size);
187
+ --line-height: var(--text-button-lg-line);
188
+ --icon-size: 24px;
189
+ --icon-gap: 8px;
190
+ }
191
+
192
+ .medium {
193
+ --min-width: 80px;
194
+ --height: 36px;
195
+ --padding-x: 10px;
196
+ --padding-y: 8px;
197
+ --font-size: var(--text-button-md-size);
198
+ --line-height: var(--text-button-md-line);
199
+ --icon-size: 20px;
200
+ --icon-gap: 6px;
201
+ }
202
+
203
+ .small {
204
+ --min-width: 60px;
205
+ --height: 24px;
206
+ --padding-x: 6px;
207
+ --padding-y: 3px;
208
+ --font-size: var(--text-button-sm-size);
209
+ --line-height: var(--text-button-sm-line);
210
+ --icon-size: 16px;
211
+ --icon-gap: 4px;
212
+ }
213
+
214
+ /* Block */
215
+
216
+ .block {
217
+ width: 100%;
218
+ }
219
+
220
+ /* Icon */
221
+
222
+ .icon {
223
+ display: flex;
224
+ margin-right: var(--icon-gap);
225
+ vertical-align: middle;
226
+ }
227
+
228
+ .icon.loading {
229
+ opacity: 0;
230
+ }
231
+
232
+ .icon > * {
233
+ width: var(--icon-size);
234
+ height: var(--icon-size);
235
+ }
236
+
237
+ .fixedIcon {
238
+ display: flex;
239
+ margin: 0 10%;
240
+ vertical-align: middle;
241
+ }
242
+
243
+ .fixedIcon > * {
244
+ width: var(--icon-size);
245
+ height: var(--icon-size);
246
+ }
247
+
248
+ .suffixIcon {
249
+ display: flex;
250
+ margin-left: var(--icon-gap);
251
+ vertical-align: middle;
252
+ }
253
+
254
+ .suffixIcon.loading {
255
+ opacity: 0;
256
+ }
257
+
258
+ .suffixIcon > * {
259
+ width: var(--icon-size);
260
+ height: var(--icon-size);
261
+ }