@soadtech/cli 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/dist/index.js +272 -0
- package/package.json +24 -0
- package/registry/base/cn.ts +5 -0
- package/registry/base/css-modules.d.ts +4 -0
- package/registry/base/theme/reset.css +43 -0
- package/registry/base/theme/tokens.css +154 -0
- package/registry/components/Accordion/Accordion.module.css +3 -0
- package/registry/components/Accordion/Accordion.tsx +54 -0
- package/registry/components/Accordion/Accordion.types.ts +17 -0
- package/registry/components/Accordion/AccordionContext.ts +18 -0
- package/registry/components/Accordion/AccordionItem.module.css +124 -0
- package/registry/components/Accordion/AccordionItem.tsx +148 -0
- package/registry/components/Accordion/AccordionItem.types.ts +14 -0
- package/registry/components/Accordion/index.ts +8 -0
- package/registry/components/ActionBar/ActionBar.module.css +18 -0
- package/registry/components/ActionBar/ActionBar.tsx +21 -0
- package/registry/components/ActionBar/ActionBar.types.ts +8 -0
- package/registry/components/ActionBar/ActionBarLink.module.css +31 -0
- package/registry/components/ActionBar/ActionBarLink.tsx +55 -0
- package/registry/components/ActionBar/ActionBarLink.types.ts +7 -0
- package/registry/components/ActionBar/index.ts +4 -0
- package/registry/components/Alert/Alert.module.css +172 -0
- package/registry/components/Alert/Alert.tsx +146 -0
- package/registry/components/Alert/Alert.types.ts +25 -0
- package/registry/components/Alert/index.ts +7 -0
- package/registry/components/Avatar/Avatar.module.css +100 -0
- package/registry/components/Avatar/Avatar.tsx +54 -0
- package/registry/components/Avatar/Avatar.types.ts +18 -0
- package/registry/components/Avatar/AvatarGroup.module.css +64 -0
- package/registry/components/Avatar/AvatarGroup.tsx +65 -0
- package/registry/components/Avatar/AvatarGroup.types.ts +13 -0
- package/registry/components/Avatar/index.ts +8 -0
- package/registry/components/Badge/Badge.module.css +92 -0
- package/registry/components/Badge/Badge.tsx +89 -0
- package/registry/components/Badge/Badge.types.ts +20 -0
- package/registry/components/Badge/TrendBadge.module.css +47 -0
- package/registry/components/Badge/TrendBadge.tsx +65 -0
- package/registry/components/Badge/TrendBadge.types.ts +15 -0
- package/registry/components/Badge/index.ts +14 -0
- package/registry/components/Breadcrumbs/BreadcrumbItem.tsx +41 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.module.css +81 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.tsx +71 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.types.ts +22 -0
- package/registry/components/Breadcrumbs/index.ts +7 -0
- package/registry/components/Button/Button.module.css +169 -0
- package/registry/components/Button/Button.tsx +43 -0
- package/registry/components/Button/Button.types.ts +18 -0
- package/registry/components/Button/index.ts +7 -0
- package/registry/components/ButtonLink/ButtonLink.module.css +85 -0
- package/registry/components/ButtonLink/ButtonLink.tsx +42 -0
- package/registry/components/ButtonLink/ButtonLink.types.ts +18 -0
- package/registry/components/ButtonLink/index.ts +6 -0
- package/registry/components/Calendar/Calendar.module.css +213 -0
- package/registry/components/Calendar/Calendar.tsx +370 -0
- package/registry/components/Calendar/Calendar.types.ts +28 -0
- package/registry/components/Calendar/CalendarDialog.module.css +29 -0
- package/registry/components/Calendar/CalendarDialog.tsx +173 -0
- package/registry/components/Calendar/CalendarDialog.types.ts +30 -0
- package/registry/components/Calendar/index.ts +9 -0
- package/registry/components/Card/Card.module.css +35 -0
- package/registry/components/Card/Card.tsx +36 -0
- package/registry/components/Card/Card.types.ts +37 -0
- package/registry/components/Card/CardContent.module.css +3 -0
- package/registry/components/Card/CardContent.tsx +16 -0
- package/registry/components/Card/CardFooter.module.css +31 -0
- package/registry/components/Card/CardFooter.tsx +34 -0
- package/registry/components/Card/CardHeader.module.css +61 -0
- package/registry/components/Card/CardHeader.tsx +46 -0
- package/registry/components/Card/InsightCard.module.css +106 -0
- package/registry/components/Card/InsightCard.tsx +68 -0
- package/registry/components/Card/InsightCard.types.ts +24 -0
- package/registry/components/Card/KPICard.module.css +31 -0
- package/registry/components/Card/KPICard.tsx +29 -0
- package/registry/components/Card/KPICard.types.ts +13 -0
- package/registry/components/Card/ListItemCard.module.css +59 -0
- package/registry/components/Card/ListItemCard.tsx +37 -0
- package/registry/components/Card/ListItemCard.types.ts +18 -0
- package/registry/components/Card/PlanCard.module.css +125 -0
- package/registry/components/Card/PlanCard.tsx +108 -0
- package/registry/components/Card/PlanCard.types.ts +30 -0
- package/registry/components/Card/ProductCard.module.css +118 -0
- package/registry/components/Card/ProductCard.tsx +56 -0
- package/registry/components/Card/ProductCard.types.ts +24 -0
- package/registry/components/Card/StatCard.module.css +20 -0
- package/registry/components/Card/StatCard.tsx +26 -0
- package/registry/components/Card/StatCard.types.ts +12 -0
- package/registry/components/Card/UserGroupCard.module.css +50 -0
- package/registry/components/Card/UserGroupCard.tsx +59 -0
- package/registry/components/Card/UserGroupCard.types.ts +23 -0
- package/registry/components/Card/index.ts +38 -0
- package/registry/components/Chart/BarChart.module.css +54 -0
- package/registry/components/Chart/BarChart.tsx +196 -0
- package/registry/components/Chart/BarChart.types.ts +20 -0
- package/registry/components/Chart/ChartAction.module.css +43 -0
- package/registry/components/Chart/ChartAction.tsx +35 -0
- package/registry/components/Chart/ChartAction.types.ts +17 -0
- package/registry/components/Chart/ChartAxis.module.css +47 -0
- package/registry/components/Chart/ChartAxis.tsx +79 -0
- package/registry/components/Chart/ChartAxis.types.ts +14 -0
- package/registry/components/Chart/ChartLegend.module.css +31 -0
- package/registry/components/Chart/ChartLegend.tsx +49 -0
- package/registry/components/Chart/ChartLegend.types.ts +18 -0
- package/registry/components/Chart/ChartTooltip.module.css +54 -0
- package/registry/components/Chart/ChartTooltip.tsx +44 -0
- package/registry/components/Chart/ChartTooltip.types.ts +19 -0
- package/registry/components/Chart/DonutChart.module.css +32 -0
- package/registry/components/Chart/DonutChart.tsx +107 -0
- package/registry/components/Chart/DonutChart.types.ts +20 -0
- package/registry/components/Chart/GridChart.module.css +26 -0
- package/registry/components/Chart/GridChart.tsx +61 -0
- package/registry/components/Chart/GridChart.types.ts +14 -0
- package/registry/components/Chart/HoverTooltip.module.css +16 -0
- package/registry/components/Chart/HoverTooltip.tsx +22 -0
- package/registry/components/Chart/KPIIndicator.module.css +48 -0
- package/registry/components/Chart/KPIIndicator.tsx +28 -0
- package/registry/components/Chart/KPIIndicator.types.ts +16 -0
- package/registry/components/Chart/LineChart.module.css +54 -0
- package/registry/components/Chart/LineChart.tsx +282 -0
- package/registry/components/Chart/LineChart.types.ts +22 -0
- package/registry/components/Chart/ProgressChart.module.css +54 -0
- package/registry/components/Chart/ProgressChart.tsx +64 -0
- package/registry/components/Chart/ProgressChart.types.ts +18 -0
- package/registry/components/Chart/TrendLineChart.module.css +5 -0
- package/registry/components/Chart/TrendLineChart.tsx +131 -0
- package/registry/components/Chart/TrendLineChart.types.ts +19 -0
- package/registry/components/Chart/chart.utils.ts +131 -0
- package/registry/components/Chart/index.ts +47 -0
- package/registry/components/Chart/useChartHover.ts +24 -0
- package/registry/components/Checkbox/Checkbox.module.css +101 -0
- package/registry/components/Checkbox/Checkbox.tsx +100 -0
- package/registry/components/Checkbox/Checkbox.types.ts +11 -0
- package/registry/components/Checkbox/CheckboxField.module.css +69 -0
- package/registry/components/Checkbox/CheckboxField.tsx +54 -0
- package/registry/components/Checkbox/CheckboxField.types.ts +9 -0
- package/registry/components/Checkbox/CheckboxGroup.module.css +41 -0
- package/registry/components/Checkbox/CheckboxGroup.tsx +60 -0
- package/registry/components/Checkbox/CheckboxGroup.types.ts +11 -0
- package/registry/components/Checkbox/CheckboxGroupContext.ts +13 -0
- package/registry/components/Checkbox/index.ts +11 -0
- package/registry/components/Chip/Chip.module.css +143 -0
- package/registry/components/Chip/Chip.tsx +93 -0
- package/registry/components/Chip/Chip.types.ts +19 -0
- package/registry/components/Chip/ChipGroup.module.css +5 -0
- package/registry/components/Chip/ChipGroup.tsx +16 -0
- package/registry/components/Chip/ChipGroup.types.ts +3 -0
- package/registry/components/Chip/index.ts +9 -0
- package/registry/components/Datepicker/Datepicker.module.css +133 -0
- package/registry/components/Datepicker/Datepicker.tsx +236 -0
- package/registry/components/Datepicker/Datepicker.types.ts +36 -0
- package/registry/components/Datepicker/index.ts +2 -0
- package/registry/components/Dialog/Dialog.module.css +18 -0
- package/registry/components/Dialog/Dialog.tsx +69 -0
- package/registry/components/Dialog/Dialog.types.ts +45 -0
- package/registry/components/Dialog/DialogBody.module.css +3 -0
- package/registry/components/Dialog/DialogBody.tsx +16 -0
- package/registry/components/Dialog/DialogContext.ts +11 -0
- package/registry/components/Dialog/DialogFooter.module.css +38 -0
- package/registry/components/Dialog/DialogFooter.tsx +30 -0
- package/registry/components/Dialog/DialogHeader.module.css +70 -0
- package/registry/components/Dialog/DialogHeader.tsx +72 -0
- package/registry/components/Dialog/DialogIcon.module.css +31 -0
- package/registry/components/Dialog/DialogIcon.tsx +89 -0
- package/registry/components/Dialog/index.ts +14 -0
- package/registry/components/Divider/Divider.module.css +19 -0
- package/registry/components/Divider/Divider.tsx +20 -0
- package/registry/components/Divider/Divider.types.ts +9 -0
- package/registry/components/Divider/index.ts +2 -0
- package/registry/components/DropdownMenu/DropdownMenu.module.css +9 -0
- package/registry/components/DropdownMenu/DropdownMenu.tsx +21 -0
- package/registry/components/DropdownMenu/DropdownMenu.types.ts +22 -0
- package/registry/components/DropdownMenu/DropdownMenuDivider.module.css +5 -0
- package/registry/components/DropdownMenu/DropdownMenuDivider.tsx +20 -0
- package/registry/components/DropdownMenu/DropdownMenuHeader.module.css +7 -0
- package/registry/components/DropdownMenu/DropdownMenuHeader.tsx +17 -0
- package/registry/components/DropdownMenu/DropdownMenuItem.module.css +78 -0
- package/registry/components/DropdownMenu/DropdownMenuItem.tsx +40 -0
- package/registry/components/DropdownMenu/index.ts +10 -0
- package/registry/components/FileUpload/FileUpload.module.css +122 -0
- package/registry/components/FileUpload/FileUpload.tsx +354 -0
- package/registry/components/FileUpload/FileUpload.types.ts +89 -0
- package/registry/components/FileUpload/FileUploadIcon.module.css +61 -0
- package/registry/components/FileUpload/FileUploadIcon.tsx +84 -0
- package/registry/components/FileUpload/FileUploadInput.module.css +140 -0
- package/registry/components/FileUpload/FileUploadInput.tsx +113 -0
- package/registry/components/FileUpload/FileUploadItem.module.css +41 -0
- package/registry/components/FileUpload/FileUploadItem.tsx +39 -0
- package/registry/components/FileUpload/index.ts +12 -0
- package/registry/components/InputCounter/InputCounter.module.css +146 -0
- package/registry/components/InputCounter/InputCounter.tsx +232 -0
- package/registry/components/InputCounter/InputCounter.types.ts +37 -0
- package/registry/components/InputCounter/index.ts +7 -0
- package/registry/components/InputMessage/InputMessage.module.css +148 -0
- package/registry/components/InputMessage/InputMessage.tsx +294 -0
- package/registry/components/InputMessage/InputMessage.types.ts +30 -0
- package/registry/components/InputMessage/index.ts +2 -0
- package/registry/components/InputSearch/InputSearch.module.css +168 -0
- package/registry/components/InputSearch/InputSearch.tsx +251 -0
- package/registry/components/InputSearch/InputSearch.types.ts +35 -0
- package/registry/components/InputSearch/index.ts +6 -0
- package/registry/components/InputText/InputText.module.css +183 -0
- package/registry/components/InputText/InputText.tsx +244 -0
- package/registry/components/InputText/InputText.types.ts +32 -0
- package/registry/components/InputText/index.ts +7 -0
- package/registry/components/InputTextArea/InputTextArea.module.css +141 -0
- package/registry/components/InputTextArea/InputTextArea.tsx +170 -0
- package/registry/components/InputTextArea/InputTextArea.types.ts +18 -0
- package/registry/components/InputTextArea/index.ts +6 -0
- package/registry/components/NavbarUser/NavbarUser.module.css +265 -0
- package/registry/components/NavbarUser/NavbarUser.tsx +202 -0
- package/registry/components/NavbarUser/NavbarUser.types.ts +31 -0
- package/registry/components/NavbarUser/index.ts +2 -0
- package/registry/components/Notification/Notification.types.ts +65 -0
- package/registry/components/Notification/NotificationItem.module.css +143 -0
- package/registry/components/Notification/NotificationItem.tsx +157 -0
- package/registry/components/Notification/NotificationPanel.module.css +75 -0
- package/registry/components/Notification/NotificationPanel.tsx +68 -0
- package/registry/components/Notification/NotificationReply.module.css +56 -0
- package/registry/components/Notification/NotificationReply.tsx +52 -0
- package/registry/components/Notification/index.ts +9 -0
- package/registry/components/Pagination/Pagination.module.css +123 -0
- package/registry/components/Pagination/Pagination.tsx +212 -0
- package/registry/components/Pagination/Pagination.types.ts +24 -0
- package/registry/components/Pagination/PaginationDots.module.css +60 -0
- package/registry/components/Pagination/PaginationDots.tsx +48 -0
- package/registry/components/Pagination/PaginationDots.types.ts +17 -0
- package/registry/components/Pagination/index.ts +12 -0
- package/registry/components/Persona/MessageDropdown.module.css +76 -0
- package/registry/components/Persona/MessageDropdown.tsx +68 -0
- package/registry/components/Persona/Persona.module.css +92 -0
- package/registry/components/Persona/Persona.tsx +90 -0
- package/registry/components/Persona/Persona.types.ts +71 -0
- package/registry/components/Persona/PersonaAction.module.css +80 -0
- package/registry/components/Persona/PersonaAction.tsx +49 -0
- package/registry/components/Persona/PersonaMessage.module.css +156 -0
- package/registry/components/Persona/PersonaMessage.tsx +70 -0
- package/registry/components/Persona/index.ts +11 -0
- package/registry/components/Progress/Progress.module.css +41 -0
- package/registry/components/Progress/Progress.tsx +43 -0
- package/registry/components/Progress/Progress.types.ts +10 -0
- package/registry/components/Progress/index.ts +2 -0
- package/registry/components/RadioButton/RadioButton.module.css +103 -0
- package/registry/components/RadioButton/RadioButton.tsx +59 -0
- package/registry/components/RadioButton/RadioButton.types.ts +19 -0
- package/registry/components/RadioButton/RadioField.module.css +68 -0
- package/registry/components/RadioButton/RadioField.tsx +68 -0
- package/registry/components/RadioButton/RadioGroup.module.css +41 -0
- package/registry/components/RadioButton/RadioGroup.tsx +76 -0
- package/registry/components/RadioButton/RadioGroupContext.ts +16 -0
- package/registry/components/RadioButton/index.ts +12 -0
- package/registry/components/RangeSlider/RangeSlider.module.css +133 -0
- package/registry/components/RangeSlider/RangeSlider.tsx +251 -0
- package/registry/components/RangeSlider/RangeSlider.types.ts +25 -0
- package/registry/components/RangeSlider/index.ts +2 -0
- package/registry/components/Rating/Rating.module.css +56 -0
- package/registry/components/Rating/Rating.tsx +142 -0
- package/registry/components/Rating/Rating.types.ts +14 -0
- package/registry/components/Rating/index.ts +7 -0
- package/registry/components/SegmentedControl/SegmentedControl.module.css +56 -0
- package/registry/components/SegmentedControl/SegmentedControl.tsx +46 -0
- package/registry/components/SegmentedControl/SegmentedControl.types.ts +27 -0
- package/registry/components/SegmentedControl/SegmentedControlContext.ts +20 -0
- package/registry/components/SegmentedControl/SegmentedControlItem.module.css +55 -0
- package/registry/components/SegmentedControl/SegmentedControlItem.tsx +32 -0
- package/registry/components/SegmentedControl/index.ts +8 -0
- package/registry/components/SelectDropdown/SelectDropdown.module.css +214 -0
- package/registry/components/SelectDropdown/SelectDropdown.tsx +375 -0
- package/registry/components/SelectDropdown/SelectDropdown.types.ts +50 -0
- package/registry/components/SelectDropdown/SelectDropdownOption.module.css +101 -0
- package/registry/components/SelectDropdown/SelectDropdownOption.tsx +86 -0
- package/registry/components/SelectDropdown/SelectDropdownOverlay.module.css +74 -0
- package/registry/components/SelectDropdown/SelectDropdownOverlay.tsx +202 -0
- package/registry/components/SelectDropdown/index.ts +11 -0
- package/registry/components/Sidebar/Sidebar.module.css +14 -0
- package/registry/components/Sidebar/Sidebar.tsx +41 -0
- package/registry/components/Sidebar/Sidebar.types.ts +41 -0
- package/registry/components/Sidebar/SidebarContent.module.css +5 -0
- package/registry/components/Sidebar/SidebarContent.tsx +14 -0
- package/registry/components/Sidebar/SidebarContext.ts +15 -0
- package/registry/components/Sidebar/SidebarDivider.module.css +5 -0
- package/registry/components/Sidebar/SidebarDivider.tsx +17 -0
- package/registry/components/Sidebar/SidebarFooter.module.css +5 -0
- package/registry/components/Sidebar/SidebarFooter.tsx +14 -0
- package/registry/components/Sidebar/SidebarGroup.module.css +12 -0
- package/registry/components/Sidebar/SidebarGroup.tsx +22 -0
- package/registry/components/Sidebar/SidebarHeader.module.css +5 -0
- package/registry/components/Sidebar/SidebarHeader.tsx +14 -0
- package/registry/components/Sidebar/SidebarNavItem.module.css +176 -0
- package/registry/components/Sidebar/SidebarNavItem.tsx +96 -0
- package/registry/components/Sidebar/index.ts +16 -0
- package/registry/components/Stepper/Stepper.module.css +11 -0
- package/registry/components/Stepper/Stepper.tsx +47 -0
- package/registry/components/Stepper/Stepper.types.ts +26 -0
- package/registry/components/Stepper/StepperContext.ts +17 -0
- package/registry/components/Stepper/StepperStep.module.css +183 -0
- package/registry/components/Stepper/StepperStep.tsx +204 -0
- package/registry/components/Stepper/index.ts +9 -0
- package/registry/components/Switch/Switch.module.css +145 -0
- package/registry/components/Switch/Switch.tsx +96 -0
- package/registry/components/Switch/Switch.types.ts +19 -0
- package/registry/components/Switch/SwitchField.module.css +69 -0
- package/registry/components/Switch/SwitchField.tsx +49 -0
- package/registry/components/Switch/index.ts +8 -0
- package/registry/components/Tab/Tab.module.css +20 -0
- package/registry/components/Tab/Tab.tsx +35 -0
- package/registry/components/Tab/Tab.types.ts +21 -0
- package/registry/components/Tab/TabAdd.module.css +36 -0
- package/registry/components/Tab/TabAdd.tsx +41 -0
- package/registry/components/Tab/TabContext.ts +19 -0
- package/registry/components/Tab/TabItem.module.css +145 -0
- package/registry/components/Tab/TabItem.tsx +87 -0
- package/registry/components/Tab/index.ts +9 -0
- package/registry/components/Table/Table.module.css +33 -0
- package/registry/components/Table/Table.tsx +74 -0
- package/registry/components/Table/Table.types.ts +64 -0
- package/registry/components/Table/TableBody.tsx +23 -0
- package/registry/components/Table/TableCell.module.css +21 -0
- package/registry/components/Table/TableCell.tsx +20 -0
- package/registry/components/Table/TableContext.ts +22 -0
- package/registry/components/Table/TableFooter.module.css +27 -0
- package/registry/components/Table/TableFooter.tsx +20 -0
- package/registry/components/Table/TableHeader.module.css +3 -0
- package/registry/components/Table/TableHeader.tsx +17 -0
- package/registry/components/Table/TableHeaderCell.module.css +55 -0
- package/registry/components/Table/TableHeaderCell.tsx +98 -0
- package/registry/components/Table/TableRow.module.css +53 -0
- package/registry/components/Table/TableRow.tsx +31 -0
- package/registry/components/Table/TableToolbar.module.css +7 -0
- package/registry/components/Table/TableToolbar.tsx +16 -0
- package/registry/components/Table/index.ts +22 -0
- package/registry/components/Tag/Tag.module.css +46 -0
- package/registry/components/Tag/Tag.tsx +38 -0
- package/registry/components/Tag/Tag.types.ts +37 -0
- package/registry/components/Tag/TagBrand.module.css +42 -0
- package/registry/components/Tag/TagBrand.tsx +38 -0
- package/registry/components/Tag/TagStatus.module.css +43 -0
- package/registry/components/Tag/TagStatus.tsx +119 -0
- package/registry/components/Tag/index.ts +15 -0
- package/registry/components/Tooltip/Tooltip.module.css +208 -0
- package/registry/components/Tooltip/Tooltip.tsx +81 -0
- package/registry/components/Tooltip/Tooltip.types.ts +27 -0
- package/registry/components/Tooltip/index.ts +7 -0
- package/registry/components/TreeviewList/TreeviewItem.module.css +89 -0
- package/registry/components/TreeviewList/TreeviewItem.tsx +142 -0
- package/registry/components/TreeviewList/TreeviewList.module.css +3 -0
- package/registry/components/TreeviewList/TreeviewList.tsx +19 -0
- package/registry/components/TreeviewList/TreeviewList.types.ts +18 -0
- package/registry/components/TreeviewList/TreeviewListContext.ts +13 -0
- package/registry/components/TreeviewList/index.ts +6 -0
- package/registry/components/VerificationCode/VerificationCode.module.css +49 -0
- package/registry/components/VerificationCode/VerificationCode.tsx +147 -0
- package/registry/components/VerificationCode/VerificationCode.types.ts +21 -0
- package/registry/components/VerificationCode/index.ts +2 -0
- package/registry/registry.json +746 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* ═══ RangeSlider ═══ */
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: var(--st-space-1);
|
|
7
|
+
font-family: var(--st-font-family);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* ─── Label ─── */
|
|
11
|
+
|
|
12
|
+
.label {
|
|
13
|
+
font-size: var(--st-font-size-sm);
|
|
14
|
+
font-weight: var(--st-font-weight-semibold);
|
|
15
|
+
color: var(--st-color-foreground);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ─── Slider row ─── */
|
|
19
|
+
|
|
20
|
+
.sliderRow {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: var(--st-space-3);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sliderWrap {
|
|
27
|
+
flex: 1;
|
|
28
|
+
min-width: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ─── Track container ─── */
|
|
32
|
+
|
|
33
|
+
.sliderContainer {
|
|
34
|
+
position: relative;
|
|
35
|
+
height: 20px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* ─── Track ─── */
|
|
40
|
+
|
|
41
|
+
.track {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 50%;
|
|
44
|
+
left: 0;
|
|
45
|
+
right: 0;
|
|
46
|
+
height: 6px;
|
|
47
|
+
transform: translateY(-50%);
|
|
48
|
+
border-radius: var(--st-radius-full);
|
|
49
|
+
background-color: var(--st-color-neutral-200);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* ─── Fill ─── */
|
|
53
|
+
|
|
54
|
+
.fill {
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: 50%;
|
|
57
|
+
height: 6px;
|
|
58
|
+
transform: translateY(-50%);
|
|
59
|
+
border-radius: var(--st-radius-full);
|
|
60
|
+
background-color: var(--st-color-primary);
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* ─── Thumb ─── */
|
|
65
|
+
|
|
66
|
+
.thumb {
|
|
67
|
+
position: absolute;
|
|
68
|
+
top: 50%;
|
|
69
|
+
width: 18px;
|
|
70
|
+
height: 18px;
|
|
71
|
+
border-radius: var(--st-radius-full);
|
|
72
|
+
background-color: var(--st-color-surface);
|
|
73
|
+
border: 2px solid var(--st-color-neutral-300);
|
|
74
|
+
box-shadow: var(--st-shadow-sm);
|
|
75
|
+
transform: translate(-50%, -50%);
|
|
76
|
+
cursor: grab;
|
|
77
|
+
z-index: 1;
|
|
78
|
+
transition: border-color var(--st-transition-fast),
|
|
79
|
+
box-shadow var(--st-transition-fast);
|
|
80
|
+
touch-action: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.thumb:hover {
|
|
84
|
+
border-color: var(--st-color-primary);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.thumb:focus-visible {
|
|
88
|
+
outline: 2px solid var(--st-color-primary);
|
|
89
|
+
outline-offset: 2px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.thumbActive {
|
|
93
|
+
cursor: grabbing;
|
|
94
|
+
border-color: var(--st-color-primary);
|
|
95
|
+
box-shadow: var(--st-shadow-md);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* ─── Value input (single mode) ─── */
|
|
99
|
+
|
|
100
|
+
.valueInput {
|
|
101
|
+
width: 64px;
|
|
102
|
+
height: 36px;
|
|
103
|
+
padding: 0 var(--st-space-2);
|
|
104
|
+
border: 1px solid var(--st-color-border);
|
|
105
|
+
border-radius: var(--st-radius-md);
|
|
106
|
+
font-family: var(--st-font-family);
|
|
107
|
+
font-size: var(--st-font-size-sm);
|
|
108
|
+
text-align: center;
|
|
109
|
+
color: var(--st-color-foreground);
|
|
110
|
+
background-color: var(--st-color-surface);
|
|
111
|
+
outline: none;
|
|
112
|
+
transition: border-color var(--st-transition-fast);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.valueInput:focus {
|
|
116
|
+
border-color: var(--st-color-primary);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* ─── Value labels (range mode) ─── */
|
|
120
|
+
|
|
121
|
+
.valueLabels {
|
|
122
|
+
position: relative;
|
|
123
|
+
height: 20px;
|
|
124
|
+
margin-top: var(--st-space-1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.valueLabel {
|
|
128
|
+
position: absolute;
|
|
129
|
+
transform: translateX(-50%);
|
|
130
|
+
font-size: var(--st-font-size-xs);
|
|
131
|
+
color: var(--st-color-muted);
|
|
132
|
+
white-space: nowrap;
|
|
133
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { forwardRef, useRef, useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { RangeSliderProps } from './RangeSlider.types';
|
|
4
|
+
import styles from './RangeSlider.module.css';
|
|
5
|
+
|
|
6
|
+
function clamp(val: number, lo: number, hi: number) {
|
|
7
|
+
return Math.max(lo, Math.min(hi, val));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function snap(val: number, min: number, step: number) {
|
|
11
|
+
return Math.round((val - min) / step) * step + min;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const RangeSlider = forwardRef<HTMLDivElement, RangeSliderProps>(
|
|
15
|
+
(
|
|
16
|
+
{
|
|
17
|
+
label,
|
|
18
|
+
min = 0,
|
|
19
|
+
max = 100,
|
|
20
|
+
step = 1,
|
|
21
|
+
value = 0,
|
|
22
|
+
onValueChange,
|
|
23
|
+
rangeValue,
|
|
24
|
+
onRangeChange,
|
|
25
|
+
showInput = false,
|
|
26
|
+
suffix = '',
|
|
27
|
+
className,
|
|
28
|
+
...rest
|
|
29
|
+
},
|
|
30
|
+
ref
|
|
31
|
+
) => {
|
|
32
|
+
const trackRef = useRef<HTMLDivElement>(null);
|
|
33
|
+
const [dragging, setDragging] = useState<number | null>(null);
|
|
34
|
+
const [inputText, setInputText] = useState(String(value));
|
|
35
|
+
const [inputFocused, setInputFocused] = useState(false);
|
|
36
|
+
|
|
37
|
+
const isRange = rangeValue !== undefined;
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!inputFocused) {
|
|
41
|
+
setInputText(String(value));
|
|
42
|
+
}
|
|
43
|
+
}, [value, inputFocused]);
|
|
44
|
+
|
|
45
|
+
const toPercent = useCallback(
|
|
46
|
+
(val: number) => ((val - min) / (max - min)) * 100,
|
|
47
|
+
[min, max]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const fromClientX = useCallback(
|
|
51
|
+
(clientX: number) => {
|
|
52
|
+
const el = trackRef.current;
|
|
53
|
+
if (!el) return min;
|
|
54
|
+
const rect = el.getBoundingClientRect();
|
|
55
|
+
const ratio = clamp((clientX - rect.left) / rect.width, 0, 1);
|
|
56
|
+
const raw = min + ratio * (max - min);
|
|
57
|
+
return clamp(snap(raw, min, step), min, max);
|
|
58
|
+
},
|
|
59
|
+
[min, max, step]
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
/* ─── Pointer handlers ─── */
|
|
63
|
+
|
|
64
|
+
const handlePointerDown =
|
|
65
|
+
(index: number) => (e: React.PointerEvent) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
(e.target as HTMLElement).setPointerCapture(e.pointerId);
|
|
68
|
+
setDragging(index);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handlePointerMove =
|
|
72
|
+
(index: number) => (e: React.PointerEvent) => {
|
|
73
|
+
if (dragging !== index) return;
|
|
74
|
+
const val = fromClientX(e.clientX);
|
|
75
|
+
|
|
76
|
+
if (isRange && rangeValue && onRangeChange) {
|
|
77
|
+
const next: [number, number] = [rangeValue[0], rangeValue[1]];
|
|
78
|
+
next[index] = val;
|
|
79
|
+
if (next[0] > next[1]) {
|
|
80
|
+
if (index === 0) next[0] = next[1];
|
|
81
|
+
else next[1] = next[0];
|
|
82
|
+
}
|
|
83
|
+
onRangeChange(next);
|
|
84
|
+
} else if (!isRange) {
|
|
85
|
+
onValueChange?.(val);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const handlePointerUp = () => setDragging(null);
|
|
90
|
+
|
|
91
|
+
const handleTrackClick = (e: React.MouseEvent) => {
|
|
92
|
+
if ((e.target as HTMLElement).closest('[role="slider"]')) return;
|
|
93
|
+
const val = fromClientX(e.clientX);
|
|
94
|
+
|
|
95
|
+
if (isRange && rangeValue && onRangeChange) {
|
|
96
|
+
const d0 = Math.abs(val - rangeValue[0]);
|
|
97
|
+
const d1 = Math.abs(val - rangeValue[1]);
|
|
98
|
+
const next: [number, number] = [rangeValue[0], rangeValue[1]];
|
|
99
|
+
if (d0 <= d1) next[0] = val;
|
|
100
|
+
else next[1] = val;
|
|
101
|
+
if (next[0] > next[1])
|
|
102
|
+
[next[0], next[1]] = [next[1], next[0]];
|
|
103
|
+
onRangeChange(next);
|
|
104
|
+
} else if (!isRange) {
|
|
105
|
+
onValueChange?.(val);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/* ─── Keyboard handler ─── */
|
|
110
|
+
|
|
111
|
+
const handleKeyDown =
|
|
112
|
+
(index: number) => (e: React.KeyboardEvent) => {
|
|
113
|
+
let delta = 0;
|
|
114
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowUp') delta = step;
|
|
115
|
+
else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown')
|
|
116
|
+
delta = -step;
|
|
117
|
+
else return;
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
|
|
120
|
+
if (isRange && rangeValue && onRangeChange) {
|
|
121
|
+
const next: [number, number] = [rangeValue[0], rangeValue[1]];
|
|
122
|
+
next[index] = clamp(next[index] + delta, min, max);
|
|
123
|
+
if (next[0] > next[1]) return;
|
|
124
|
+
onRangeChange(next);
|
|
125
|
+
} else if (!isRange) {
|
|
126
|
+
onValueChange?.(clamp(value + delta, min, max));
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/* ─── Input handlers ─── */
|
|
131
|
+
|
|
132
|
+
const handleInputFocus = () => {
|
|
133
|
+
setInputFocused(true);
|
|
134
|
+
setInputText(String(value));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const handleInputBlur = () => {
|
|
138
|
+
setInputFocused(false);
|
|
139
|
+
const parsed = parseFloat(inputText);
|
|
140
|
+
if (!isNaN(parsed)) {
|
|
141
|
+
onValueChange?.(clamp(snap(parsed, min, step), min, max));
|
|
142
|
+
} else {
|
|
143
|
+
setInputText(String(value));
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const handleInputKeyDown = (e: React.KeyboardEvent) => {
|
|
148
|
+
if (e.key === 'Enter') (e.target as HTMLInputElement).blur();
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/* ─── Computed positions ─── */
|
|
152
|
+
|
|
153
|
+
const singlePct = isRange ? 0 : toPercent(value);
|
|
154
|
+
const rangePcts = isRange
|
|
155
|
+
? [toPercent(rangeValue![0]), toPercent(rangeValue![1])]
|
|
156
|
+
: [0, 0];
|
|
157
|
+
|
|
158
|
+
/* ─── Render ─── */
|
|
159
|
+
|
|
160
|
+
const renderThumb = (pct: number, index: number, ariaVal: number, ariaLabel?: string) => (
|
|
161
|
+
<div
|
|
162
|
+
key={index}
|
|
163
|
+
className={cn(styles.thumb, dragging === index && styles.thumbActive)}
|
|
164
|
+
style={{ left: `${pct}%` }}
|
|
165
|
+
role="slider"
|
|
166
|
+
tabIndex={0}
|
|
167
|
+
aria-valuemin={min}
|
|
168
|
+
aria-valuemax={max}
|
|
169
|
+
aria-valuenow={ariaVal}
|
|
170
|
+
aria-label={ariaLabel}
|
|
171
|
+
onPointerDown={handlePointerDown(index)}
|
|
172
|
+
onPointerMove={handlePointerMove(index)}
|
|
173
|
+
onPointerUp={handlePointerUp}
|
|
174
|
+
onKeyDown={handleKeyDown(index)}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<div ref={ref} className={cn(styles.root, className)} {...rest}>
|
|
180
|
+
{label && <span className={styles.label}>{label}</span>}
|
|
181
|
+
|
|
182
|
+
<div className={styles.sliderRow}>
|
|
183
|
+
<div className={styles.sliderWrap}>
|
|
184
|
+
<div
|
|
185
|
+
className={styles.sliderContainer}
|
|
186
|
+
ref={trackRef}
|
|
187
|
+
onClick={handleTrackClick}
|
|
188
|
+
>
|
|
189
|
+
<div className={styles.track} />
|
|
190
|
+
|
|
191
|
+
{isRange ? (
|
|
192
|
+
<div
|
|
193
|
+
className={styles.fill}
|
|
194
|
+
style={{
|
|
195
|
+
left: `${rangePcts[0]}%`,
|
|
196
|
+
width: `${rangePcts[1] - rangePcts[0]}%`,
|
|
197
|
+
}}
|
|
198
|
+
/>
|
|
199
|
+
) : (
|
|
200
|
+
<div
|
|
201
|
+
className={styles.fill}
|
|
202
|
+
style={{ left: 0, width: `${singlePct}%` }}
|
|
203
|
+
/>
|
|
204
|
+
)}
|
|
205
|
+
|
|
206
|
+
{isRange
|
|
207
|
+
? [
|
|
208
|
+
renderThumb(rangePcts[0], 0, rangeValue![0], `${label} minimum`),
|
|
209
|
+
renderThumb(rangePcts[1], 1, rangeValue![1], `${label} maximum`),
|
|
210
|
+
]
|
|
211
|
+
: renderThumb(singlePct, 0, value, label)}
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
{isRange && rangeValue && (
|
|
215
|
+
<div className={styles.valueLabels}>
|
|
216
|
+
<span
|
|
217
|
+
className={styles.valueLabel}
|
|
218
|
+
style={{ left: `${rangePcts[0]}%` }}
|
|
219
|
+
>
|
|
220
|
+
{rangeValue[0]}
|
|
221
|
+
</span>
|
|
222
|
+
<span
|
|
223
|
+
className={styles.valueLabel}
|
|
224
|
+
style={{ left: `${rangePcts[1]}%` }}
|
|
225
|
+
>
|
|
226
|
+
{rangeValue[1]}
|
|
227
|
+
</span>
|
|
228
|
+
</div>
|
|
229
|
+
)}
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
{!isRange && showInput && (
|
|
233
|
+
<input
|
|
234
|
+
type="text"
|
|
235
|
+
className={styles.valueInput}
|
|
236
|
+
value={inputFocused ? inputText : `${value}${suffix}`}
|
|
237
|
+
onChange={(e) =>
|
|
238
|
+
setInputText(e.target.value.replace(suffix, ''))
|
|
239
|
+
}
|
|
240
|
+
onFocus={handleInputFocus}
|
|
241
|
+
onBlur={handleInputBlur}
|
|
242
|
+
onKeyDown={handleInputKeyDown}
|
|
243
|
+
/>
|
|
244
|
+
)}
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
RangeSlider.displayName = 'RangeSlider';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface RangeSliderProps
|
|
4
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
5
|
+
/** Label text above the slider */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Minimum value */
|
|
8
|
+
min?: number;
|
|
9
|
+
/** Maximum value */
|
|
10
|
+
max?: number;
|
|
11
|
+
/** Step increment */
|
|
12
|
+
step?: number;
|
|
13
|
+
/** Single-thumb value */
|
|
14
|
+
value?: number;
|
|
15
|
+
/** Single-thumb change handler */
|
|
16
|
+
onValueChange?: (value: number) => void;
|
|
17
|
+
/** Dual-thumb range value [low, high] */
|
|
18
|
+
rangeValue?: [number, number];
|
|
19
|
+
/** Dual-thumb range change handler */
|
|
20
|
+
onRangeChange?: (value: [number, number]) => void;
|
|
21
|
+
/** Show editable input next to track (single mode) */
|
|
22
|
+
showInput?: boolean;
|
|
23
|
+
/** Suffix shown in input, e.g. "%" */
|
|
24
|
+
suffix?: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* ─── Root ─── */
|
|
2
|
+
.root {
|
|
3
|
+
--rating-color-active: var(--st-color-primary);
|
|
4
|
+
--rating-color-inactive: var(--st-color-neutral-200);
|
|
5
|
+
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: var(--st-space-1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* ─── Stars container ─── */
|
|
12
|
+
.stars {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 2px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ─── Icon fills ─── */
|
|
19
|
+
.iconActive {
|
|
20
|
+
fill: var(--rating-color-active);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.iconInactive {
|
|
24
|
+
fill: var(--rating-color-inactive);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* ─── Value text ─── */
|
|
28
|
+
.value {
|
|
29
|
+
font-family: var(--st-font-family);
|
|
30
|
+
font-weight: var(--st-font-weight-semibold);
|
|
31
|
+
line-height: var(--st-line-height-tight);
|
|
32
|
+
color: var(--st-color-foreground);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.md .value {
|
|
36
|
+
font-size: var(--st-font-size-sm);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.sm .value {
|
|
40
|
+
font-size: var(--st-font-size-xs);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* ─── Count text ─── */
|
|
44
|
+
.count {
|
|
45
|
+
font-family: var(--st-font-family);
|
|
46
|
+
line-height: var(--st-line-height-tight);
|
|
47
|
+
color: var(--st-color-muted);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.md .count {
|
|
51
|
+
font-size: var(--st-font-size-sm);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.sm .count {
|
|
55
|
+
font-size: var(--st-font-size-xs);
|
|
56
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { forwardRef, useId } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { RatingIconType, RatingProps } from './Rating.types';
|
|
4
|
+
import styles from './Rating.module.css';
|
|
5
|
+
|
|
6
|
+
const STAR_PATH =
|
|
7
|
+
'M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z';
|
|
8
|
+
const HEART_PATH =
|
|
9
|
+
'M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z';
|
|
10
|
+
|
|
11
|
+
interface IconProps {
|
|
12
|
+
type: RatingIconType;
|
|
13
|
+
fill: number;
|
|
14
|
+
gradientId: string;
|
|
15
|
+
size: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function RatingIcon({ type, fill, gradientId, size }: IconProps) {
|
|
19
|
+
const d = type === 'star' ? STAR_PATH : HEART_PATH;
|
|
20
|
+
const clamped = Math.min(1, Math.max(0, fill));
|
|
21
|
+
|
|
22
|
+
if (clamped <= 0) {
|
|
23
|
+
return (
|
|
24
|
+
<svg width={size} height={size} viewBox="0 0 24 24" aria-hidden="true">
|
|
25
|
+
<path d={d} className={styles.iconInactive} />
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (clamped >= 1) {
|
|
31
|
+
return (
|
|
32
|
+
<svg width={size} height={size} viewBox="0 0 24 24" aria-hidden="true">
|
|
33
|
+
<path d={d} className={styles.iconActive} />
|
|
34
|
+
</svg>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const offset = `${Math.round(clamped * 100)}%`;
|
|
39
|
+
return (
|
|
40
|
+
<svg width={size} height={size} viewBox="0 0 24 24" aria-hidden="true">
|
|
41
|
+
<defs>
|
|
42
|
+
<linearGradient id={gradientId}>
|
|
43
|
+
<stop
|
|
44
|
+
offset={offset}
|
|
45
|
+
style={{ stopColor: 'var(--rating-color-active)' }}
|
|
46
|
+
/>
|
|
47
|
+
<stop
|
|
48
|
+
offset={offset}
|
|
49
|
+
style={{ stopColor: 'var(--rating-color-inactive)' }}
|
|
50
|
+
/>
|
|
51
|
+
</linearGradient>
|
|
52
|
+
</defs>
|
|
53
|
+
<path d={d} fill={`url(#${gradientId})`} />
|
|
54
|
+
</svg>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const ICON_SIZE = { md: 16, sm: 12 } as const;
|
|
59
|
+
|
|
60
|
+
export const Rating = forwardRef<HTMLDivElement, RatingProps>(
|
|
61
|
+
(
|
|
62
|
+
{
|
|
63
|
+
value,
|
|
64
|
+
count,
|
|
65
|
+
maxStars = 5,
|
|
66
|
+
size = 'md',
|
|
67
|
+
variant = 'type1',
|
|
68
|
+
icon = 'star',
|
|
69
|
+
className,
|
|
70
|
+
...rest
|
|
71
|
+
},
|
|
72
|
+
ref,
|
|
73
|
+
) => {
|
|
74
|
+
const baseId = useId().replace(/:/g, '');
|
|
75
|
+
const iconSize = ICON_SIZE[size];
|
|
76
|
+
|
|
77
|
+
const starsEl = (
|
|
78
|
+
<span className={styles.stars}>
|
|
79
|
+
{variant === 'simple' ? (
|
|
80
|
+
<RatingIcon
|
|
81
|
+
type={icon}
|
|
82
|
+
fill={1}
|
|
83
|
+
gradientId={`${baseId}-0`}
|
|
84
|
+
size={iconSize}
|
|
85
|
+
/>
|
|
86
|
+
) : (
|
|
87
|
+
Array.from({ length: maxStars }, (_, i) => (
|
|
88
|
+
<RatingIcon
|
|
89
|
+
key={i}
|
|
90
|
+
type={icon}
|
|
91
|
+
fill={Math.min(1, Math.max(0, value - i))}
|
|
92
|
+
gradientId={`${baseId}-${i}`}
|
|
93
|
+
size={iconSize}
|
|
94
|
+
/>
|
|
95
|
+
))
|
|
96
|
+
)}
|
|
97
|
+
</span>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const valueEl = <span className={styles.value}>{value}</span>;
|
|
101
|
+
const countEl =
|
|
102
|
+
count !== undefined ? (
|
|
103
|
+
<span className={styles.count}>({count})</span>
|
|
104
|
+
) : null;
|
|
105
|
+
|
|
106
|
+
/* Element order depends on variant + size:
|
|
107
|
+
md type1 / sm type2 / simple → stars first
|
|
108
|
+
md type2 / sm type1 → value first */
|
|
109
|
+
const starsFirst =
|
|
110
|
+
variant === 'simple' ||
|
|
111
|
+
(variant === 'type1' && size === 'md') ||
|
|
112
|
+
(variant === 'type2' && size === 'sm');
|
|
113
|
+
|
|
114
|
+
const label = `Rating: ${value} out of ${maxStars}${count !== undefined ? ` (${count} reviews)` : ''}`;
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
ref={ref}
|
|
119
|
+
role="img"
|
|
120
|
+
aria-label={label}
|
|
121
|
+
className={cn(styles.root, styles[size], className)}
|
|
122
|
+
{...rest}
|
|
123
|
+
>
|
|
124
|
+
{starsFirst ? (
|
|
125
|
+
<>
|
|
126
|
+
{starsEl}
|
|
127
|
+
{valueEl}
|
|
128
|
+
{countEl}
|
|
129
|
+
</>
|
|
130
|
+
) : (
|
|
131
|
+
<>
|
|
132
|
+
{valueEl}
|
|
133
|
+
{starsEl}
|
|
134
|
+
{countEl}
|
|
135
|
+
</>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
Rating.displayName = 'Rating';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type RatingSize = 'md' | 'sm';
|
|
4
|
+
export type RatingVariant = 'type1' | 'type2' | 'simple';
|
|
5
|
+
export type RatingIconType = 'star' | 'heart';
|
|
6
|
+
|
|
7
|
+
export interface RatingProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
value: number;
|
|
9
|
+
count?: number;
|
|
10
|
+
maxStars?: number;
|
|
11
|
+
size?: RatingSize;
|
|
12
|
+
variant?: RatingVariant;
|
|
13
|
+
icon?: RatingIconType;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
width: fit-content;
|
|
5
|
+
background: var(--st-color-neutral-100);
|
|
6
|
+
padding: 4px;
|
|
7
|
+
border-radius: var(--st-radius-full);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Sizes — custom properties inherited by items */
|
|
11
|
+
.lg {
|
|
12
|
+
--sc-height: 40px;
|
|
13
|
+
--sc-px: var(--st-space-4);
|
|
14
|
+
--sc-font: var(--st-font-size-sm);
|
|
15
|
+
--sc-gap: var(--st-space-2);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.md {
|
|
19
|
+
--sc-height: 32px;
|
|
20
|
+
--sc-px: var(--st-space-3);
|
|
21
|
+
--sc-font: var(--st-font-size-sm);
|
|
22
|
+
--sc-gap: var(--st-space-1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.sm {
|
|
26
|
+
--sc-height: 28px;
|
|
27
|
+
--sc-px: var(--st-space-2);
|
|
28
|
+
--sc-font: var(--st-font-size-xs);
|
|
29
|
+
--sc-gap: var(--st-space-1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Button variant — connected, position-based corners */
|
|
33
|
+
.button {
|
|
34
|
+
gap: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.button > *:first-child {
|
|
38
|
+
border-radius: var(--st-radius-full) 0 0 var(--st-radius-full);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.button > *:last-child {
|
|
42
|
+
border-radius: 0 var(--st-radius-full) var(--st-radius-full) 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.button > *:only-child {
|
|
46
|
+
border-radius: var(--st-radius-full);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Tag variant — each item independently pill-shaped */
|
|
50
|
+
.tag {
|
|
51
|
+
gap: 2px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.tag > * {
|
|
55
|
+
border-radius: var(--st-radius-full);
|
|
56
|
+
}
|