@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,168 @@
|
|
|
1
|
+
.text {
|
|
2
|
+
font-size: var(--font-size);
|
|
3
|
+
font-weight: normal;
|
|
4
|
+
hyphens: auto;
|
|
5
|
+
line-height: var(--leading);
|
|
6
|
+
color: var(--text-color);
|
|
7
|
+
overflow-wrap: anywhere;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:where(.text) {
|
|
11
|
+
margin-top: 0;
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a.text {
|
|
16
|
+
text-decoration: underline;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (hover: hover) {
|
|
20
|
+
a.text:hover {
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
a.text:focus-visible {
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
a.text:active {
|
|
30
|
+
text-decoration: underline;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
button.text {
|
|
34
|
+
padding: 0;
|
|
35
|
+
background-color: transparent;
|
|
36
|
+
border: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
button.text.link:focus-visible {
|
|
40
|
+
color: var(--color-primary);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media (hover: hover) {
|
|
44
|
+
button.text.link:hover {
|
|
45
|
+
color: var(--color-primary);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
button.text.link:active {
|
|
49
|
+
color: var(--color-primary);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.bold {
|
|
54
|
+
font-weight: bold;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* font-size */
|
|
58
|
+
.body.xs {
|
|
59
|
+
--font-size: var(--text-body-xs-size);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.body.sm {
|
|
63
|
+
--font-size: var(--text-body-sm-size);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.body.md {
|
|
67
|
+
--font-size: var(--text-body-md-size);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.body.lg {
|
|
71
|
+
--font-size: var(--text-body-lg-size);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.heading.xxs {
|
|
75
|
+
--font-size: var(--text-heading-xxs-size);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.heading.xs {
|
|
79
|
+
--font-size: var(--text-heading-xs-size);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.heading.sm {
|
|
83
|
+
--font-size: var(--text-heading-sm-size);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.heading.md {
|
|
87
|
+
--font-size: var(--text-heading-md-size);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.heading.lg {
|
|
91
|
+
--font-size: var(--text-heading-lg-size);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.heading.xl {
|
|
95
|
+
--font-size: var(--text-heading-xl-size);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.button.sm {
|
|
99
|
+
--font-size: var(--text-button-sm-size);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.button.md {
|
|
103
|
+
--font-size: var(--text-button-md-size);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.button.lg {
|
|
107
|
+
--font-size: var(--text-button-lg-size);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.tag.md {
|
|
111
|
+
--font-size: var(--text-tag-md-size);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.tag.lg {
|
|
115
|
+
--font-size: var(--text-tag-lg-size);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* line-height */
|
|
119
|
+
.default {
|
|
120
|
+
--leading: var(--text-body-md-line);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.default.heading.xs,
|
|
124
|
+
.default.heading.sm {
|
|
125
|
+
--leading: var(--text-heading-sm-line);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.default.heading.md,
|
|
129
|
+
.default.heading.lg,
|
|
130
|
+
.default.heading.xl {
|
|
131
|
+
--leading: var(--text-heading-md-line);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.button.default {
|
|
135
|
+
--leading: var(--text-button-md-line);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.tag.default {
|
|
139
|
+
--leading: var(--text-tag-md-line);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.narrow {
|
|
143
|
+
--leading: var(--text-body-md-narrow-line);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.wide {
|
|
147
|
+
--leading: var(--text-body-md-wide-line);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.wide.heading {
|
|
151
|
+
--leading: var(--text-heading-md-wide-line);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.left {
|
|
155
|
+
text-align: left;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.center {
|
|
159
|
+
text-align: center;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.right {
|
|
163
|
+
text-align: right;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.nowrap {
|
|
167
|
+
white-space: nowrap;
|
|
168
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
|
+
import { cloneElement } from "react";
|
|
5
|
+
import styles from "./Text.module.css";
|
|
6
|
+
import {
|
|
7
|
+
BodyFontSize,
|
|
8
|
+
BodyLeading,
|
|
9
|
+
HeadingFontSize,
|
|
10
|
+
HeadingLeading,
|
|
11
|
+
ButtonFontSize,
|
|
12
|
+
ButtonLeading,
|
|
13
|
+
TagFontSize,
|
|
14
|
+
TagLeading,
|
|
15
|
+
TextColorVariant,
|
|
16
|
+
} from "../../types/style";
|
|
17
|
+
import { fixedForwardRef } from "../../utils/component";
|
|
18
|
+
import { colorVariable } from "../../utils/style";
|
|
19
|
+
import { DistributiveOmit } from "../../utils/types";
|
|
20
|
+
import type {
|
|
21
|
+
ReactNode,
|
|
22
|
+
ElementType,
|
|
23
|
+
ForwardedRef,
|
|
24
|
+
ComponentPropsWithRef,
|
|
25
|
+
ReactElement,
|
|
26
|
+
} from "react";
|
|
27
|
+
|
|
28
|
+
type BaseProps = {
|
|
29
|
+
/**
|
|
30
|
+
* レンダリングされる要素を変更。フレームワークのリンクコンポーネントを想定しています
|
|
31
|
+
* 指定した場合、colorがデフォルトでlinkになります
|
|
32
|
+
*/
|
|
33
|
+
render?: ReactElement;
|
|
34
|
+
/**
|
|
35
|
+
* 表示するテキスト
|
|
36
|
+
* pやdivなどを含めないでください(文法的にNGです)
|
|
37
|
+
*/
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* 太字とする
|
|
41
|
+
*/
|
|
42
|
+
bold?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 文字色の抽象値
|
|
45
|
+
* @default main
|
|
46
|
+
*/
|
|
47
|
+
color?: TextColorVariant;
|
|
48
|
+
/**
|
|
49
|
+
* HTMLのid属性
|
|
50
|
+
*/
|
|
51
|
+
id?: string;
|
|
52
|
+
/**
|
|
53
|
+
* テキストの配置。指定しない場合、親要素の配置を継承
|
|
54
|
+
*/
|
|
55
|
+
textAlign?: "left" | "center" | "right";
|
|
56
|
+
/**
|
|
57
|
+
* 領域が狭い場合でも折り返えさない
|
|
58
|
+
*/
|
|
59
|
+
noWrap?: boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type BodyProps = BaseProps & {
|
|
63
|
+
/**
|
|
64
|
+
* テキストの種類
|
|
65
|
+
* @default body
|
|
66
|
+
*/
|
|
67
|
+
type?: "body";
|
|
68
|
+
/**
|
|
69
|
+
* フォントサイズの抽象値
|
|
70
|
+
* @default md
|
|
71
|
+
*/
|
|
72
|
+
size?: BodyFontSize;
|
|
73
|
+
/**
|
|
74
|
+
* 行送りの抽象値(`line-height`)
|
|
75
|
+
*/
|
|
76
|
+
leading?: BodyLeading;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type HeadingProps = BaseProps & {
|
|
80
|
+
/**
|
|
81
|
+
* テキストの種類
|
|
82
|
+
*/
|
|
83
|
+
type: "heading";
|
|
84
|
+
/**
|
|
85
|
+
* フォントサイズの抽象値
|
|
86
|
+
*/
|
|
87
|
+
size?: HeadingFontSize;
|
|
88
|
+
/**
|
|
89
|
+
* 行送りの抽象値(`line-height`)
|
|
90
|
+
* @default default
|
|
91
|
+
*/
|
|
92
|
+
leading?: HeadingLeading;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type ButtonProps = BaseProps & {
|
|
96
|
+
/**
|
|
97
|
+
* テキストの種類
|
|
98
|
+
*/
|
|
99
|
+
type: "button";
|
|
100
|
+
/**
|
|
101
|
+
* フォントサイズの抽象値
|
|
102
|
+
*/
|
|
103
|
+
size?: ButtonFontSize;
|
|
104
|
+
/**
|
|
105
|
+
* 行送りの抽象値(`line-height`)
|
|
106
|
+
* @default default
|
|
107
|
+
*/
|
|
108
|
+
leading?: ButtonLeading;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type TagProps = BaseProps & {
|
|
112
|
+
/**
|
|
113
|
+
* テキストの種類
|
|
114
|
+
*/
|
|
115
|
+
type: "tag";
|
|
116
|
+
/**
|
|
117
|
+
* フォントサイズの抽象値
|
|
118
|
+
*/
|
|
119
|
+
size?: TagFontSize;
|
|
120
|
+
/**
|
|
121
|
+
* 行送りの抽象値(`line-height`)
|
|
122
|
+
* @default default
|
|
123
|
+
*/
|
|
124
|
+
leading?: TagLeading;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
type TextProps = BodyProps | HeadingProps | ButtonProps | TagProps;
|
|
128
|
+
|
|
129
|
+
function TextInner<T extends ElementType>(
|
|
130
|
+
props: {
|
|
131
|
+
/**
|
|
132
|
+
* レンダリングされる要素を指定。renderとは違い、HTMLのネイティブ要素に限定
|
|
133
|
+
* また、指定した要素に応じて対応する属性も合わせて使用可能に
|
|
134
|
+
* @default p
|
|
135
|
+
*/
|
|
136
|
+
as?: T;
|
|
137
|
+
} & TextProps &
|
|
138
|
+
DistributiveOmit<ComponentPropsWithRef<ElementType extends T ? "p" : T>, "as">,
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
+
ref: ForwardedRef<any>,
|
|
141
|
+
) {
|
|
142
|
+
const {
|
|
143
|
+
render,
|
|
144
|
+
as: TextComponent = "p",
|
|
145
|
+
size = "md",
|
|
146
|
+
type = "body",
|
|
147
|
+
leading = "default",
|
|
148
|
+
bold = false,
|
|
149
|
+
noWrap = false,
|
|
150
|
+
color: _color,
|
|
151
|
+
children,
|
|
152
|
+
id,
|
|
153
|
+
textAlign,
|
|
154
|
+
...rest
|
|
155
|
+
} = props;
|
|
156
|
+
const color =
|
|
157
|
+
_color != null
|
|
158
|
+
? _color
|
|
159
|
+
: TextComponent === "a" || TextComponent === "button" || render != null
|
|
160
|
+
? "link"
|
|
161
|
+
: "main";
|
|
162
|
+
|
|
163
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
164
|
+
const createElement = (props: any, children: ReactNode) => {
|
|
165
|
+
return render ? (
|
|
166
|
+
cloneElement(render, props, children)
|
|
167
|
+
) : (
|
|
168
|
+
<TextComponent {...props}>{children}</TextComponent>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return createElement(
|
|
173
|
+
{
|
|
174
|
+
ref,
|
|
175
|
+
id,
|
|
176
|
+
className: clsx(
|
|
177
|
+
styles.text,
|
|
178
|
+
styles[size],
|
|
179
|
+
styles[type],
|
|
180
|
+
styles[leading],
|
|
181
|
+
textAlign && styles[textAlign],
|
|
182
|
+
bold && styles.bold,
|
|
183
|
+
noWrap && styles.nowrap,
|
|
184
|
+
),
|
|
185
|
+
style: colorVariable(color),
|
|
186
|
+
...rest,
|
|
187
|
+
},
|
|
188
|
+
<>{children}</>,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const Text = fixedForwardRef(TextInner);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.textArea {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
width: 100%;
|
|
4
|
+
padding: var(--size-spacing-md) var(--size-spacing-sm) 0.875rem;
|
|
5
|
+
font-size: var(--text-body-md-narrow-size);
|
|
6
|
+
line-height: var(--text-body-md-narrow-line);
|
|
7
|
+
color: var(--color-on-surface);
|
|
8
|
+
text-align: inherit;
|
|
9
|
+
appearance: none;
|
|
10
|
+
caret-color: var(--color-ubie-blue-600);
|
|
11
|
+
background-color: var(--color-ubie-white);
|
|
12
|
+
border: 1px solid var(--color-outline);
|
|
13
|
+
border-bottom-width: 2px;
|
|
14
|
+
border-radius: 8px 8px 0 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.textArea:disabled {
|
|
18
|
+
color: var(--color-placeholder);
|
|
19
|
+
background-color: var(--color-outline-variant);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.textArea::placeholder {
|
|
23
|
+
color: var(--color-placeholder);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.textArea:disabled::placeholder {
|
|
27
|
+
color: var(--color-placeholder);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.textArea.isInvalid,
|
|
31
|
+
.textArea:user-invalid {
|
|
32
|
+
background: var(--color-error-container);
|
|
33
|
+
border-bottom-color: var(--color-ubie-red-700);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@supports not (selector(:user-invalid)) {
|
|
37
|
+
.textArea:invalid {
|
|
38
|
+
background: var(--color-error-container);
|
|
39
|
+
border-bottom-color: var(--color-ubie-red-700);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.textArea:focus {
|
|
44
|
+
border-bottom-color: var(--color-ubie-blue-600);
|
|
45
|
+
outline: none;
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { createRef } from "react";
|
|
3
|
+
import { TextArea } from "./TextArea";
|
|
4
|
+
|
|
5
|
+
describe("TextArea", () => {
|
|
6
|
+
it("access to DOM through ref prop", () => {
|
|
7
|
+
const ref = createRef<HTMLTextAreaElement>();
|
|
8
|
+
|
|
9
|
+
render(<TextArea name="test" defaultValue="test" ref={ref} />);
|
|
10
|
+
expect(ref.current).not.toBeNull();
|
|
11
|
+
expect(ref.current?.tagName).toBe("TEXTAREA");
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import styles from "./TextArea.module.css";
|
|
6
|
+
import { CustomDataAttributeProps } from "../../types/attributes";
|
|
7
|
+
import type { TextareaHTMLAttributes } from "react";
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
/**
|
|
11
|
+
* 値が不正であることを示す
|
|
12
|
+
*/
|
|
13
|
+
isInvalid?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* フィールドを無効化する
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
} & TextareaHTMLAttributes<HTMLTextAreaElement> &
|
|
19
|
+
CustomDataAttributeProps;
|
|
20
|
+
|
|
21
|
+
export const TextArea = forwardRef<HTMLTextAreaElement, Props>(
|
|
22
|
+
({ isInvalid = false, className, ...props }, ref) => {
|
|
23
|
+
const _className = clsx({ [styles.isInvalid]: isInvalid }, styles.textArea, className);
|
|
24
|
+
|
|
25
|
+
return <textarea ref={ref} {...props} className={_className} aria-invalid={isInvalid} />;
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
TextArea.displayName = "TextArea";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
width: 3rem;
|
|
5
|
+
height: 1.5rem;
|
|
6
|
+
padding: 0.125rem;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
border-radius: 3rem;
|
|
9
|
+
transition: background-color 200ms;
|
|
10
|
+
-webkit-tap-highlight-color: transparent;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.root,
|
|
14
|
+
.root * {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.root:has(input:focus-visible) {
|
|
19
|
+
outline: 2px solid var(--color-ubie-pink-500);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.root:has(input:disabled) {
|
|
23
|
+
cursor: default;
|
|
24
|
+
background-color: var(--color-placeholder);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.on {
|
|
28
|
+
background-color: var(--color-ubie-blue-600);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.off {
|
|
32
|
+
background-color: var(--color-ubie-gray-500);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@media (hover: hover) {
|
|
36
|
+
.on:hover {
|
|
37
|
+
background-color: var(--color-ubie-blue-700);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.off:hover {
|
|
41
|
+
background-color: var(--color-ubie-gray-700);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.thumb {
|
|
46
|
+
width: 1.25rem;
|
|
47
|
+
height: 1.25rem;
|
|
48
|
+
background-color: var(--color-ubie-white);
|
|
49
|
+
border-radius: 50%;
|
|
50
|
+
transition: transform 200ms;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.thumbOn {
|
|
54
|
+
transform: translateX(1.5rem);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.thumbOff {
|
|
58
|
+
transform: translateX(0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.input {
|
|
62
|
+
position: absolute;
|
|
63
|
+
width: 1px;
|
|
64
|
+
height: 1px;
|
|
65
|
+
padding: 0;
|
|
66
|
+
margin: -1px;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
clip: rect(0, 0, 0, 0);
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
border-width: 0;
|
|
71
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { render } from "@testing-library/react";
|
|
2
|
+
import { createRef } from "react";
|
|
3
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
4
|
+
import { Toggle } from "./Toggle";
|
|
5
|
+
|
|
6
|
+
describe("Toggle", () => {
|
|
7
|
+
it("access to DOM through ref prop", () => {
|
|
8
|
+
const ref = createRef<HTMLInputElement>();
|
|
9
|
+
|
|
10
|
+
render(<Toggle name="test" value="test" ref={ref} />);
|
|
11
|
+
expect(ref.current).not.toBeNull();
|
|
12
|
+
expect(ref.current?.tagName).toBe("INPUT");
|
|
13
|
+
expect(ref.current?.type).toBe("checkbox");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("has switch role", () => {
|
|
17
|
+
const { getByTestId } = render(<Toggle name="test" value="test" data-testid="switch" />);
|
|
18
|
+
const element = getByTestId("switch");
|
|
19
|
+
expect(element.getAttribute("role")).toBe("switch");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { forwardRef, InputHTMLAttributes, useRef, useState } from "react";
|
|
5
|
+
import styles from "./Toggle.module.css";
|
|
6
|
+
import { CustomDataAttributeProps } from "../../types/attributes";
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
/**
|
|
10
|
+
* 現在の状態が選択中かどうか
|
|
11
|
+
*/
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 初期状態で選択状態とする
|
|
15
|
+
*/
|
|
16
|
+
defaultChecked?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 無効状態かどうか
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "children"> &
|
|
23
|
+
CustomDataAttributeProps;
|
|
24
|
+
|
|
25
|
+
export const Toggle = forwardRef<HTMLInputElement, Props>(
|
|
26
|
+
({ checked: checkedProps, defaultChecked, onChange, ...otherProps }, ref) => {
|
|
27
|
+
const { current: isUnControlled } = useRef(checkedProps === undefined);
|
|
28
|
+
const [isUnControlledChecked, setIsUnControlledChecked] = useState(defaultChecked);
|
|
29
|
+
|
|
30
|
+
const isChecked = isUnControlled ? isUnControlledChecked : checkedProps;
|
|
31
|
+
|
|
32
|
+
const handleChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {
|
|
33
|
+
if (isUnControlled) {
|
|
34
|
+
setIsUnControlledChecked(event.target.checked);
|
|
35
|
+
}
|
|
36
|
+
if (onChange) onChange(event);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<label className={clsx(styles.root, isChecked ? styles.on : styles.off)}>
|
|
41
|
+
<input
|
|
42
|
+
ref={ref}
|
|
43
|
+
type="checkbox"
|
|
44
|
+
role="switch"
|
|
45
|
+
checked={isChecked}
|
|
46
|
+
onChange={handleChange}
|
|
47
|
+
className={styles.input}
|
|
48
|
+
{...otherProps}
|
|
49
|
+
/>
|
|
50
|
+
<span className={clsx(styles.thumb, isChecked ? styles.thumbOn : styles.thumbOff)} />
|
|
51
|
+
</label>
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
Toggle.displayName = "Toggle";
|
package/src/font.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import debounce from "debounce";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
|
|
4
|
+
export const useScrollable = () => {
|
|
5
|
+
const [canScrollUp, setCanScrollUp] = useState(false);
|
|
6
|
+
const [canScrollDown, setCanScrollDown] = useState(false);
|
|
7
|
+
|
|
8
|
+
let abrotController: AbortController | null = null;
|
|
9
|
+
|
|
10
|
+
const checkScrollable = (element: HTMLDivElement) => {
|
|
11
|
+
const { top, bottom } = element.getBoundingClientRect();
|
|
12
|
+
const { top: contentTop, bottom: contentBottom } = element.children[0].getBoundingClientRect();
|
|
13
|
+
|
|
14
|
+
// On some Android devices, the decimal point in the number causes the judgment to be incorrect.
|
|
15
|
+
setCanScrollUp(Math.floor(contentTop) < Math.floor(top));
|
|
16
|
+
setCanScrollDown(Math.floor(contentBottom) > Math.floor(bottom));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const handleEvent = (element: HTMLDivElement) => () => {
|
|
20
|
+
checkScrollable(element);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const setContainer = (element: HTMLDivElement) => {
|
|
24
|
+
if (!abrotController) return;
|
|
25
|
+
|
|
26
|
+
element.addEventListener("scroll", debounce(handleEvent(element), 25), {
|
|
27
|
+
signal: abrotController.signal,
|
|
28
|
+
passive: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
window.addEventListener("resize", debounce(handleEvent(element), 50), {
|
|
32
|
+
signal: abrotController.signal,
|
|
33
|
+
passive: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// In some cases, the DOM may not be ready when the callback ref is triggered in modal components. It is shifted appropriately.
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
checkScrollable(element);
|
|
39
|
+
}, 10);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const unSetContainer = () => {
|
|
43
|
+
abrotController?.abort();
|
|
44
|
+
abrotController = null;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const scrollContainerRef = useCallback((node: HTMLDivElement | null) => {
|
|
48
|
+
if (node === null) {
|
|
49
|
+
unSetContainer();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
abrotController = new AbortController();
|
|
54
|
+
setContainer(node);
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
return { scrollContainerRef, canScrollUp, canScrollDown };
|
|
58
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { FC, SVGProps } from "react";
|
|
4
|
+
|
|
5
|
+
export const AppleIcon: FC<SVGProps<SVGSVGElement>> = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" {...props}>
|
|
8
|
+
<path
|
|
9
|
+
d="M20.6856 16.6738C20.2168 17.7149 19.9909 18.1802 19.388 19.099C18.5439 20.383 17.3534 21.9863 15.8826 21.9964C14.5732 22.0083 14.2352 21.1422 12.457 21.1575C10.6805 21.1659 10.3103 22.0134 8.99916 21.9998C7.52669 21.9863 6.40068 20.5427 5.55659 19.2604C3.19588 15.665 2.94622 11.4497 4.40511 9.20782C5.43771 7.61816 7.06983 6.68407 8.60345 6.68407C10.1659 6.68407 11.1476 7.54174 12.4383 7.54174C13.6917 7.54174 14.4543 6.68237 16.2613 6.68237C17.6268 6.68237 19.0704 7.42625 20.103 8.71021C16.7267 10.5614 17.2753 15.383 20.6856 16.6738ZM14.8891 5.24726C15.5463 4.40317 16.0456 3.21263 15.8639 2C14.7923 2.07303 13.5389 2.75747 12.8069 3.64401C12.1428 4.45243 11.5926 5.65147 11.8065 6.81144C12.9767 6.84881 14.1876 6.15078 14.8891 5.24726Z"
|
|
10
|
+
fill="white"
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { FC, SVGProps } from "react";
|
|
4
|
+
|
|
5
|
+
export const GoogleIcon: FC<SVGProps<SVGSVGElement>> = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<svg height="1em" viewBox="0 0 24 24" width="1em" {...props}>
|
|
8
|
+
<path
|
|
9
|
+
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
10
|
+
fill="#4285F4"
|
|
11
|
+
/>
|
|
12
|
+
<path
|
|
13
|
+
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
14
|
+
fill="#34A853"
|
|
15
|
+
/>
|
|
16
|
+
<path
|
|
17
|
+
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|
18
|
+
fill="#FBBC05"
|
|
19
|
+
/>
|
|
20
|
+
<path
|
|
21
|
+
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
22
|
+
fill="#EA4335"
|
|
23
|
+
/>
|
|
24
|
+
<path d="M1 1h22v22H1z" fill="none" />
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
};
|