@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.
- package/.storybook/main.ts +14 -0
- package/.storybook/preview.tsx +25 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/dist/chunk-DKo7XVKm.mjs +33 -0
- package/dist/index.d.mts +1720 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +10594 -0
- package/dist/index.mjs.map +1 -0
- package/dist/style.css +2299 -0
- package/package.json +47 -0
- package/src/components/Accordion/Accordion.module.css +75 -0
- package/src/components/Accordion/Accordion.spec.tsx +18 -0
- package/src/components/Accordion/Accordion.stories.tsx +61 -0
- package/src/components/Accordion/Accordion.tsx +89 -0
- package/src/components/ActionHalfModal/ActionHalfModal.module.css +180 -0
- package/src/components/ActionHalfModal/ActionHalfModal.spec.tsx +57 -0
- package/src/components/ActionHalfModal/ActionHalfModal.stories.tsx +469 -0
- package/src/components/ActionHalfModal/ActionHalfModal.tsx +269 -0
- package/src/components/ActionModal/ActionModal.module.css +145 -0
- package/src/components/ActionModal/ActionModal.spec.tsx +57 -0
- package/src/components/ActionModal/ActionModal.stories.tsx +302 -0
- package/src/components/ActionModal/ActionModal.tsx +232 -0
- package/src/components/Bold/Bold.module.css +4 -0
- package/src/components/Bold/Bold.spec.tsx +24 -0
- package/src/components/Bold/Bold.stories.tsx +54 -0
- package/src/components/Bold/Bold.tsx +31 -0
- package/src/components/Box/Box.module.css +46 -0
- package/src/components/Box/Box.spec.tsx +188 -0
- package/src/components/Box/Box.tsx +242 -0
- package/src/components/Button/Button.module.css +261 -0
- package/src/components/Button/Button.spec.tsx +82 -0
- package/src/components/Button/Button.tsx +99 -0
- package/src/components/Button/ButtonTypes.ts +107 -0
- package/src/components/Button/LinkButton.spec.tsx +86 -0
- package/src/components/Button/LinkButton.tsx +80 -0
- package/src/components/Button/VariantIcon.tsx +20 -0
- package/src/components/Button/useIcon.tsx +16 -0
- package/src/components/ButtonCard/ButtonCard.module.css +35 -0
- package/src/components/ButtonCard/ButtonCard.spec.tsx +18 -0
- package/src/components/ButtonCard/ButtonCard.stories.tsx +54 -0
- package/src/components/ButtonCard/ButtonCard.tsx +18 -0
- package/src/components/Center/Center.module.css +19 -0
- package/src/components/Center/Center.spec.tsx +143 -0
- package/src/components/Center/Center.tsx +108 -0
- package/src/components/Checkbox/Checkbox.module.css +124 -0
- package/src/components/Checkbox/Checkbox.spec.tsx +17 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +213 -0
- package/src/components/Checkbox/Checkbox.tsx +50 -0
- package/src/components/CheckboxCard/CheckboxCard.module.css +102 -0
- package/src/components/CheckboxCard/CheckboxCard.spec.tsx +16 -0
- package/src/components/CheckboxCard/CheckboxCard.stories.tsx +205 -0
- package/src/components/CheckboxCard/CheckboxCard.tsx +53 -0
- package/src/components/CheckboxGroup/CheckboxGroup.module.css +16 -0
- package/src/components/CheckboxGroup/CheckboxGroup.spec.tsx +17 -0
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +64 -0
- package/src/components/Color/Color.module.css +3 -0
- package/src/components/Color/Color.spec.tsx +24 -0
- package/src/components/Color/Color.stories.tsx +71 -0
- package/src/components/Color/Color.tsx +28 -0
- package/src/components/Divider/Divider.module.css +9 -0
- package/src/components/Divider/Divider.spec.tsx +42 -0
- package/src/components/Divider/Divider.stories.tsx +77 -0
- package/src/components/Divider/Divider.tsx +49 -0
- package/src/components/ErrorMessage/ErrorMessage.module.css +8 -0
- package/src/components/ErrorMessage/ErrorMessage.spec.tsx +12 -0
- package/src/components/ErrorMessage/ErrorMessage.tsx +20 -0
- package/src/components/Flex/Flex.module.css +24 -0
- package/src/components/Flex/Flex.spec.tsx +188 -0
- package/src/components/Flex/Flex.tsx +173 -0
- package/src/components/FlexItem/FlexItem.module.css +14 -0
- package/src/components/FlexItem/FlexItem.spec.tsx +84 -0
- package/src/components/FlexItem/FlexItem.tsx +106 -0
- package/src/components/Heading/Heading.module.css +131 -0
- package/src/components/Heading/Heading.tsx +86 -0
- package/src/components/HelperMessage/HelperMessage.module.css +8 -0
- package/src/components/HelperMessage/HelperMessage.tsx +15 -0
- package/src/components/Icon/Icon.module.css +6 -0
- package/src/components/Icon/Icon.spec.tsx +24 -0
- package/src/components/Icon/Icon.stories.tsx +100 -0
- package/src/components/Icon/Icon.tsx +101 -0
- package/src/components/Input/Input.module.css +51 -0
- package/src/components/Input/Input.spec.tsx +14 -0
- package/src/components/Input/Input.tsx +27 -0
- package/src/components/Label/Label.module.css +14 -0
- package/src/components/Label/Label.tsx +39 -0
- package/src/components/LinkCard/LinkCard.module.css +72 -0
- package/src/components/LinkCard/LinkCard.tsx +96 -0
- package/src/components/MessageHalfModal/MessageHalfModal.module.css +181 -0
- package/src/components/MessageHalfModal/MessageHalfModal.spec.tsx +73 -0
- package/src/components/MessageHalfModal/MessageHalfModal.stories.tsx +242 -0
- package/src/components/MessageHalfModal/MessageHalfModal.tsx +194 -0
- package/src/components/MessageModal/MessageModal.module.css +149 -0
- package/src/components/MessageModal/MessageModal.spec.tsx +57 -0
- package/src/components/MessageModal/MessageModal.stories.tsx +223 -0
- package/src/components/MessageModal/MessageModal.tsx +178 -0
- package/src/components/Pre/Pre.module.css +8 -0
- package/src/components/Pre/Pre.spec.tsx +11 -0
- package/src/components/Pre/Pre.stories.tsx +76 -0
- package/src/components/Pre/Pre.tsx +40 -0
- package/src/components/RadioButton/RadioButton.module.css +92 -0
- package/src/components/RadioButton/RadioButton.spec.tsx +25 -0
- package/src/components/RadioButton/RadioButton.tsx +55 -0
- package/src/components/RadioCard/RadioCard.module.css +109 -0
- package/src/components/RadioCard/RadioCard.tsx +61 -0
- package/src/components/RadioGroup/RadioGroup.module.css +16 -0
- package/src/components/RadioGroup/RadioGroup.spec.tsx +17 -0
- package/src/components/RadioGroup/RadioGroup.tsx +60 -0
- package/src/components/Select/Select.module.css +70 -0
- package/src/components/Select/Select.spec.tsx +12 -0
- package/src/components/Select/Select.tsx +56 -0
- package/src/components/Stack/Stack.module.css +10 -0
- package/src/components/Stack/Stack.spec.tsx +177 -0
- package/src/components/Stack/Stack.tsx +151 -0
- package/src/components/Stepper/Stepper.module.css +137 -0
- package/src/components/Stepper/Stepper.spec.tsx +198 -0
- package/src/components/Stepper/Stepper.stories.tsx +192 -0
- package/src/components/Stepper/Stepper.tsx +70 -0
- package/src/components/Stepper/StepperItem.tsx +113 -0
- package/src/components/Text/Text.module.css +168 -0
- package/src/components/Text/Text.tsx +192 -0
- package/src/components/TextArea/TextArea.module.css +46 -0
- package/src/components/TextArea/TextArea.spec.tsx +13 -0
- package/src/components/TextArea/TextArea.tsx +29 -0
- package/src/components/Toggle/Toggle.module.css +71 -0
- package/src/components/Toggle/Toggle.spec.tsx +21 -0
- package/src/components/Toggle/Toggle.tsx +56 -0
- package/src/font.ts +2 -0
- package/src/hooks/useScrollable.ts +58 -0
- package/src/icons/AppleIcon.tsx +14 -0
- package/src/icons/GoogleIcon.tsx +27 -0
- package/src/icons/LINEIcon.tsx +16 -0
- package/src/index.ts +35 -0
- package/src/sharedComponents/RequiredLabel/RequiredLabel.module.css +10 -0
- package/src/sharedComponents/RequiredLabel/RequiredLabel.tsx +8 -0
- package/src/sharedComponents/VisuallyHidden/VisuallyHidden.module.css +15 -0
- package/src/sharedComponents/VisuallyHidden/VisuallyHidden.tsx +22 -0
- package/src/stories/Accordion.stories.portable.ts +4 -0
- package/src/stories/Box.stories.tsx +474 -0
- package/src/stories/Button.stories.tsx +262 -0
- package/src/stories/Center.stories.tsx +126 -0
- package/src/stories/ErrorMessage.stories.tsx +19 -0
- package/src/stories/Flex.stories.tsx +345 -0
- package/src/stories/Form.stories.tsx +83 -0
- package/src/stories/Heading.stories.tsx +263 -0
- package/src/stories/HelperMessage.stories.tsx +22 -0
- package/src/stories/Input.stories.tsx +145 -0
- package/src/stories/Label.stories.tsx +32 -0
- package/src/stories/LinkButton.stories.tsx +207 -0
- package/src/stories/LinkCard.stories.tsx +90 -0
- package/src/stories/RadioButton.stories.tsx +168 -0
- package/src/stories/RadioCard.stories.tsx +236 -0
- package/src/stories/Select.stories.tsx +97 -0
- package/src/stories/Stack.stories.tsx +167 -0
- package/src/stories/Text.stories.tsx +396 -0
- package/src/stories/TextArea.stories.tsx +49 -0
- package/src/stories/Toggle.stories.tsx +30 -0
- package/src/test/vitest-jest-dom.d.ts +12 -0
- package/src/types/attributes.ts +6 -0
- package/src/types/global.d.ts +11 -0
- package/src/types/icon.ts +3 -0
- package/src/types/style.ts +254 -0
- package/src/utils/component.ts +8 -0
- package/src/utils/style.spec.ts +57 -0
- package/src/utils/style.ts +387 -0
- package/src/utils/types.ts +8 -0
- package/tsconfig.json +18 -0
- package/tsconfig.spec-lint.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.ts +50 -0
- package/vitest.shims.d.ts +1 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
export type FontSize = "xxs" | "xs" | "sm" | "md" | "lg" | "xl";
|
|
2
|
+
|
|
3
|
+
export type TextType = "body" | "heading" | "button" | "tag";
|
|
4
|
+
|
|
5
|
+
export type Leading = "default" | "narrow" | "wide";
|
|
6
|
+
|
|
7
|
+
export type Hue = "black" | "blue" | "pink" | "orange" | "purple" | "green" | "red";
|
|
8
|
+
|
|
9
|
+
export type TextColorVariant =
|
|
10
|
+
| "main"
|
|
11
|
+
| "sub"
|
|
12
|
+
| "link"
|
|
13
|
+
| "linkSub"
|
|
14
|
+
| "disabled"
|
|
15
|
+
| "white"
|
|
16
|
+
| Hue
|
|
17
|
+
| `${Hue}Darken`;
|
|
18
|
+
|
|
19
|
+
export type TextColorTokenKey = string;
|
|
20
|
+
|
|
21
|
+
export type BodyFontSize = Extract<FontSize, "xs" | "sm" | "md" | "lg">;
|
|
22
|
+
|
|
23
|
+
export type BodyLeading = Extract<Leading, "default" | "narrow" | "wide">;
|
|
24
|
+
|
|
25
|
+
export type HeadingFontSize = Extract<FontSize, "xxs" | "xs" | "sm" | "md" | "lg" | "xl">;
|
|
26
|
+
|
|
27
|
+
export type HeadingLeading = Extract<Leading, "default" | "wide">;
|
|
28
|
+
|
|
29
|
+
export type ButtonFontSize = Extract<FontSize, "sm" | "md" | "lg">;
|
|
30
|
+
|
|
31
|
+
export type ButtonLeading = Extract<Leading, "default">;
|
|
32
|
+
|
|
33
|
+
export type TagFontSize = Extract<FontSize, "md" | "lg">;
|
|
34
|
+
|
|
35
|
+
export type TagLeading = Extract<Leading, "default">;
|
|
36
|
+
|
|
37
|
+
export type Spacing = "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
|
|
38
|
+
|
|
39
|
+
export type PaddingProps = {
|
|
40
|
+
/**
|
|
41
|
+
* 四方のパディングを一括で設定。Spacing Tokenのキーを指定
|
|
42
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
43
|
+
*/
|
|
44
|
+
p?: Spacing;
|
|
45
|
+
/**
|
|
46
|
+
* 水平方向のパディングを一括で設定。Spacing Tokenのキーを指定
|
|
47
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
48
|
+
*/
|
|
49
|
+
px?: Spacing;
|
|
50
|
+
/**
|
|
51
|
+
* 垂直方向のパディングを一括で設定。Spacing Tokenのキーを指定
|
|
52
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
53
|
+
*/
|
|
54
|
+
py?: Spacing;
|
|
55
|
+
/**
|
|
56
|
+
* 上方向のパディング。Spacing Tokenのキーを指定
|
|
57
|
+
*/
|
|
58
|
+
pt?: Spacing;
|
|
59
|
+
/**
|
|
60
|
+
* 右方向のパディング。Spacing Tokenのキーを指定
|
|
61
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
62
|
+
*/
|
|
63
|
+
pr?: Spacing;
|
|
64
|
+
/**
|
|
65
|
+
* 下方向のパディング。Spacing Tokenのキーを指定
|
|
66
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
67
|
+
*/
|
|
68
|
+
pb?: Spacing;
|
|
69
|
+
/**
|
|
70
|
+
* 左方向のパディング。Spacing Tokenのキーを指定
|
|
71
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
72
|
+
*/
|
|
73
|
+
pl?: Spacing;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type MarginProps = {
|
|
77
|
+
/**
|
|
78
|
+
* 四方のマージンを一括で設定。Spacing Tokenのキーを指定
|
|
79
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
80
|
+
*/
|
|
81
|
+
m?: Spacing;
|
|
82
|
+
/**
|
|
83
|
+
* 水平方向のマージンを一括で設定。Spacing Tokenのキーを指定
|
|
84
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
85
|
+
*/
|
|
86
|
+
mx?: Spacing;
|
|
87
|
+
/**
|
|
88
|
+
* 垂直方向のマージンを一括で設定。Spacing Tokenのキーを指定
|
|
89
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
90
|
+
*/
|
|
91
|
+
my?: Spacing;
|
|
92
|
+
/**
|
|
93
|
+
* 上方向のマージン。Spacing Tokenのキーを指定
|
|
94
|
+
*/
|
|
95
|
+
mt?: Spacing;
|
|
96
|
+
/**
|
|
97
|
+
* 右方向のマージン。Spacing Tokenのキーを指定
|
|
98
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
99
|
+
*/
|
|
100
|
+
mr?: Spacing;
|
|
101
|
+
/**
|
|
102
|
+
* 下方向のマージン。Spacing Tokenのキーを指定
|
|
103
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
104
|
+
*/
|
|
105
|
+
mb?: Spacing;
|
|
106
|
+
/**
|
|
107
|
+
* 左方向のマージン。Spacing Tokenのキーを指定
|
|
108
|
+
* xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
|
|
109
|
+
*/
|
|
110
|
+
ml?: Spacing;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type MarginYProps = Pick<MarginProps, "my" | "mt" | "mb">;
|
|
114
|
+
|
|
115
|
+
export type FlexDirection = "row" | "column";
|
|
116
|
+
|
|
117
|
+
export type AlignItems = "normal" | "flex-start" | "center" | "flex-end" | "stretch" | "baseline";
|
|
118
|
+
|
|
119
|
+
export type JustifyContent =
|
|
120
|
+
| "normal"
|
|
121
|
+
| "flex-start"
|
|
122
|
+
| "center"
|
|
123
|
+
| "flex-end"
|
|
124
|
+
| "space-between"
|
|
125
|
+
| "space-around"
|
|
126
|
+
| "space-evenly";
|
|
127
|
+
|
|
128
|
+
export type Radius = "xs" | "sm" | "md" | "lg" | "full";
|
|
129
|
+
|
|
130
|
+
export type RadiusProp = {
|
|
131
|
+
/**
|
|
132
|
+
* 角丸を指定。Radius Tokenのキーを指定
|
|
133
|
+
* xs=2px,sm=4px,md=8px,lg=12px
|
|
134
|
+
*/
|
|
135
|
+
radius?: Radius;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type BackgroundColorVariant =
|
|
139
|
+
| "white"
|
|
140
|
+
| Hue
|
|
141
|
+
| `${Hue}Darken`
|
|
142
|
+
| `${Hue}Inverse`
|
|
143
|
+
| `${Hue}InverseDarken`;
|
|
144
|
+
|
|
145
|
+
export type BackgroundColorTokenKey = string;
|
|
146
|
+
|
|
147
|
+
export type BorderColorTokenKey = string;
|
|
148
|
+
|
|
149
|
+
export type BorderVariant = Hue | `${Hue}Darken` | `${Hue}Thick` | `${Hue}DarkenThick`;
|
|
150
|
+
|
|
151
|
+
export type IconColorVariant = "white" | Hue;
|
|
152
|
+
|
|
153
|
+
export type CSSVariable = `var(--${string})`;
|
|
154
|
+
|
|
155
|
+
// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis
|
|
156
|
+
export type CSSLength =
|
|
157
|
+
| `${string}cap`
|
|
158
|
+
| `${string}ch`
|
|
159
|
+
| `${string}em`
|
|
160
|
+
| `${string}ex`
|
|
161
|
+
| `${string}ic`
|
|
162
|
+
| `${string}lh`
|
|
163
|
+
| `${string}rcap`
|
|
164
|
+
| `${string}rem`
|
|
165
|
+
| `${string}rex`
|
|
166
|
+
| `${string}ric`
|
|
167
|
+
| `${string}rlh`
|
|
168
|
+
| `${string}vh`
|
|
169
|
+
| `${string}vmax`
|
|
170
|
+
| `${string}vmin`
|
|
171
|
+
| `${string}vw`
|
|
172
|
+
| `${string}vb`
|
|
173
|
+
| `${string}vi`
|
|
174
|
+
| `${string}cqw`
|
|
175
|
+
| `${string}cqh`
|
|
176
|
+
| `${string}cqi`
|
|
177
|
+
| `${string}cqb`
|
|
178
|
+
| `${string}cqmin`
|
|
179
|
+
| `${string}cqmax`
|
|
180
|
+
| `${string}px`
|
|
181
|
+
| `${string}cm`
|
|
182
|
+
| `${string}mm`
|
|
183
|
+
| `${string}q`
|
|
184
|
+
| `${string}in`
|
|
185
|
+
| `${string}pc`
|
|
186
|
+
| `${string}pt`;
|
|
187
|
+
|
|
188
|
+
export type CSSPercentage = `${string}%`;
|
|
189
|
+
|
|
190
|
+
export type CSSCalc = `calc(${string})`;
|
|
191
|
+
|
|
192
|
+
export type CSSLengthPercentage = CSSLength | CSSPercentage | CSSCalc;
|
|
193
|
+
|
|
194
|
+
export type CSSWidth =
|
|
195
|
+
| "auto"
|
|
196
|
+
| CSSLengthPercentage
|
|
197
|
+
| "min-content"
|
|
198
|
+
| "max-content"
|
|
199
|
+
| "fit-content"
|
|
200
|
+
| `fit-content(${CSSLengthPercentage})`
|
|
201
|
+
| CSSVariable;
|
|
202
|
+
|
|
203
|
+
export type CSSMaxWidth =
|
|
204
|
+
| "none"
|
|
205
|
+
| CSSLengthPercentage
|
|
206
|
+
| "min-content"
|
|
207
|
+
| "max-content"
|
|
208
|
+
| "fit-content"
|
|
209
|
+
| `fit-content(${CSSLengthPercentage})`
|
|
210
|
+
| CSSVariable;
|
|
211
|
+
|
|
212
|
+
export type CSSMinWidth = CSSWidth;
|
|
213
|
+
|
|
214
|
+
export type WidthProps = {
|
|
215
|
+
/**
|
|
216
|
+
* 幅を指定
|
|
217
|
+
* @default auto
|
|
218
|
+
*/
|
|
219
|
+
width?: CSSWidth;
|
|
220
|
+
/**
|
|
221
|
+
* 最小幅
|
|
222
|
+
* @default auto
|
|
223
|
+
*/
|
|
224
|
+
minWidth?: CSSMinWidth;
|
|
225
|
+
/**
|
|
226
|
+
* 最大幅
|
|
227
|
+
* @default none
|
|
228
|
+
*/
|
|
229
|
+
maxWidth?: CSSMaxWidth;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export type CSSHeight = CSSWidth;
|
|
233
|
+
|
|
234
|
+
export type CSSMaxHeight = CSSMaxWidth;
|
|
235
|
+
|
|
236
|
+
export type CSSMinHeight = CSSHeight;
|
|
237
|
+
|
|
238
|
+
export type HeightProps = {
|
|
239
|
+
/**
|
|
240
|
+
* 高さを指定
|
|
241
|
+
* @default auto
|
|
242
|
+
*/
|
|
243
|
+
height?: CSSHeight;
|
|
244
|
+
/**
|
|
245
|
+
* 最小高さ
|
|
246
|
+
* @default auto
|
|
247
|
+
*/
|
|
248
|
+
minHeight?: CSSMinHeight;
|
|
249
|
+
/**
|
|
250
|
+
* 最大高さ
|
|
251
|
+
* @default none
|
|
252
|
+
*/
|
|
253
|
+
maxHeight?: CSSMaxHeight;
|
|
254
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
4
|
+
type FixedForwardRef = <T, P = {}>(
|
|
5
|
+
render: (props: P, ref: React.Ref<T>) => React.ReactNode,
|
|
6
|
+
) => (props: P & React.RefAttributes<T>) => React.ReactNode;
|
|
7
|
+
|
|
8
|
+
export const fixedForwardRef: FixedForwardRef = forwardRef as FixedForwardRef;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it, expect } from "vite-plus/test";
|
|
2
|
+
import { opacityToClassName, colorVariable, widthVariables } from "./style";
|
|
3
|
+
|
|
4
|
+
describe("opacityToClassName", () => {
|
|
5
|
+
it("should return normalOverlay when opacity is normal", () => {
|
|
6
|
+
expect(opacityToClassName("normal")).toBe("normalOverlay");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should return darkerOverlay when opacity is darker", () => {
|
|
10
|
+
expect(opacityToClassName("darker")).toBe("darkerOverlay");
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe("colorVariable", () => {
|
|
15
|
+
// 名前も正確性を保つ形に修正
|
|
16
|
+
it("should return main text color variable", () => {
|
|
17
|
+
expect(colorVariable("main") as Record<string, string>).toStrictEqual({
|
|
18
|
+
"--text-color": "var(--color-on-surface)",
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
it("should return sub text color variable", () => {
|
|
22
|
+
expect(colorVariable("sub") as Record<string, string>).toStrictEqual({
|
|
23
|
+
"--text-color": "var(--color-on-surface-variant)",
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it("should return blue color variable", () => {
|
|
27
|
+
expect(colorVariable("blue") as Record<string, string>).toStrictEqual({
|
|
28
|
+
"--text-color": "var(--color-ubie-blue-800)",
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it("should return accent pink darken color variable", () => {
|
|
32
|
+
expect(colorVariable("pinkDarken") as Record<string, string>).toStrictEqual({
|
|
33
|
+
"--text-color": "var(--color-ubie-pink-900)",
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
it("should return link sub text color variable", () => {
|
|
37
|
+
expect(colorVariable("linkSub") as Record<string, string>).toStrictEqual({
|
|
38
|
+
"--text-color": "var(--color-on-surface-variant)",
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("widthVariables", () => {
|
|
44
|
+
it("should return default width values", () => {
|
|
45
|
+
const variables = widthVariables({});
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
expect(variables["--width"]).toStrictEqual("auto");
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
expect(variables["--max-width"]).toStrictEqual("none");
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
expect(variables["--min-width"]).toStrictEqual("auto");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Spacing,
|
|
3
|
+
Radius,
|
|
4
|
+
HeadingFontSize,
|
|
5
|
+
TextType,
|
|
6
|
+
BodyFontSize,
|
|
7
|
+
BodyLeading,
|
|
8
|
+
ButtonFontSize,
|
|
9
|
+
ButtonLeading,
|
|
10
|
+
HeadingLeading,
|
|
11
|
+
TagFontSize,
|
|
12
|
+
TagLeading,
|
|
13
|
+
CSSMinWidth,
|
|
14
|
+
CSSMaxWidth,
|
|
15
|
+
CSSWidth,
|
|
16
|
+
TextColorVariant,
|
|
17
|
+
TextColorTokenKey,
|
|
18
|
+
BackgroundColorVariant,
|
|
19
|
+
BackgroundColorTokenKey,
|
|
20
|
+
BorderVariant,
|
|
21
|
+
BorderColorTokenKey,
|
|
22
|
+
IconColorVariant,
|
|
23
|
+
} from "../types/style";
|
|
24
|
+
import type { CSSProperties } from "react";
|
|
25
|
+
|
|
26
|
+
export type Opacity = "normal" | "darker";
|
|
27
|
+
export const opacityToClassName = (opacity: Opacity) => {
|
|
28
|
+
switch (opacity) {
|
|
29
|
+
case "normal":
|
|
30
|
+
return "normalOverlay";
|
|
31
|
+
case "darker":
|
|
32
|
+
return "darkerOverlay";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const createSpacingVariableFromKey = (key: Spacing) => {
|
|
37
|
+
return `var(--size-spacing-${key})`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const createRadiusVariableFromKey = (key: Radius) => {
|
|
41
|
+
return `var(--radius-${key})`;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const cssFontSizeToken = ({
|
|
45
|
+
type,
|
|
46
|
+
size,
|
|
47
|
+
}:
|
|
48
|
+
| {
|
|
49
|
+
type: Extract<TextType, "body">;
|
|
50
|
+
size: BodyFontSize;
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
type: Extract<TextType, "heading">;
|
|
54
|
+
size: HeadingFontSize;
|
|
55
|
+
}
|
|
56
|
+
| {
|
|
57
|
+
type: Extract<TextType, "button">;
|
|
58
|
+
size: ButtonFontSize;
|
|
59
|
+
}
|
|
60
|
+
| {
|
|
61
|
+
type: Extract<TextType, "tag">;
|
|
62
|
+
size: TagFontSize;
|
|
63
|
+
}) => {
|
|
64
|
+
switch (type) {
|
|
65
|
+
case "body":
|
|
66
|
+
return `var(--text-${type}-${size}-size)`;
|
|
67
|
+
case "heading":
|
|
68
|
+
return `var(--text-${type}-${size}-size)`;
|
|
69
|
+
case "button":
|
|
70
|
+
return `var(--text-${type}-${size}-size)`;
|
|
71
|
+
case "tag":
|
|
72
|
+
return `var(--text-${type}-${size}-size)`;
|
|
73
|
+
default:
|
|
74
|
+
// eslint-disable-next-line no-case-declarations
|
|
75
|
+
const _: never = type;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return "";
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const cssLeadingToken = ({
|
|
82
|
+
type,
|
|
83
|
+
size,
|
|
84
|
+
leading,
|
|
85
|
+
}:
|
|
86
|
+
| {
|
|
87
|
+
type: Extract<TextType, "body">;
|
|
88
|
+
size: BodyFontSize;
|
|
89
|
+
leading: BodyLeading;
|
|
90
|
+
}
|
|
91
|
+
| {
|
|
92
|
+
type: Extract<TextType, "heading">;
|
|
93
|
+
size: HeadingFontSize;
|
|
94
|
+
leading: HeadingLeading;
|
|
95
|
+
}
|
|
96
|
+
| {
|
|
97
|
+
type: Extract<TextType, "button">;
|
|
98
|
+
size: ButtonFontSize;
|
|
99
|
+
leading: ButtonLeading;
|
|
100
|
+
}
|
|
101
|
+
| {
|
|
102
|
+
type: Extract<TextType, "tag">;
|
|
103
|
+
size: TagFontSize;
|
|
104
|
+
leading: TagLeading;
|
|
105
|
+
}) => {
|
|
106
|
+
switch (type) {
|
|
107
|
+
case "body":
|
|
108
|
+
return leading === "default"
|
|
109
|
+
? `var(--text-${type}-${size}-line)`
|
|
110
|
+
: `var(--text-${type}-${size}-${leading}-line)`;
|
|
111
|
+
case "heading":
|
|
112
|
+
return `var(--text-${type}-${size}-line)`;
|
|
113
|
+
case "button":
|
|
114
|
+
return `var(--text-${type}-${size}-line)`;
|
|
115
|
+
case "tag":
|
|
116
|
+
return `var(--text-${type}-${size}-line)`;
|
|
117
|
+
default:
|
|
118
|
+
// eslint-disable-next-line no-case-declarations
|
|
119
|
+
const _: never = type;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return "";
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const textColorTokenKeyMap = {
|
|
126
|
+
main: "on-surface",
|
|
127
|
+
sub: "on-surface-variant",
|
|
128
|
+
link: "primary",
|
|
129
|
+
linkSub: "on-surface-variant",
|
|
130
|
+
disabled: "placeholder",
|
|
131
|
+
white: "on-primary",
|
|
132
|
+
black: "on-surface-variant",
|
|
133
|
+
blue: "ubie-blue-800",
|
|
134
|
+
pink: "ubie-pink-600",
|
|
135
|
+
orange: "ubie-yellow-800",
|
|
136
|
+
purple: "ubie-purple-800",
|
|
137
|
+
green: "ubie-green-800",
|
|
138
|
+
red: "ubie-red-800",
|
|
139
|
+
blackDarken: "on-surface",
|
|
140
|
+
blueDarken: "primary",
|
|
141
|
+
pinkDarken: "ubie-pink-900",
|
|
142
|
+
orangeDarken: "ubie-yellow-900",
|
|
143
|
+
purpleDarken: "ubie-purple-900",
|
|
144
|
+
greenDarken: "ubie-green-900",
|
|
145
|
+
redDarken: "ubie-red-900",
|
|
146
|
+
} as const satisfies Record<TextColorVariant, TextColorTokenKey>;
|
|
147
|
+
|
|
148
|
+
const textColorVariantToTokenKey = (color: TextColorVariant) => {
|
|
149
|
+
return textColorTokenKeyMap[color];
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns css variants based on the foreground color key
|
|
154
|
+
*/
|
|
155
|
+
export const colorVariable = (color: TextColorVariant | undefined): CSSProperties => {
|
|
156
|
+
if (color == null) {
|
|
157
|
+
return {
|
|
158
|
+
"--text-color": "inherit",
|
|
159
|
+
} as CSSProperties;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const tokenKey = textColorVariantToTokenKey(color);
|
|
163
|
+
return {
|
|
164
|
+
"--text-color": `var(--color-${tokenKey})`,
|
|
165
|
+
} as CSSProperties;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const backgroundColorVariantToTokenKey = (color: BackgroundColorVariant) => {
|
|
169
|
+
const tokenKeyMap = {
|
|
170
|
+
white: "surface-container",
|
|
171
|
+
black: "ubie-gray-100",
|
|
172
|
+
blue: "ubie-blue-100",
|
|
173
|
+
pink: "ubie-pink-100",
|
|
174
|
+
orange: "warning-container",
|
|
175
|
+
purple: "accent-purple-container",
|
|
176
|
+
green: "success-container",
|
|
177
|
+
red: "error-container",
|
|
178
|
+
blackDarken: "outline-variant",
|
|
179
|
+
blueDarken: "on-primary-icon",
|
|
180
|
+
pinkDarken: "ubie-pink-200",
|
|
181
|
+
orangeDarken: "ubie-yellow-200",
|
|
182
|
+
purpleDarken: "ubie-purple-200",
|
|
183
|
+
greenDarken: "ubie-green-200",
|
|
184
|
+
redDarken: "on-error-icon",
|
|
185
|
+
blackInverse: "ubie-gray-600",
|
|
186
|
+
blueInverse: "primary",
|
|
187
|
+
pinkInverse: "ubie-pink-600",
|
|
188
|
+
orangeInverse: "ubie-yellow-600",
|
|
189
|
+
purpleInverse: "accent-purple",
|
|
190
|
+
greenInverse: "success",
|
|
191
|
+
redInverse: "error",
|
|
192
|
+
blackInverseDarken: "ubie-gray-700",
|
|
193
|
+
blueInverseDarken: "ubie-blue-800",
|
|
194
|
+
pinkInverseDarken: "ubie-pink-800",
|
|
195
|
+
orangeInverseDarken: "on-warning-container",
|
|
196
|
+
purpleInverseDarken: "on-accent-purple-container",
|
|
197
|
+
greenInverseDarken: "on-success-container",
|
|
198
|
+
redInverseDarken: "ubie-red-700",
|
|
199
|
+
} as const satisfies Record<BackgroundColorVariant, BackgroundColorTokenKey>;
|
|
200
|
+
|
|
201
|
+
return tokenKeyMap[color];
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const backgroundColorVariable = (
|
|
205
|
+
color: BackgroundColorVariant | undefined,
|
|
206
|
+
): CSSProperties => {
|
|
207
|
+
if (color == null) {
|
|
208
|
+
return {
|
|
209
|
+
"--background-color": "transparent",
|
|
210
|
+
} as CSSProperties;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const tokenKey = backgroundColorVariantToTokenKey(color);
|
|
214
|
+
return {
|
|
215
|
+
"--background-color": `var(--color-${tokenKey})`,
|
|
216
|
+
} as CSSProperties;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const iconColorVariable = (color?: IconColorVariant): CSSProperties => {
|
|
220
|
+
if (color == null) {
|
|
221
|
+
return {
|
|
222
|
+
"--icon-color": "inherit",
|
|
223
|
+
} as CSSProperties;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (color === "white") {
|
|
227
|
+
return {
|
|
228
|
+
"--icon-color": "var(--color-ubie-white)",
|
|
229
|
+
} as CSSProperties;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// FIXME icon用のトークンが定義されたら差し替え
|
|
233
|
+
return {
|
|
234
|
+
"--icon-color": `var(--color-ubie-${color}-600)`,
|
|
235
|
+
} as CSSProperties;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Accepts optional arguments to unify default values.
|
|
240
|
+
*/
|
|
241
|
+
export const paddingVariables = ({
|
|
242
|
+
p,
|
|
243
|
+
px,
|
|
244
|
+
py,
|
|
245
|
+
pt,
|
|
246
|
+
pr,
|
|
247
|
+
pb,
|
|
248
|
+
pl,
|
|
249
|
+
}: {
|
|
250
|
+
p?: Spacing;
|
|
251
|
+
px?: Spacing;
|
|
252
|
+
py?: Spacing;
|
|
253
|
+
pt?: Spacing;
|
|
254
|
+
pr?: Spacing;
|
|
255
|
+
pb?: Spacing;
|
|
256
|
+
pl?: Spacing;
|
|
257
|
+
}) => {
|
|
258
|
+
const topKey = pt ?? py ?? p;
|
|
259
|
+
const rightKey = pr ?? px ?? p;
|
|
260
|
+
const bottomKey = pb ?? py ?? p;
|
|
261
|
+
const leftKey = pl ?? px ?? p;
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
"--padding-top": topKey ? createSpacingVariableFromKey(topKey) : "0",
|
|
265
|
+
"--padding-right": rightKey ? createSpacingVariableFromKey(rightKey) : "0",
|
|
266
|
+
"--padding-bottom": bottomKey ? createSpacingVariableFromKey(bottomKey) : "0",
|
|
267
|
+
"--padding-left": leftKey ? createSpacingVariableFromKey(leftKey) : "0",
|
|
268
|
+
} as CSSProperties;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Accepts optional arguments to unify default values.
|
|
273
|
+
*/
|
|
274
|
+
export const marginVariables = ({
|
|
275
|
+
m,
|
|
276
|
+
mx,
|
|
277
|
+
my,
|
|
278
|
+
mt,
|
|
279
|
+
mr,
|
|
280
|
+
mb,
|
|
281
|
+
ml,
|
|
282
|
+
}: {
|
|
283
|
+
m?: Spacing;
|
|
284
|
+
mx?: Spacing;
|
|
285
|
+
my?: Spacing;
|
|
286
|
+
mt?: Spacing;
|
|
287
|
+
mr?: Spacing;
|
|
288
|
+
mb?: Spacing;
|
|
289
|
+
ml?: Spacing;
|
|
290
|
+
}) => {
|
|
291
|
+
const topKey = mt ?? my ?? m;
|
|
292
|
+
const rightKey = mr ?? mx ?? m;
|
|
293
|
+
const bottomKey = mb ?? my ?? m;
|
|
294
|
+
const leftKey = ml ?? mx ?? m;
|
|
295
|
+
|
|
296
|
+
return {
|
|
297
|
+
"--margin-top": topKey ? createSpacingVariableFromKey(topKey) : "0",
|
|
298
|
+
"--margin-right": rightKey ? createSpacingVariableFromKey(rightKey) : "0",
|
|
299
|
+
"--margin-bottom": bottomKey ? createSpacingVariableFromKey(bottomKey) : "0",
|
|
300
|
+
"--margin-left": leftKey ? createSpacingVariableFromKey(leftKey) : "0",
|
|
301
|
+
} as CSSProperties;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Accepts optional arguments to unify default values.
|
|
306
|
+
*/
|
|
307
|
+
export const radiusVariables = (radius?: Radius) => {
|
|
308
|
+
return {
|
|
309
|
+
"--radius": radius ? createRadiusVariableFromKey(radius) : "0",
|
|
310
|
+
} as CSSProperties;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Accepts optional arguments to unify default values.
|
|
315
|
+
*/
|
|
316
|
+
export const gapVariables = (spacing?: Spacing) => {
|
|
317
|
+
return {
|
|
318
|
+
"--gap": spacing ? `var(--size-spacing-${spacing})` : "0",
|
|
319
|
+
} as CSSProperties;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export const widthVariables = ({
|
|
323
|
+
width = "auto",
|
|
324
|
+
minWidth = "auto",
|
|
325
|
+
maxWidth = "none",
|
|
326
|
+
}: {
|
|
327
|
+
width?: CSSWidth;
|
|
328
|
+
minWidth?: CSSMinWidth;
|
|
329
|
+
maxWidth?: CSSMaxWidth;
|
|
330
|
+
}) => {
|
|
331
|
+
return {
|
|
332
|
+
"--width": width,
|
|
333
|
+
"--min-width": minWidth,
|
|
334
|
+
"--max-width": maxWidth,
|
|
335
|
+
} as CSSProperties;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
const borderVariantToColorTokenKey = (border: BorderVariant) => {
|
|
339
|
+
const tokenKeyMap = {
|
|
340
|
+
black: "outline",
|
|
341
|
+
blue: "ubie-blue-400",
|
|
342
|
+
pink: "ubie-pink-400",
|
|
343
|
+
orange: "ubie-yellow-400",
|
|
344
|
+
purple: "ubie-purple-400",
|
|
345
|
+
green: "ubie-green-400",
|
|
346
|
+
red: "ubie-red-400",
|
|
347
|
+
blackDarken: "placeholder",
|
|
348
|
+
blueDarken: "ubie-blue-500",
|
|
349
|
+
pinkDarken: "ubie-pink-500",
|
|
350
|
+
orangeDarken: "warning",
|
|
351
|
+
purpleDarken: "accent-purple",
|
|
352
|
+
greenDarken: "success",
|
|
353
|
+
redDarken: "error",
|
|
354
|
+
blackThick: "outline",
|
|
355
|
+
blueThick: "ubie-blue-400",
|
|
356
|
+
pinkThick: "ubie-pink-400",
|
|
357
|
+
orangeThick: "ubie-yellow-400",
|
|
358
|
+
purpleThick: "ubie-purple-400",
|
|
359
|
+
greenThick: "ubie-green-400",
|
|
360
|
+
redThick: "ubie-red-400",
|
|
361
|
+
blackDarkenThick: "placeholder",
|
|
362
|
+
blueDarkenThick: "ubie-blue-500",
|
|
363
|
+
pinkDarkenThick: "ubie-pink-500",
|
|
364
|
+
orangeDarkenThick: "warning",
|
|
365
|
+
purpleDarkenThick: "accent-purple",
|
|
366
|
+
greenDarkenThick: "success",
|
|
367
|
+
redDarkenThick: "error",
|
|
368
|
+
} as const satisfies Record<BorderVariant, BorderColorTokenKey>;
|
|
369
|
+
|
|
370
|
+
return tokenKeyMap[border];
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
export const borderVariables = (border?: BorderVariant) => {
|
|
374
|
+
if (border == null) {
|
|
375
|
+
return {
|
|
376
|
+
"--border-width": "0px",
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const isThick = border.endsWith("Thick");
|
|
381
|
+
const colorKey = borderVariantToColorTokenKey(border);
|
|
382
|
+
|
|
383
|
+
return {
|
|
384
|
+
"--border-width": isThick ? "2px" : "1px",
|
|
385
|
+
"--border-color": `var(--color-${colorKey})`,
|
|
386
|
+
};
|
|
387
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type AllOrNone<T> = T | Partial<Record<keyof T, undefined>>;
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
export type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any
|
|
5
|
+
? Omit<T, TOmitted>
|
|
6
|
+
: never;
|
|
7
|
+
|
|
8
|
+
export type HTMLTagname = keyof HTMLElementTagNameMap;
|