@mich8060/chg-design-system 0.1.0
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/.github/workflows/figma-sync.yml +30 -0
- package/ARCHITECTURE_FIX.md +241 -0
- package/LICENSE +21 -0
- package/README.lib.md +103 -0
- package/README.md +177 -0
- package/figma.config.json +9 -0
- package/package.json +67 -0
- package/package.lib.json +49 -0
- package/public/data/figma-variables.json +40026 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +46 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/public/styles/tokens.css +1994 -0
- package/scripts/index.js +896 -0
- package/scripts/publish-lib.js +150 -0
- package/scripts/validate.js +94 -0
- package/src/App.css +457 -0
- package/src/App.css.map +1 -0
- package/src/App.js +161 -0
- package/src/App.scss +548 -0
- package/src/App.test.js +8 -0
- package/src/assets/images/.gitkeep +0 -0
- package/src/assets/images/doctors/Avatar-1.png +0 -0
- package/src/assets/images/doctors/Avatar-10.png +0 -0
- package/src/assets/images/doctors/Avatar-11.png +0 -0
- package/src/assets/images/doctors/Avatar-12.png +0 -0
- package/src/assets/images/doctors/Avatar-13.png +0 -0
- package/src/assets/images/doctors/Avatar-14.png +0 -0
- package/src/assets/images/doctors/Avatar-15.png +0 -0
- package/src/assets/images/doctors/Avatar-16.png +0 -0
- package/src/assets/images/doctors/Avatar-17.png +0 -0
- package/src/assets/images/doctors/Avatar-18.png +0 -0
- package/src/assets/images/doctors/Avatar-19.png +0 -0
- package/src/assets/images/doctors/Avatar-2.png +0 -0
- package/src/assets/images/doctors/Avatar-20.png +0 -0
- package/src/assets/images/doctors/Avatar-21.png +0 -0
- package/src/assets/images/doctors/Avatar-3.png +0 -0
- package/src/assets/images/doctors/Avatar-4.png +0 -0
- package/src/assets/images/doctors/Avatar-5.png +0 -0
- package/src/assets/images/doctors/Avatar-6.png +0 -0
- package/src/assets/images/doctors/Avatar-7.png +0 -0
- package/src/assets/images/doctors/Avatar-8.png +0 -0
- package/src/assets/images/doctors/Avatar-9.png +0 -0
- package/src/assets/images/doctors/Avatar.png +0 -0
- package/src/assets/images/doctors/index.js +141 -0
- package/src/data/figma-variables.json +90305 -0
- package/src/index.js +20 -0
- package/src/index.scss +10 -0
- package/src/pages/AccordionDemo.jsx +206 -0
- package/src/pages/AccordionDemo.scss +34 -0
- package/src/pages/ActionMenuDemo.jsx +957 -0
- package/src/pages/ActionMenuDemo.scss +34 -0
- package/src/pages/AvatarDemo.jsx +328 -0
- package/src/pages/AvatarDemo.scss +40 -0
- package/src/pages/BadgeDemo.jsx +254 -0
- package/src/pages/BadgeDemo.scss +40 -0
- package/src/pages/BorderRadiusDemo.jsx +112 -0
- package/src/pages/BorderRadiusDemo.scss +50 -0
- package/src/pages/BrandingDemo.jsx +117 -0
- package/src/pages/BreadcrumbDemo.jsx +172 -0
- package/src/pages/ButtonDemo.jsx +708 -0
- package/src/pages/ButtonDemo.scss +34 -0
- package/src/pages/CheckboxDemo.jsx +194 -0
- package/src/pages/ChipDemo.jsx +359 -0
- package/src/pages/ChipDemo.scss +40 -0
- package/src/pages/ColorsDemo.jsx +566 -0
- package/src/pages/ColorsDemo.scss +243 -0
- package/src/pages/ComponentsUsage.jsx +401 -0
- package/src/pages/DatepickerDemo.jsx +223 -0
- package/src/pages/DividerDemo.jsx +337 -0
- package/src/pages/DotStatusDemo.jsx +223 -0
- package/src/pages/DropdownDemo.jsx +229 -0
- package/src/pages/FieldDemo.jsx +253 -0
- package/src/pages/FigmaVariablesDemo.jsx +426 -0
- package/src/pages/FigmaVariablesDemo.scss +316 -0
- package/src/pages/FileUploadDemo.jsx +186 -0
- package/src/pages/FlexDemo.jsx +144 -0
- package/src/pages/FlexDemo.scss +119 -0
- package/src/pages/FontInstallation.jsx +252 -0
- package/src/pages/FontInstallation.scss +40 -0
- package/src/pages/Home.jsx +3156 -0
- package/src/pages/IconDemo.jsx +1680 -0
- package/src/pages/ImageAspectDemo.jsx +152 -0
- package/src/pages/InputDemo.jsx +245 -0
- package/src/pages/Installation.jsx +257 -0
- package/src/pages/Installation.scss +40 -0
- package/src/pages/KeyDemo.jsx +184 -0
- package/src/pages/MenuDemo.jsx +139 -0
- package/src/pages/MicroCalendarDemo.jsx +165 -0
- package/src/pages/PaginationDemo.jsx +176 -0
- package/src/pages/PillToggleDemo.jsx +212 -0
- package/src/pages/ProgressCircleDemo.jsx +206 -0
- package/src/pages/ProgressIndicatorDemo.jsx +227 -0
- package/src/pages/RadioDemo.jsx +282 -0
- package/src/pages/ShadowsDemo.jsx +118 -0
- package/src/pages/ShadowsDemo.scss +93 -0
- package/src/pages/SliderDemo.jsx +226 -0
- package/src/pages/SpacingDemo.jsx +160 -0
- package/src/pages/SpacingDemo.scss +107 -0
- package/src/pages/StatusDemo.jsx +196 -0
- package/src/pages/StepsDemo.jsx +308 -0
- package/src/pages/TableDemo.jsx +376 -0
- package/src/pages/TabsDemo.jsx +221 -0
- package/src/pages/ToastDemo.jsx +195 -0
- package/src/pages/ToggleDemo.jsx +187 -0
- package/src/pages/TokensDemo.jsx +637 -0
- package/src/pages/TokensDemo.scss +270 -0
- package/src/pages/TokensUsage.jsx +220 -0
- package/src/pages/TooltipDemo.jsx +170 -0
- package/src/pages/TypographyDemo.jsx +229 -0
- package/src/pages/TypographyDemo.scss +105 -0
- package/src/pages/UtilitiesDemo.jsx +381 -0
- package/src/pages/UtilitiesDemo.scss +214 -0
- package/src/reportWebVitals.js +13 -0
- package/src/setupTests.js +5 -0
- package/src/styles/_typography.scss +932 -0
- package/src/styles/_utilities.scss +3635 -0
- package/src/styles/_variables.scss +887 -0
- package/src/styles/prism-custom.css +206 -0
- package/src/styles/prism-custom.css.map +1 -0
- package/src/styles/prism-custom.scss +205 -0
- package/src/styles/tokens.css +4416 -0
- package/src/styles/tokens.css.map +1 -0
- package/src/styles/tokens.scss +1456 -0
- package/src/ui/Accordion/Accordion.jsx +70 -0
- package/src/ui/Accordion/Accordion.scss +82 -0
- package/src/ui/Accordion/index.js +1 -0
- package/src/ui/ActionMenu/ActionMenu.jsx +383 -0
- package/src/ui/ActionMenu/ActionMenu.scss +198 -0
- package/src/ui/ActionMenu/index.js +1 -0
- package/src/ui/Avatar/Avatar.jsx +49 -0
- package/src/ui/Avatar/Avatar.scss +82 -0
- package/src/ui/Avatar/index.js +1 -0
- package/src/ui/Badge/Badge.jsx +64 -0
- package/src/ui/Badge/Badge.scss +84 -0
- package/src/ui/Badge/index.js +1 -0
- package/src/ui/Branding/Branding.jsx +65 -0
- package/src/ui/Branding/Branding.scss +116 -0
- package/src/ui/Branding/index.js +1 -0
- package/src/ui/Breadcrumb/Breadcrumb.jsx +162 -0
- package/src/ui/Breadcrumb/Breadcrumb.scss +46 -0
- package/src/ui/Breadcrumb/index.js +2 -0
- package/src/ui/Button/Button.figma.tsx +49 -0
- package/src/ui/Button/Button.jsx +135 -0
- package/src/ui/Button/Button.scss +188 -0
- package/src/ui/Button/index.js +1 -0
- package/src/ui/Card/Card.jsx +25 -0
- package/src/ui/Card/Card.scss +47 -0
- package/src/ui/Card/index.js +1 -0
- package/src/ui/Checkbox/Checkbox.jsx +70 -0
- package/src/ui/Checkbox/Checkbox.scss +96 -0
- package/src/ui/Checkbox/index.js +1 -0
- package/src/ui/Chip/Chip.jsx +104 -0
- package/src/ui/Chip/Chip.scss +118 -0
- package/src/ui/Chip/index.js +1 -0
- package/src/ui/CopyButton/CopyButton.jsx +102 -0
- package/src/ui/CopyButton/CopyButton.scss +56 -0
- package/src/ui/CopyButton/index.js +1 -0
- package/src/ui/Datepicker/Datepicker.jsx +326 -0
- package/src/ui/Datepicker/Datepicker.scss +187 -0
- package/src/ui/Datepicker/index.js +2 -0
- package/src/ui/Divider/Divider.jsx +89 -0
- package/src/ui/Divider/Divider.scss +112 -0
- package/src/ui/Divider/index.js +1 -0
- package/src/ui/DotStatus/DotStatus.jsx +64 -0
- package/src/ui/DotStatus/DotStatus.scss +87 -0
- package/src/ui/DotStatus/index.js +1 -0
- package/src/ui/Dropdown/Dropdown.jsx +200 -0
- package/src/ui/Dropdown/Dropdown.scss +156 -0
- package/src/ui/Dropdown/index.js +1 -0
- package/src/ui/Field/Field.jsx +89 -0
- package/src/ui/Field/Field.scss +119 -0
- package/src/ui/Field/index.js +1 -0
- package/src/ui/FileUpload/FileUpload.figma.tsx +28 -0
- package/src/ui/FileUpload/FileUpload.jsx +153 -0
- package/src/ui/FileUpload/FileUpload.scss +78 -0
- package/src/ui/FileUpload/index.js +2 -0
- package/src/ui/Flex/Flex.jsx +42 -0
- package/src/ui/Flex/Flex.scss +119 -0
- package/src/ui/Flex/index.js +1 -0
- package/src/ui/Icon/Icon.figma.tsx +22 -0
- package/src/ui/Icon/Icon.jsx +47 -0
- package/src/ui/Icon/index.js +1 -0
- package/src/ui/ImageAspect/ImageAspect.jsx +56 -0
- package/src/ui/ImageAspect/ImageAspect.scss +62 -0
- package/src/ui/ImageAspect/index.js +1 -0
- package/src/ui/Input/Input.figma.tsx +35 -0
- package/src/ui/Input/Input.jsx +68 -0
- package/src/ui/Input/Input.scss +64 -0
- package/src/ui/Input/index.js +2 -0
- package/src/ui/Key/Key.jsx +37 -0
- package/src/ui/Key/Key.scss +34 -0
- package/src/ui/Key/index.js +1 -0
- package/src/ui/Menu/Menu.jsx +389 -0
- package/src/ui/Menu/Menu.scss +382 -0
- package/src/ui/Menu/index.js +1 -0
- package/src/ui/MicroCalendar/MicroCalendar.jsx +392 -0
- package/src/ui/MicroCalendar/MicroCalendar.scss +277 -0
- package/src/ui/MicroCalendar/index.js +1 -0
- package/src/ui/Pagination/Pagination.jsx +237 -0
- package/src/ui/Pagination/Pagination.scss +182 -0
- package/src/ui/Pagination/index.js +1 -0
- package/src/ui/PillToggle/PillToggle.jsx +56 -0
- package/src/ui/PillToggle/PillToggle.scss +84 -0
- package/src/ui/PillToggle/index.js +1 -0
- package/src/ui/Playground/Playground.jsx +524 -0
- package/src/ui/Playground/Playground.scss +310 -0
- package/src/ui/Playground/index.js +2 -0
- package/src/ui/ProgressCircle/ProgressCircle.jsx +147 -0
- package/src/ui/ProgressCircle/ProgressCircle.scss +143 -0
- package/src/ui/ProgressCircle/index.js +1 -0
- package/src/ui/ProgressIndicator/ProgressIndicator.jsx +92 -0
- package/src/ui/ProgressIndicator/ProgressIndicator.scss +133 -0
- package/src/ui/ProgressIndicator/index.js +1 -0
- package/src/ui/Radio/Radio.jsx +57 -0
- package/src/ui/Radio/Radio.scss +84 -0
- package/src/ui/Radio/index.js +1 -0
- package/src/ui/Slider/Slider.jsx +283 -0
- package/src/ui/Slider/Slider.scss +156 -0
- package/src/ui/Slider/index.js +1 -0
- package/src/ui/Status/Status.jsx +66 -0
- package/src/ui/Status/Status.scss +90 -0
- package/src/ui/Status/index.js +1 -0
- package/src/ui/Steps/Steps.jsx +201 -0
- package/src/ui/Steps/Steps.scss +240 -0
- package/src/ui/Steps/index.js +1 -0
- package/src/ui/Table/Table.jsx +143 -0
- package/src/ui/Table/Table.scss +90 -0
- package/src/ui/Table/index.js +1 -0
- package/src/ui/Tabs/TabItem.jsx +86 -0
- package/src/ui/Tabs/Tabs.figma.tsx +30 -0
- package/src/ui/Tabs/Tabs.jsx +318 -0
- package/src/ui/Tabs/Tabs.scss +164 -0
- package/src/ui/Tabs/Untitled +1 -0
- package/src/ui/Tabs/index.js +3 -0
- package/src/ui/Tag/Tag.figma.tsx +29 -0
- package/src/ui/Tag/Tag.jsx +93 -0
- package/src/ui/Tag/Tag.scss +229 -0
- package/src/ui/Tag/index.js +2 -0
- package/src/ui/Textarea/Textarea.figma.tsx +35 -0
- package/src/ui/Textarea/Textarea.jsx +68 -0
- package/src/ui/Textarea/Textarea.scss +69 -0
- package/src/ui/Textarea/index.js +2 -0
- package/src/ui/Toast/Toast.jsx +75 -0
- package/src/ui/Toast/Toast.scss +132 -0
- package/src/ui/Toast/index.js +2 -0
- package/src/ui/Toggle/Toggle.jsx +73 -0
- package/src/ui/Toggle/Toggle.scss +139 -0
- package/src/ui/Toggle/index.js +1 -0
- package/src/ui/Tooltip/Tooltip.figma.tsx +24 -0
- package/src/ui/Tooltip/Tooltip.jsx +123 -0
- package/src/ui/Tooltip/Tooltip.scss +80 -0
- package/src/ui/Tooltip/index.js +2 -0
- package/src/ui/index.js +63 -0
- package/src/utils/formatDate.js +27 -0
- package/src/utils/headerVariants.js +69 -0
- package/vite.config.lib.js +55 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
@use "../../styles/typography" as *;
|
|
2
|
+
|
|
3
|
+
.uds-divider {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
width: 100%;
|
|
8
|
+
margin: var(--uds-gap-16) 0;
|
|
9
|
+
|
|
10
|
+
// Solid variant - 8px tall box that goes edge to edge
|
|
11
|
+
&--solid {
|
|
12
|
+
align-items: stretch;
|
|
13
|
+
height: 8px;
|
|
14
|
+
margin: var(--uds-spacing-24) 0;
|
|
15
|
+
background-color: var(--uds-color-neutrals-100);
|
|
16
|
+
border-top:solid var(--uds-border-width-1) var(--uds-border-secondary);
|
|
17
|
+
border-bottom:solid var(--uds-border-width-1) var(--uds-border-secondary);
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Line variant (default) - horizontal line with optional content
|
|
22
|
+
&--line,
|
|
23
|
+
&:not(&--solid) {
|
|
24
|
+
&::before {
|
|
25
|
+
content: "";
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
right: 0;
|
|
29
|
+
top: 50%;
|
|
30
|
+
height: var(--uds-border-width-1);
|
|
31
|
+
background-color: var(--uds-border-primary);
|
|
32
|
+
z-index: 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Alignment variants
|
|
37
|
+
&--left {
|
|
38
|
+
.uds-divider__content {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&--center {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
|
|
46
|
+
.uds-divider__content {
|
|
47
|
+
margin: 0 auto;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&--right {
|
|
52
|
+
.uds-divider__content {
|
|
53
|
+
margin-left: auto;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&__content {
|
|
58
|
+
position: relative;
|
|
59
|
+
z-index: 1;
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: var(--uds-gap-8);
|
|
63
|
+
background-color: var(--uds-surface-primary);
|
|
64
|
+
border: var(--uds-border-width-1) solid var(--uds-border-primary);
|
|
65
|
+
padding-inline: var(--uds-spacing-12);
|
|
66
|
+
padding-block: var(--uds-spacing-4);
|
|
67
|
+
|
|
68
|
+
// Icon-only variant
|
|
69
|
+
&--icon-only {
|
|
70
|
+
border-radius: var(--uds-radius-9999);
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
width:28px;
|
|
75
|
+
padding:0;
|
|
76
|
+
height:28px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Label variant (with or without icon)
|
|
80
|
+
&--with-label {
|
|
81
|
+
border-radius: var(--uds-radius-9999);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&__icon {
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
color: var(--uds-text-primary);
|
|
90
|
+
flex: 0;
|
|
91
|
+
width: 20px;
|
|
92
|
+
height: 28px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&__label {
|
|
96
|
+
@include uds-body-14-medium;
|
|
97
|
+
display: inline-flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: var(--uds-gap-6);
|
|
100
|
+
color: var(--uds-text-primary);
|
|
101
|
+
background-color: var(--uds-surface-primary);
|
|
102
|
+
padding-inline: var(--uds-spacing-8);
|
|
103
|
+
padding-block: var(--uds-spacing-4);
|
|
104
|
+
border-radius: var(--uds-radius-4);
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&__label-icon {
|
|
109
|
+
flex-shrink: 0;
|
|
110
|
+
color: var(--uds-text-primary);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Divider";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./DotStatus.scss";
|
|
3
|
+
|
|
4
|
+
const BASE_CLASS = "uds-dot-status";
|
|
5
|
+
|
|
6
|
+
const variantClassMap = {
|
|
7
|
+
"light-gray": "light-gray",
|
|
8
|
+
red: "red",
|
|
9
|
+
orange: "orange",
|
|
10
|
+
yellow: "yellow",
|
|
11
|
+
"light-green": "light-green",
|
|
12
|
+
green: "green",
|
|
13
|
+
blue: "blue",
|
|
14
|
+
"dark-blue": "dark-blue",
|
|
15
|
+
teal: "teal",
|
|
16
|
+
purple: "purple",
|
|
17
|
+
pink: "pink",
|
|
18
|
+
magenta: "magenta",
|
|
19
|
+
"dark-red": "dark-red",
|
|
20
|
+
"dark-gray": "dark-gray",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const sizeClassMap = {
|
|
24
|
+
small: "small",
|
|
25
|
+
medium: "medium",
|
|
26
|
+
large: "large",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Dot Status component for displaying status indicators
|
|
31
|
+
* @param {string} variant - Color variant
|
|
32
|
+
* @param {string} size - Size variant: 'small', 'medium', or 'large'
|
|
33
|
+
* @param {boolean} outline - Whether to show an outline/border around the dot
|
|
34
|
+
* @param {string} className - Additional CSS classes
|
|
35
|
+
* @param {string} 'aria-label' - Accessible label for screen readers
|
|
36
|
+
* @param {object} props - Additional props to pass to the dot element
|
|
37
|
+
*/
|
|
38
|
+
export default function DotStatus({
|
|
39
|
+
variant = "blue",
|
|
40
|
+
size = "medium",
|
|
41
|
+
outline = false,
|
|
42
|
+
className = "",
|
|
43
|
+
"aria-label": ariaLabel,
|
|
44
|
+
...props
|
|
45
|
+
}) {
|
|
46
|
+
const classNames = [
|
|
47
|
+
BASE_CLASS,
|
|
48
|
+
variantClassMap[variant] && `${BASE_CLASS}--${variantClassMap[variant]}`,
|
|
49
|
+
sizeClassMap[size] && `${BASE_CLASS}--${sizeClassMap[size]}`,
|
|
50
|
+
outline && `${BASE_CLASS}--outline`,
|
|
51
|
+
className,
|
|
52
|
+
]
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.join(" ");
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<span
|
|
58
|
+
className={classNames}
|
|
59
|
+
role="status"
|
|
60
|
+
aria-label={ariaLabel || `${variant} status`}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
@use "../../styles/typography" as *;
|
|
2
|
+
|
|
3
|
+
.uds-dot-status {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
border-radius: 50%;
|
|
6
|
+
flex-shrink: 0;
|
|
7
|
+
vertical-align: middle;
|
|
8
|
+
|
|
9
|
+
// Size variants
|
|
10
|
+
&--small {
|
|
11
|
+
width: 8px;
|
|
12
|
+
height: 8px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&--medium {
|
|
16
|
+
width: 12px;
|
|
17
|
+
height: 12px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&--large {
|
|
21
|
+
width: 16px;
|
|
22
|
+
height: 16px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Variant colors
|
|
26
|
+
&--light-gray {
|
|
27
|
+
background-color: #f3f4f6; // Very light gray
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&--red {
|
|
31
|
+
background-color: #ef4444; // Bright red
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&--orange {
|
|
35
|
+
background-color: #f97316; // Bright orange
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&--yellow {
|
|
39
|
+
background-color: #eab308; // Bright yellow
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&--light-green {
|
|
43
|
+
background-color: #84cc16; // Light green (lime)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&--green {
|
|
47
|
+
background-color: #22c55e; // Darker green
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&--blue {
|
|
51
|
+
background-color: #3b82f6; // Medium blue
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&--dark-blue {
|
|
55
|
+
background-color: #2563eb; // Dark blue
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&--teal {
|
|
59
|
+
background-color: #14b8a6; // Teal/Cyan
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&--purple {
|
|
63
|
+
background-color: #a855f7; // Medium purple
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&--pink {
|
|
67
|
+
background-color: #ec4899; // Bright pink
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&--magenta {
|
|
71
|
+
background-color: #d946ef; // Darker pink/magenta
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&--dark-red {
|
|
75
|
+
background-color: #dc2626; // Dark red/maroon
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&--dark-gray {
|
|
79
|
+
background-color: #1f2937; // Dark gray (almost black)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Outline variant
|
|
83
|
+
&--outline {
|
|
84
|
+
border: var(--uds-border-width-1) solid var(--uds-border-inverse); // Light gray border/ring
|
|
85
|
+
// Background colors remain the same as defined above
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./DotStatus";
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
|
+
import Icon from "../Icon/Icon";
|
|
3
|
+
import "./Dropdown.scss";
|
|
4
|
+
|
|
5
|
+
const BASE_CLASS = "uds-dropdown";
|
|
6
|
+
|
|
7
|
+
const stateClassMap = {
|
|
8
|
+
default: "default",
|
|
9
|
+
focused: "focused",
|
|
10
|
+
error: "error",
|
|
11
|
+
disabled: "disabled",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Dropdown component for custom select inputs
|
|
16
|
+
* @param {array} options - Array of option objects with { value, label } or array of strings
|
|
17
|
+
* @param {string|number} value - Currently selected value
|
|
18
|
+
* @param {function} onChange - Callback when selection changes (receives new value)
|
|
19
|
+
* @param {string} placeholder - Placeholder text when no option is selected
|
|
20
|
+
* @param {string} state - Visual state: 'default', 'focused', 'error', 'disabled'
|
|
21
|
+
* @param {string} id - Unique identifier for the dropdown
|
|
22
|
+
* @param {string} label - Label text for the dropdown
|
|
23
|
+
* @param {string} className - Additional CSS classes
|
|
24
|
+
* @param {object} props - Additional props to pass to the dropdown
|
|
25
|
+
*/
|
|
26
|
+
export default function Dropdown({
|
|
27
|
+
options = [],
|
|
28
|
+
value,
|
|
29
|
+
onChange,
|
|
30
|
+
placeholder = "Select an option",
|
|
31
|
+
state = "default",
|
|
32
|
+
id,
|
|
33
|
+
label,
|
|
34
|
+
className = "",
|
|
35
|
+
disabled = false,
|
|
36
|
+
...props
|
|
37
|
+
}) {
|
|
38
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
39
|
+
const [focused, setFocused] = useState(false);
|
|
40
|
+
const dropdownRef = useRef(null);
|
|
41
|
+
const listRef = useRef(null);
|
|
42
|
+
|
|
43
|
+
const dropdownId =
|
|
44
|
+
id || `dropdown-${Math.random().toString(36).substr(2, 9)}`;
|
|
45
|
+
|
|
46
|
+
// Normalize options to always have { value, label } format
|
|
47
|
+
const normalizedOptions = options.map((option) => {
|
|
48
|
+
if (typeof option === "string") {
|
|
49
|
+
return { value: option, label: option };
|
|
50
|
+
}
|
|
51
|
+
return option;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Determine the current state
|
|
55
|
+
const currentState = disabled
|
|
56
|
+
? "disabled"
|
|
57
|
+
: state === "default" && focused
|
|
58
|
+
? "focused"
|
|
59
|
+
: state;
|
|
60
|
+
|
|
61
|
+
// Get the selected option's label
|
|
62
|
+
const selectedOption = normalizedOptions.find((opt) => opt.value === value);
|
|
63
|
+
const displayValue = selectedOption ? selectedOption.label : placeholder;
|
|
64
|
+
|
|
65
|
+
// Close dropdown when clicking outside
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const handleClickOutside = (event) => {
|
|
68
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
69
|
+
setIsOpen(false);
|
|
70
|
+
setFocused(false);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (isOpen) {
|
|
75
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
80
|
+
};
|
|
81
|
+
}, [isOpen]);
|
|
82
|
+
|
|
83
|
+
// Handle keyboard navigation
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!isOpen) return;
|
|
86
|
+
|
|
87
|
+
const handleKeyDown = (event) => {
|
|
88
|
+
if (event.key === "Escape") {
|
|
89
|
+
setIsOpen(false);
|
|
90
|
+
setFocused(false);
|
|
91
|
+
} else if (event.key === "ArrowDown") {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
const currentIndex = normalizedOptions.findIndex(
|
|
94
|
+
(opt) => opt.value === value,
|
|
95
|
+
);
|
|
96
|
+
const nextIndex =
|
|
97
|
+
currentIndex < normalizedOptions.length - 1 ? currentIndex + 1 : 0;
|
|
98
|
+
if (onChange && !disabled) {
|
|
99
|
+
onChange(normalizedOptions[nextIndex].value);
|
|
100
|
+
}
|
|
101
|
+
} else if (event.key === "ArrowUp") {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
const currentIndex = normalizedOptions.findIndex(
|
|
104
|
+
(opt) => opt.value === value,
|
|
105
|
+
);
|
|
106
|
+
const prevIndex =
|
|
107
|
+
currentIndex > 0 ? currentIndex - 1 : normalizedOptions.length - 1;
|
|
108
|
+
if (onChange && !disabled) {
|
|
109
|
+
onChange(normalizedOptions[prevIndex].value);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
115
|
+
return () => {
|
|
116
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
117
|
+
};
|
|
118
|
+
}, [isOpen, value, normalizedOptions, onChange, disabled]);
|
|
119
|
+
|
|
120
|
+
const handleToggle = () => {
|
|
121
|
+
if (!disabled) {
|
|
122
|
+
setIsOpen(!isOpen);
|
|
123
|
+
setFocused(!isOpen);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const handleSelect = (optionValue) => {
|
|
128
|
+
if (onChange && !disabled) {
|
|
129
|
+
onChange(optionValue);
|
|
130
|
+
setIsOpen(false);
|
|
131
|
+
setFocused(false);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const classNames = [
|
|
136
|
+
BASE_CLASS,
|
|
137
|
+
stateClassMap[currentState] &&
|
|
138
|
+
`${BASE_CLASS}--${stateClassMap[currentState]}`,
|
|
139
|
+
isOpen && `${BASE_CLASS}--open`,
|
|
140
|
+
className,
|
|
141
|
+
]
|
|
142
|
+
.filter(Boolean)
|
|
143
|
+
.join(" ");
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div className={`${BASE_CLASS}-wrapper`}>
|
|
147
|
+
{label && (
|
|
148
|
+
<label htmlFor={dropdownId} className={`${BASE_CLASS}__label`}>
|
|
149
|
+
{label}
|
|
150
|
+
</label>
|
|
151
|
+
)}
|
|
152
|
+
<div className={classNames} ref={dropdownRef}>
|
|
153
|
+
<button
|
|
154
|
+
type="button"
|
|
155
|
+
id={dropdownId}
|
|
156
|
+
className={`${BASE_CLASS}__trigger`}
|
|
157
|
+
onClick={handleToggle}
|
|
158
|
+
onFocus={() => !disabled && setFocused(true)}
|
|
159
|
+
onBlur={() => !focused && setFocused(false)}
|
|
160
|
+
disabled={disabled}
|
|
161
|
+
aria-haspopup="listbox"
|
|
162
|
+
aria-expanded={isOpen}
|
|
163
|
+
aria-label={label || placeholder}
|
|
164
|
+
{...props}
|
|
165
|
+
>
|
|
166
|
+
<span
|
|
167
|
+
className={`${BASE_CLASS}__value ${!selectedOption ? `${BASE_CLASS}__value--placeholder` : ""}`}
|
|
168
|
+
>
|
|
169
|
+
{displayValue}
|
|
170
|
+
</span>
|
|
171
|
+
<Icon
|
|
172
|
+
name="CaretDown"
|
|
173
|
+
size={16}
|
|
174
|
+
appearance="regular"
|
|
175
|
+
className={`${BASE_CLASS}__icon ${isOpen ? `${BASE_CLASS}__icon--open` : ""}`}
|
|
176
|
+
/>
|
|
177
|
+
</button>
|
|
178
|
+
{isOpen && !disabled && (
|
|
179
|
+
<ul className={`${BASE_CLASS}__list`} role="listbox" ref={listRef}>
|
|
180
|
+
{normalizedOptions.map((option) => {
|
|
181
|
+
const isSelected = option.value === value;
|
|
182
|
+
return (
|
|
183
|
+
<li
|
|
184
|
+
key={option.value}
|
|
185
|
+
className={`${BASE_CLASS}__option ${isSelected ? `${BASE_CLASS}__option--selected` : ""}`}
|
|
186
|
+
role="option"
|
|
187
|
+
aria-selected={isSelected}
|
|
188
|
+
onClick={() => handleSelect(option.value)}
|
|
189
|
+
onMouseEnter={(e) => e.currentTarget.focus()}
|
|
190
|
+
>
|
|
191
|
+
{option.label}
|
|
192
|
+
</li>
|
|
193
|
+
);
|
|
194
|
+
})}
|
|
195
|
+
</ul>
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
@use "../../styles/typography" as *;
|
|
2
|
+
|
|
3
|
+
.uds-dropdown-wrapper {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: var(--uds-gap-8);
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.uds-dropdown {
|
|
11
|
+
position: relative;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
width: 100%;
|
|
14
|
+
|
|
15
|
+
&__label {
|
|
16
|
+
@include uds-body-14-medium;
|
|
17
|
+
color: var(--uds-text-primary);
|
|
18
|
+
display: block;
|
|
19
|
+
margin-bottom: var(--uds-gap-8);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__trigger {
|
|
23
|
+
@include uds-body-16;
|
|
24
|
+
all: unset;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: space-between;
|
|
28
|
+
width: 100%;
|
|
29
|
+
padding: var(--uds-spacing-10) var(--uds-spacing-12);
|
|
30
|
+
background-color: var(--uds-surface-primary);
|
|
31
|
+
border: var(--uds-border-width-1) solid var(--uds-border-primary);
|
|
32
|
+
border-radius: var(--uds-radius-4);
|
|
33
|
+
color: var(--uds-text-primary);
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
transition: all var(--uds-animation-duration-200) var(--uds-animation-ease-standard);
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
text-align: left;
|
|
38
|
+
|
|
39
|
+
&:focus-visible {
|
|
40
|
+
outline: solid var(--uds-focus-ring-width) var(--uds-focus-ring-border);
|
|
41
|
+
outline-offset: var(--uds-focus-ring-offset);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&__value {
|
|
46
|
+
flex: 1;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
white-space: nowrap;
|
|
50
|
+
|
|
51
|
+
&--placeholder {
|
|
52
|
+
color: var(--uds-text-secondary);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&__icon {
|
|
57
|
+
flex-shrink: 0;
|
|
58
|
+
margin-left: var(--uds-gap-8);
|
|
59
|
+
transition: transform var(--uds-animation-duration-200) var(--uds-animation-ease-standard);
|
|
60
|
+
color: var(--uds-text-secondary);
|
|
61
|
+
|
|
62
|
+
&--open {
|
|
63
|
+
transform: rotate(180deg);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// State variants
|
|
68
|
+
&--default {
|
|
69
|
+
.uds-dropdown__trigger {
|
|
70
|
+
background-color: var(--uds-surface-primary);
|
|
71
|
+
border-color: var(--uds-border-primary);
|
|
72
|
+
color: var(--uds-text-primary);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&--focused {
|
|
77
|
+
.uds-dropdown__trigger {
|
|
78
|
+
background-color: var(--uds-surface-primary);
|
|
79
|
+
border-color: var(--uds-border-brand-primary);
|
|
80
|
+
color: var(--uds-text-primary);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&--error {
|
|
85
|
+
.uds-dropdown__trigger {
|
|
86
|
+
background-color: var(--uds-surface-primary);
|
|
87
|
+
border-color: #ef4444; // Red border
|
|
88
|
+
color: #ef4444; // Red text
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.uds-dropdown__value {
|
|
92
|
+
color: #ef4444;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.uds-dropdown__icon {
|
|
96
|
+
color: #ef4444;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&--disabled {
|
|
101
|
+
.uds-dropdown__trigger {
|
|
102
|
+
background-color: var(--uds-surface-tertiary);
|
|
103
|
+
border-color: var(--uds-border-primary);
|
|
104
|
+
color: var(--uds-text-secondary);
|
|
105
|
+
cursor: not-allowed;
|
|
106
|
+
opacity: 0.6;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.uds-dropdown__value {
|
|
110
|
+
color: var(--uds-text-secondary);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.uds-dropdown__icon {
|
|
114
|
+
color: var(--uds-text-secondary);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&__list {
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: calc(100% + 4px);
|
|
121
|
+
left: 0;
|
|
122
|
+
right: 0;
|
|
123
|
+
z-index: 1000;
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding: var(--uds-spacing-4) 0;
|
|
126
|
+
background-color: var(--uds-surface-primary);
|
|
127
|
+
border: var(--uds-border-width-1) solid var(--uds-border-primary);
|
|
128
|
+
border-radius: var(--uds-radius-4);
|
|
129
|
+
box-shadow: var(--uds-shadow-lg);
|
|
130
|
+
list-style: none;
|
|
131
|
+
max-height: 300px;
|
|
132
|
+
overflow-y: auto;
|
|
133
|
+
box-sizing: border-box;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&__option {
|
|
137
|
+
@include uds-body-16;
|
|
138
|
+
padding: var(--uds-spacing-10) var(--uds-spacing-12);
|
|
139
|
+
color: var(--uds-text-primary);
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
transition: background-color var(--uds-animation-duration-200)
|
|
142
|
+
var(--uds-animation-ease-standard);
|
|
143
|
+
outline: none;
|
|
144
|
+
|
|
145
|
+
&:hover,
|
|
146
|
+
&:focus {
|
|
147
|
+
background-color: var(--uds-surface-tertiary);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&--selected {
|
|
151
|
+
background-color: var(--uds-surface-brand-secondary);
|
|
152
|
+
color: var(--uds-text-brand-primary);
|
|
153
|
+
font-weight: 600;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Dropdown";
|