@for-the-people-initiative/design-system 1.3.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/README.md +80 -0
- package/dist/css/theme-dark.css +7 -0
- package/dist/css/tokens.css +2315 -0
- package/dist/scss/_tokens.scss +2521 -0
- package/dist/ts/tokens.ts +2441 -0
- package/package.json +80 -0
- package/src/components/Accordion/Accordion.scss +118 -0
- package/src/components/Accordion/Accordion.vue +105 -0
- package/src/components/Accordion/AccordionTab.vue +79 -0
- package/src/components/Alert/Alert.scss +109 -0
- package/src/components/Alert/Alert.vue +79 -0
- package/src/components/AppBar/AppBar.scss +73 -0
- package/src/components/AppBar/AppBar.vue +49 -0
- package/src/components/AtmosphericBackground/AtmosphericBackground.vue +198 -0
- package/src/components/AutoComplete/AutoComplete.scss +282 -0
- package/src/components/AutoComplete/AutoComplete.vue +398 -0
- package/src/components/Avatar/Avatar.scss +191 -0
- package/src/components/Avatar/Avatar.vue +44 -0
- package/src/components/Badge/Badge.scss +84 -0
- package/src/components/Badge/Badge.vue +41 -0
- package/src/components/BlockUI/BlockUI.scss +85 -0
- package/src/components/BlockUI/BlockUI.vue +90 -0
- package/src/components/Breadcrumb/Breadcrumb.scss +84 -0
- package/src/components/Breadcrumb/Breadcrumb.vue +141 -0
- package/src/components/Button/Button.scss +254 -0
- package/src/components/Button/Button.vue +68 -0
- package/src/components/CTA/CTA.scss +92 -0
- package/src/components/CTA/CTA.vue +33 -0
- package/src/components/Calendar/Calendar.scss +330 -0
- package/src/components/Calendar/Calendar.vue +455 -0
- package/src/components/Card/Card.scss +66 -0
- package/src/components/Card/Card.vue +48 -0
- package/src/components/Carousel/Carousel.scss +121 -0
- package/src/components/Carousel/Carousel.vue +191 -0
- package/src/components/Chart/Chart.scss +109 -0
- package/src/components/Chart/Chart.vue +209 -0
- package/src/components/Checkbox/Checkbox.scss +148 -0
- package/src/components/Checkbox/Checkbox.vue +75 -0
- package/src/components/Chip/Chip.scss +83 -0
- package/src/components/Chip/Chip.vue +73 -0
- package/src/components/ColorPicker/ColorPicker.scss +244 -0
- package/src/components/ColorPicker/ColorPicker.vue +411 -0
- package/src/components/Column/Column.scss +87 -0
- package/src/components/Column/Column.vue +45 -0
- package/src/components/ColumnGroup/ColumnGroup.scss +41 -0
- package/src/components/ColumnGroup/ColumnGroup.vue +27 -0
- package/src/components/ColumnGroup/ColumnGroupRow.vue +18 -0
- package/src/components/CommandPalette/CommandPalette.scss +143 -0
- package/src/components/CommandPalette/CommandPalette.vue +165 -0
- package/src/components/ConfirmDialog/ConfirmDialog.scss +177 -0
- package/src/components/ConfirmDialog/ConfirmDialog.vue +162 -0
- package/src/components/ConfirmPopup/ConfirmPopup.scss +180 -0
- package/src/components/ConfirmPopup/ConfirmPopup.vue +185 -0
- package/src/components/ContextMenu/ContextMenu.scss +171 -0
- package/src/components/ContextMenu/ContextMenu.vue +383 -0
- package/src/components/DataTable/DataTable.scss +162 -0
- package/src/components/DataTable/DataTable.vue +225 -0
- package/src/components/DataView/DataView.scss +149 -0
- package/src/components/DataView/DataView.vue +172 -0
- package/src/components/DatePicker/DatePicker.scss +71 -0
- package/src/components/DatePicker/DatePicker.vue +121 -0
- package/src/components/Dialog/Dialog.scss +161 -0
- package/src/components/Dialog/Dialog.vue +245 -0
- package/src/components/Divider/Divider.scss +147 -0
- package/src/components/Divider/Divider.vue +49 -0
- package/src/components/Dock/Dock.scss +221 -0
- package/src/components/Dock/Dock.vue +107 -0
- package/src/components/Drawer/Drawer.scss +220 -0
- package/src/components/Drawer/Drawer.vue +137 -0
- package/src/components/Dropdown/Dropdown.scss +218 -0
- package/src/components/Dropdown/Dropdown.vue +313 -0
- package/src/components/Editor/Editor.scss +156 -0
- package/src/components/Editor/Editor.vue +253 -0
- package/src/components/FAQ/FAQ.scss +24 -0
- package/src/components/FAQ/FAQ.vue +28 -0
- package/src/components/FeatureGrid/FeatureGrid.scss +92 -0
- package/src/components/FeatureGrid/FeatureGrid.vue +39 -0
- package/src/components/FieldSet/FieldSet.scss +97 -0
- package/src/components/FieldSet/FieldSet.vue +70 -0
- package/src/components/FileUpload/FileUpload.scss +137 -0
- package/src/components/FileUpload/FileUpload.vue +183 -0
- package/src/components/Footer/Footer.scss +95 -0
- package/src/components/Footer/Footer.vue +59 -0
- package/src/components/Form/Form.scss +72 -0
- package/src/components/Form/Form.vue +30 -0
- package/src/components/Form/FormField.vue +42 -0
- package/src/components/Galleria/Galleria.scss +295 -0
- package/src/components/Galleria/Galleria.vue +274 -0
- package/src/components/Hero/Hero.scss +116 -0
- package/src/components/Hero/Hero.vue +57 -0
- package/src/components/Image/Image.scss +129 -0
- package/src/components/Image/Image.vue +117 -0
- package/src/components/ImageCompare/ImageCompare.scss +97 -0
- package/src/components/ImageCompare/ImageCompare.vue +66 -0
- package/src/components/InPlace/InPlace.scss +97 -0
- package/src/components/InPlace/InPlace.vue +107 -0
- package/src/components/InlineMessage/InlineMessage.scss +69 -0
- package/src/components/InlineMessage/InlineMessage.vue +47 -0
- package/src/components/InputChips/InputChips.scss +165 -0
- package/src/components/InputChips/InputChips.vue +169 -0
- package/src/components/InputGroup/InputGroup.scss +57 -0
- package/src/components/InputGroup/InputGroup.vue +22 -0
- package/src/components/InputGroupAddon/InputGroupAddon.scss +28 -0
- package/src/components/InputGroupAddon/InputGroupAddon.vue +22 -0
- package/src/components/InputIcon/InputIcon.scss +58 -0
- package/src/components/InputIcon/InputIcon.vue +28 -0
- package/src/components/InputMask/InputMask.scss +65 -0
- package/src/components/InputMask/InputMask.vue +268 -0
- package/src/components/InputNumber/InputNumber.scss +122 -0
- package/src/components/InputNumber/InputNumber.vue +150 -0
- package/src/components/InputOtp/InputOtp.scss +88 -0
- package/src/components/InputOtp/InputOtp.vue +230 -0
- package/src/components/InputSwitch/InputSwitch.scss +131 -0
- package/src/components/InputSwitch/InputSwitch.vue +49 -0
- package/src/components/InputText/InputText.scss +61 -0
- package/src/components/InputText/InputText.vue +71 -0
- package/src/components/Knob/Knob.scss +92 -0
- package/src/components/Knob/Knob.vue +252 -0
- package/src/components/ListBox/ListBox.scss +152 -0
- package/src/components/ListBox/ListBox.vue +198 -0
- package/src/components/LogoCloud/LogoCloud.scss +64 -0
- package/src/components/LogoCloud/LogoCloud.vue +35 -0
- package/src/components/MegaMenu/MegaMenu.scss +280 -0
- package/src/components/MegaMenu/MegaMenu.vue +218 -0
- package/src/components/Menu/Menu.scss +102 -0
- package/src/components/Menu/Menu.vue +221 -0
- package/src/components/MenuBar/MenuBar.scss +208 -0
- package/src/components/MenuBar/MenuBar.vue +306 -0
- package/src/components/Message/Message.scss +126 -0
- package/src/components/Message/Message.vue +99 -0
- package/src/components/MeterGroup/MeterGroup.scss +105 -0
- package/src/components/MeterGroup/MeterGroup.vue +73 -0
- package/src/components/MultiSelect/MultiSelect.scss +239 -0
- package/src/components/MultiSelect/MultiSelect.vue +296 -0
- package/src/components/OrderList/OrderList.scss +133 -0
- package/src/components/OrderList/OrderList.vue +267 -0
- package/src/components/OrganizationChart/OrganizationChart.scss +145 -0
- package/src/components/OrganizationChart/OrganizationChart.vue +220 -0
- package/src/components/OverlayPanel/OverlayPanel.scss +69 -0
- package/src/components/OverlayPanel/OverlayPanel.vue +180 -0
- package/src/components/Paginator/Paginator.scss +130 -0
- package/src/components/Paginator/Paginator.vue +212 -0
- package/src/components/Panel/Panel.scss +113 -0
- package/src/components/Panel/Panel.vue +89 -0
- package/src/components/PanelMenu/PanelMenu.scss +211 -0
- package/src/components/PanelMenu/PanelMenu.vue +295 -0
- package/src/components/ParticleBackground/ParticleBackground.vue +310 -0
- package/src/components/PickList/PickList.scss +126 -0
- package/src/components/PickList/PickList.vue +249 -0
- package/src/components/PopOver/PopOver.scss +112 -0
- package/src/components/PopOver/PopOver.vue +254 -0
- package/src/components/PricingTable/PricingCard.vue +33 -0
- package/src/components/PricingTable/PricingTable.scss +133 -0
- package/src/components/PricingTable/PricingTable.vue +21 -0
- package/src/components/ProgressBar/ProgressBar.scss +58 -0
- package/src/components/ProgressBar/ProgressBar.vue +48 -0
- package/src/components/ProgressSpinner/ProgressSpinner.scss +48 -0
- package/src/components/ProgressSpinner/ProgressSpinner.vue +53 -0
- package/src/components/RadioButton/RadioButton.scss +148 -0
- package/src/components/RadioButton/RadioButton.vue +52 -0
- package/src/components/Rating/Rating.scss +109 -0
- package/src/components/Rating/Rating.vue +136 -0
- package/src/components/Row/Row.scss +38 -0
- package/src/components/Row/Row.vue +30 -0
- package/src/components/ScrollPanel/ScrollPanel.scss +90 -0
- package/src/components/ScrollPanel/ScrollPanel.vue +284 -0
- package/src/components/ScrollTop/ScrollTop.scss +59 -0
- package/src/components/ScrollTop/ScrollTop.vue +99 -0
- package/src/components/Section/Section.scss +58 -0
- package/src/components/Section/Section.vue +39 -0
- package/src/components/Select/Select.scss +98 -0
- package/src/components/Select/Select.vue +92 -0
- package/src/components/SelectButton/SelectButton.scss +65 -0
- package/src/components/SelectButton/SelectButton.vue +144 -0
- package/src/components/Sidebar/Sidebar.scss +170 -0
- package/src/components/Sidebar/Sidebar.vue +137 -0
- package/src/components/Skeleton/Skeleton.scss +43 -0
- package/src/components/Skeleton/Skeleton.vue +57 -0
- package/src/components/Slider/Slider.scss +103 -0
- package/src/components/Slider/Slider.vue +65 -0
- package/src/components/SpeedDial/SpeedDial.scss +217 -0
- package/src/components/SpeedDial/SpeedDial.vue +196 -0
- package/src/components/SplitButton/SplitButton.scss +264 -0
- package/src/components/SplitButton/SplitButton.vue +172 -0
- package/src/components/Splitter/Splitter.scss +95 -0
- package/src/components/Splitter/Splitter.vue +191 -0
- package/src/components/Splitter/SplitterPanel.vue +125 -0
- package/src/components/Stats/Stats.scss +54 -0
- package/src/components/Stats/Stats.vue +28 -0
- package/src/components/Steps/Steps.scss +164 -0
- package/src/components/Steps/Steps.vue +100 -0
- package/src/components/TabMenu/TabMenu.scss +106 -0
- package/src/components/TabMenu/TabMenu.vue +174 -0
- package/src/components/Tabs/TabPanel.vue +41 -0
- package/src/components/Tabs/Tabs.scss +82 -0
- package/src/components/Tabs/Tabs.vue +162 -0
- package/src/components/Tag/Tag.scss +73 -0
- package/src/components/Tag/Tag.vue +37 -0
- package/src/components/Terminal/Terminal.scss +80 -0
- package/src/components/Terminal/Terminal.vue +113 -0
- package/src/components/Testimonial/Testimonial.scss +80 -0
- package/src/components/Testimonial/Testimonial.vue +29 -0
- package/src/components/Textarea/Textarea.scss +65 -0
- package/src/components/Textarea/Textarea.vue +101 -0
- package/src/components/TieredMenu/TieredMenu.scss +146 -0
- package/src/components/TieredMenu/TieredMenu.vue +270 -0
- package/src/components/TieredMenu/TieredMenuSub.vue +132 -0
- package/src/components/Timeline/Timeline.scss +190 -0
- package/src/components/Timeline/Timeline.vue +79 -0
- package/src/components/Toast/Toast.scss +284 -0
- package/src/components/Toast/Toast.vue +162 -0
- package/src/components/ToggleButton/ToggleButton.scss +99 -0
- package/src/components/ToggleButton/ToggleButton.vue +65 -0
- package/src/components/ToggleSwitch/ToggleSwitch.scss +68 -0
- package/src/components/ToggleSwitch/ToggleSwitch.vue +44 -0
- package/src/components/Toolbar/Toolbar.scss +37 -0
- package/src/components/Toolbar/Toolbar.vue +23 -0
- package/src/components/Tooltip/Tooltip.scss +114 -0
- package/src/components/Tooltip/Tooltip.vue +169 -0
- package/src/components/Tree/Tree.scss +164 -0
- package/src/components/Tree/Tree.vue +273 -0
- package/src/components/TreeSelect/TreeSelect.scss +238 -0
- package/src/components/TreeSelect/TreeSelect.vue +401 -0
- package/src/components/TreeTable/TreeTable.scss +172 -0
- package/src/components/TreeTable/TreeTable.vue +285 -0
- package/src/components/VirtualScroller/VirtualScroller.scss +107 -0
- package/src/components/VirtualScroller/VirtualScroller.vue +234 -0
- package/src/scss/fonts.scss +63 -0
- package/src/scss/mixins/accent-gradient.scss +43 -0
- package/src/scss/mixins/border.scss +28 -0
- package/src/scss/mixins/breakpoint.scss +80 -0
- package/src/scss/mixins/container.scss +33 -0
- package/src/scss/mixins/elevation.scss +43 -0
- package/src/scss/mixins/grid.scss +23 -0
- package/src/scss/mixins/levitation.scss +15 -0
- package/src/scss/mixins/list.scss +5 -0
- package/src/scss/mixins/surface-atmospheric.scss +93 -0
- package/src/scss/mixins/surface.scss +19 -0
- package/src/scss/mixins/typography.scss +91 -0
- package/src/scss/utility-classes/utility-classes-spacing.scss +34 -0
- package/src/scss/utility-classes/utility-classes-typography.scss +114 -0
- package/tokens/components/accordion.json +127 -0
- package/tokens/components/autocomplete.json +238 -0
- package/tokens/components/avatar.json +220 -0
- package/tokens/components/badge.json +119 -0
- package/tokens/components/block-ui.json +40 -0
- package/tokens/components/breadcrumb.json +57 -0
- package/tokens/components/button.json +395 -0
- package/tokens/components/calendar.json +260 -0
- package/tokens/components/card.json +157 -0
- package/tokens/components/carousel.json +154 -0
- package/tokens/components/chart.json +132 -0
- package/tokens/components/checkbox.json +130 -0
- package/tokens/components/chip.json +100 -0
- package/tokens/components/color-picker.json +196 -0
- package/tokens/components/column-group.json +45 -0
- package/tokens/components/column.json +109 -0
- package/tokens/components/confirm-dialog.json +141 -0
- package/tokens/components/confirm-popup.json +101 -0
- package/tokens/components/context-menu.json +168 -0
- package/tokens/components/data-table.json +157 -0
- package/tokens/components/data-view.json +172 -0
- package/tokens/components/dialog.json +151 -0
- package/tokens/components/divider.json +45 -0
- package/tokens/components/dock.json +173 -0
- package/tokens/components/drawer.json +163 -0
- package/tokens/components/dropdown.json +230 -0
- package/tokens/components/editor.json +170 -0
- package/tokens/components/field-set.json +115 -0
- package/tokens/components/file-upload.json +193 -0
- package/tokens/components/galleria.json +235 -0
- package/tokens/components/image-compare.json +74 -0
- package/tokens/components/image.json +71 -0
- package/tokens/components/in-place.json +100 -0
- package/tokens/components/inline-message.json +107 -0
- package/tokens/components/input-chips.json +187 -0
- package/tokens/components/input-group-addon.json +47 -0
- package/tokens/components/input-group.json +21 -0
- package/tokens/components/input-icon.json +38 -0
- package/tokens/components/input-mask.json +136 -0
- package/tokens/components/input-number.json +144 -0
- package/tokens/components/input-otp.json +138 -0
- package/tokens/components/input-switch.json +108 -0
- package/tokens/components/input-text.json +136 -0
- package/tokens/components/knob.json +119 -0
- package/tokens/components/listbox.json +166 -0
- package/tokens/components/mega-menu.json +283 -0
- package/tokens/components/menu.json +145 -0
- package/tokens/components/menubar.json +152 -0
- package/tokens/components/message.json +151 -0
- package/tokens/components/meter-group.json +108 -0
- package/tokens/components/multi-select.json +244 -0
- package/tokens/components/order-list.json +193 -0
- package/tokens/components/organization-chart.json +188 -0
- package/tokens/components/overlay-panel.json +94 -0
- package/tokens/components/paginator.json +186 -0
- package/tokens/components/panel.json +120 -0
- package/tokens/components/panelmenu.json +190 -0
- package/tokens/components/picklist.json +187 -0
- package/tokens/components/popover.json +65 -0
- package/tokens/components/progress-bar.json +33 -0
- package/tokens/components/progress-spinner.json +38 -0
- package/tokens/components/radio.json +125 -0
- package/tokens/components/rating.json +76 -0
- package/tokens/components/row.json +62 -0
- package/tokens/components/scroll-panel.json +69 -0
- package/tokens/components/scroll-top.json +84 -0
- package/tokens/components/select-button.json +145 -0
- package/tokens/components/select.json +190 -0
- package/tokens/components/sidebar.json +146 -0
- package/tokens/components/skeleton.json +26 -0
- package/tokens/components/slider.json +82 -0
- package/tokens/components/speed-dial.json +144 -0
- package/tokens/components/split-button.json +316 -0
- package/tokens/components/splitter.json +88 -0
- package/tokens/components/steps.json +154 -0
- package/tokens/components/tabmenu.json +103 -0
- package/tokens/components/tabs.json +97 -0
- package/tokens/components/tag.json +122 -0
- package/tokens/components/terminal.json +100 -0
- package/tokens/components/textarea.json +96 -0
- package/tokens/components/tieredmenu.json +142 -0
- package/tokens/components/timeline.json +129 -0
- package/tokens/components/toast.json +281 -0
- package/tokens/components/toggle-button.json +220 -0
- package/tokens/components/toggle-switch.json +95 -0
- package/tokens/components/toolbar.json +41 -0
- package/tokens/components/tooltip.json +60 -0
- package/tokens/components/tree-select.json +224 -0
- package/tokens/components/tree.json +153 -0
- package/tokens/components/treetable.json +155 -0
- package/tokens/components/virtualscroller.json +95 -0
- package/tokens/primitives/color.json +137 -0
- package/tokens/primitives/radius.json +12 -0
- package/tokens/primitives/shadow.json +29 -0
- package/tokens/primitives/spacing.json +15 -0
- package/tokens/semantics/color.json +81 -0
- package/tokens/semantics/radius.json +10 -0
- package/tokens/semantics/shadow.json +9 -0
- package/tokens/semantics/spacing.json +24 -0
- package/tokens/themes/dark.json +7 -0
- package/tokens/themes/light.json +7 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
@use "../../../dist/scss/tokens" as *;
|
|
2
|
+
@use "../../scss/mixins/elevation" as *;
|
|
3
|
+
|
|
4
|
+
$c: toast;
|
|
5
|
+
|
|
6
|
+
.#{$c}-container {
|
|
7
|
+
position: fixed;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--toast-container-gap, $toast-container-gap);
|
|
11
|
+
padding: var(--toast-container-padding, $toast-container-padding);
|
|
12
|
+
max-width: var(--toast-container-maxWidth, $toast-container-maxWidth);
|
|
13
|
+
z-index: var(--toast-container-zIndex, $toast-container-zIndex);
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
|
|
16
|
+
> * {
|
|
17
|
+
pointer-events: auto;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Position variants
|
|
22
|
+
.#{$c}-container--top-left {
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
align-items: flex-start;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.#{$c}-container--top-center {
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 50%;
|
|
31
|
+
transform: translateX(-50%);
|
|
32
|
+
align-items: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.#{$c}-container--top-right {
|
|
36
|
+
top: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
align-items: flex-end;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.#{$c}-container--bottom-left {
|
|
42
|
+
bottom: 0;
|
|
43
|
+
left: 0;
|
|
44
|
+
align-items: flex-start;
|
|
45
|
+
flex-direction: column-reverse;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.#{$c}-container--bottom-center {
|
|
49
|
+
bottom: 0;
|
|
50
|
+
left: 50%;
|
|
51
|
+
transform: translateX(-50%);
|
|
52
|
+
align-items: center;
|
|
53
|
+
flex-direction: column-reverse;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.#{$c}-container--bottom-right {
|
|
57
|
+
bottom: 0;
|
|
58
|
+
right: 0;
|
|
59
|
+
align-items: flex-end;
|
|
60
|
+
flex-direction: column-reverse;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.#{$c}-container--center {
|
|
64
|
+
top: 50%;
|
|
65
|
+
left: 50%;
|
|
66
|
+
transform: translate(-50%, -50%);
|
|
67
|
+
align-items: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.#{$c} {
|
|
71
|
+
@include elevation(3);
|
|
72
|
+
position: relative;
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: flex-start;
|
|
75
|
+
gap: var(--toast-icon-gap, $toast-icon-gap);
|
|
76
|
+
width: 100%;
|
|
77
|
+
padding: var(--toast-padding-y, $toast-padding-y) var(--toast-padding-x, $toast-padding-x);
|
|
78
|
+
// Component token overrides
|
|
79
|
+
background-color: var(--toast-background-default, $toast-background-default);
|
|
80
|
+
border-color: var(--toast-border-color-default, $toast-border-color-default);
|
|
81
|
+
border-width: var(--toast-border-width, $toast-border-width);
|
|
82
|
+
border-radius: var(--toast-radius, $toast-radius);
|
|
83
|
+
box-shadow: var(--toast-shadow, $toast-shadow);
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.#{$c}--closable {
|
|
88
|
+
padding-right: calc(var(--toast-padding-x, $toast-padding-x) + var(--toast-closeButton-size, $toast-closeButton-size) + var(--toast-icon-gap, $toast-icon-gap));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Severity variants
|
|
92
|
+
.#{$c}--success {
|
|
93
|
+
background-color: var(--toast-background-success, $toast-background-success);
|
|
94
|
+
border-color: var(--toast-border-color-success, $toast-border-color-success);
|
|
95
|
+
|
|
96
|
+
.#{$c}__icon {
|
|
97
|
+
color: var(--toast-icon-color-success, $toast-icon-color-success);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.#{$c}__summary {
|
|
101
|
+
color: var(--toast-summary-color-success, $toast-summary-color-success);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.#{$c}--info {
|
|
106
|
+
background-color: var(--toast-background-info, $toast-background-info);
|
|
107
|
+
border-color: var(--toast-border-color-info, $toast-border-color-info);
|
|
108
|
+
|
|
109
|
+
.#{$c}__icon {
|
|
110
|
+
color: var(--toast-icon-color-info, $toast-icon-color-info);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.#{$c}__summary {
|
|
114
|
+
color: var(--toast-summary-color-info, $toast-summary-color-info);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.#{$c}--warning {
|
|
119
|
+
background-color: var(--toast-background-warning, $toast-background-warning);
|
|
120
|
+
border-color: var(--toast-border-color-warning, $toast-border-color-warning);
|
|
121
|
+
|
|
122
|
+
.#{$c}__icon {
|
|
123
|
+
color: var(--toast-icon-color-warning, $toast-icon-color-warning);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.#{$c}__summary {
|
|
127
|
+
color: var(--toast-summary-color-warning, $toast-summary-color-warning);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.#{$c}--error {
|
|
132
|
+
background-color: var(--toast-background-error, $toast-background-error);
|
|
133
|
+
border-color: var(--toast-border-color-error, $toast-border-color-error);
|
|
134
|
+
|
|
135
|
+
.#{$c}__icon {
|
|
136
|
+
color: var(--toast-icon-color-error, $toast-icon-color-error);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.#{$c}__summary {
|
|
140
|
+
color: var(--toast-summary-color-error, $toast-summary-color-error);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.#{$c}__icon {
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
justify-content: center;
|
|
148
|
+
width: var(--toast-icon-size, $toast-icon-size);
|
|
149
|
+
height: var(--toast-icon-size, $toast-icon-size);
|
|
150
|
+
color: var(--toast-icon-color-default, $toast-icon-color-default);
|
|
151
|
+
flex-shrink: 0;
|
|
152
|
+
|
|
153
|
+
svg {
|
|
154
|
+
width: 100%;
|
|
155
|
+
height: 100%;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.#{$c}__content {
|
|
160
|
+
display: flex;
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
gap: var(--toast-content-gap, $toast-content-gap);
|
|
163
|
+
flex: 1;
|
|
164
|
+
min-width: 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.#{$c}__summary {
|
|
168
|
+
font-size: var(--toast-summary-fontSize, $toast-summary-fontSize);
|
|
169
|
+
font-weight: var(--toast-summary-fontWeight, $toast-summary-fontWeight);
|
|
170
|
+
color: var(--toast-summary-color-default, $toast-summary-color-default);
|
|
171
|
+
line-height: 1.4;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.#{$c}__detail {
|
|
175
|
+
font-size: var(--toast-detail-fontSize, $toast-detail-fontSize);
|
|
176
|
+
color: var(--toast-detail-color, $toast-detail-color);
|
|
177
|
+
line-height: 1.4;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.#{$c}__close {
|
|
181
|
+
position: absolute;
|
|
182
|
+
top: var(--toast-padding-y, $toast-padding-y);
|
|
183
|
+
right: var(--toast-padding-x, $toast-padding-x);
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
width: var(--toast-closeButton-size, $toast-closeButton-size);
|
|
188
|
+
height: var(--toast-closeButton-size, $toast-closeButton-size);
|
|
189
|
+
padding: 0;
|
|
190
|
+
border: none;
|
|
191
|
+
background: transparent;
|
|
192
|
+
color: var(--toast-closeButton-color-default, $toast-closeButton-color-default);
|
|
193
|
+
border-radius: var(--toast-closeButton-radius, $toast-closeButton-radius);
|
|
194
|
+
cursor: pointer;
|
|
195
|
+
transition: background-color 0.15s ease, color 0.15s ease;
|
|
196
|
+
|
|
197
|
+
&:hover {
|
|
198
|
+
background-color: var(--toast-closeButton-background-hover, $toast-closeButton-background-hover);
|
|
199
|
+
color: var(--toast-closeButton-color-hover, $toast-closeButton-color-hover);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
svg {
|
|
203
|
+
width: var(--toast-closeButton-iconSize, $toast-closeButton-iconSize);
|
|
204
|
+
height: var(--toast-closeButton-iconSize, $toast-closeButton-iconSize);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.#{$c}__progress {
|
|
209
|
+
position: absolute;
|
|
210
|
+
bottom: 0;
|
|
211
|
+
left: 0;
|
|
212
|
+
right: 0;
|
|
213
|
+
height: var(--toast-progress-height, $toast-progress-height);
|
|
214
|
+
background-color: var(--toast-progress-background, $toast-progress-background);
|
|
215
|
+
overflow: hidden;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.#{$c}__progress-bar {
|
|
219
|
+
height: 100%;
|
|
220
|
+
background-color: var(--toast-progress-fill-default, $toast-progress-fill-default);
|
|
221
|
+
animation: toast-progress-shrink linear forwards;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.#{$c}__progress-bar--success {
|
|
225
|
+
background-color: var(--toast-progress-fill-success, $toast-progress-fill-success);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.#{$c}__progress-bar--info {
|
|
229
|
+
background-color: var(--toast-progress-fill-info, $toast-progress-fill-info);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.#{$c}__progress-bar--warning {
|
|
233
|
+
background-color: var(--toast-progress-fill-warning, $toast-progress-fill-warning);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.#{$c}__progress-bar--error {
|
|
237
|
+
background-color: var(--toast-progress-fill-error, $toast-progress-fill-error);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@keyframes toast-progress-shrink {
|
|
241
|
+
from {
|
|
242
|
+
width: 100%;
|
|
243
|
+
}
|
|
244
|
+
to {
|
|
245
|
+
width: 0%;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Transition animations
|
|
250
|
+
.#{$c}-slide-enter-active,
|
|
251
|
+
.#{$c}-slide-leave-active {
|
|
252
|
+
transition: all 0.3s ease;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.#{$c}-slide-enter-from {
|
|
256
|
+
opacity: 0;
|
|
257
|
+
transform: translateX(100%);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.#{$c}-slide-leave-to {
|
|
261
|
+
opacity: 0;
|
|
262
|
+
transform: translateX(100%);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Adjust slide direction based on position
|
|
266
|
+
.#{$c}-container--top-left,
|
|
267
|
+
.#{$c}-container--bottom-left {
|
|
268
|
+
.#{$c}-slide-enter-from,
|
|
269
|
+
.#{$c}-slide-leave-to {
|
|
270
|
+
transform: translateX(-100%);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.#{$c}-container--top-center,
|
|
275
|
+
.#{$c}-container--bottom-center,
|
|
276
|
+
.#{$c}-container--center {
|
|
277
|
+
.#{$c}-slide-enter-from {
|
|
278
|
+
transform: translateY(-20px);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.#{$c}-slide-leave-to {
|
|
282
|
+
transform: translateY(-20px);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport to="body">
|
|
3
|
+
<div
|
|
4
|
+
class="toast-container"
|
|
5
|
+
:class="`toast-container--${position}`"
|
|
6
|
+
>
|
|
7
|
+
<TransitionGroup name="toast-slide">
|
|
8
|
+
<div
|
|
9
|
+
v-for="toast in toasts"
|
|
10
|
+
:key="toast.id"
|
|
11
|
+
class="toast"
|
|
12
|
+
:class="[
|
|
13
|
+
`toast--${toast.severity || 'default'}`,
|
|
14
|
+
{ 'toast--closable': toast.closable !== false }
|
|
15
|
+
]"
|
|
16
|
+
role="alert"
|
|
17
|
+
aria-live="assertive"
|
|
18
|
+
>
|
|
19
|
+
<span v-if="showIcon" class="toast__icon">
|
|
20
|
+
<svg v-if="toast.severity === 'success'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
21
|
+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
|
|
22
|
+
<polyline points="22 4 12 14.01 9 11.01" />
|
|
23
|
+
</svg>
|
|
24
|
+
<svg v-else-if="toast.severity === 'info'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
25
|
+
<circle cx="12" cy="12" r="10" />
|
|
26
|
+
<line x1="12" y1="16" x2="12" y2="12" />
|
|
27
|
+
<line x1="12" y1="8" x2="12.01" y2="8" />
|
|
28
|
+
</svg>
|
|
29
|
+
<svg v-else-if="toast.severity === 'warning'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
30
|
+
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
|
|
31
|
+
<line x1="12" y1="9" x2="12" y2="13" />
|
|
32
|
+
<line x1="12" y1="17" x2="12.01" y2="17" />
|
|
33
|
+
</svg>
|
|
34
|
+
<svg v-else-if="toast.severity === 'error'" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
35
|
+
<circle cx="12" cy="12" r="10" />
|
|
36
|
+
<line x1="15" y1="9" x2="9" y2="15" />
|
|
37
|
+
<line x1="9" y1="9" x2="15" y2="15" />
|
|
38
|
+
</svg>
|
|
39
|
+
<svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
40
|
+
<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9" />
|
|
41
|
+
<path d="M13.73 21a2 2 0 0 1-3.46 0" />
|
|
42
|
+
</svg>
|
|
43
|
+
</span>
|
|
44
|
+
|
|
45
|
+
<div class="toast__content">
|
|
46
|
+
<span v-if="toast.summary" class="toast__summary">{{ toast.summary }}</span>
|
|
47
|
+
<span v-if="toast.detail" class="toast__detail">{{ toast.detail }}</span>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<button
|
|
51
|
+
v-if="toast.closable !== false"
|
|
52
|
+
type="button"
|
|
53
|
+
class="toast__close"
|
|
54
|
+
aria-label="Close"
|
|
55
|
+
@click="removeToast(toast.id)"
|
|
56
|
+
>
|
|
57
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
58
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
59
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
60
|
+
</svg>
|
|
61
|
+
</button>
|
|
62
|
+
|
|
63
|
+
<div
|
|
64
|
+
v-if="toast.life && showProgress"
|
|
65
|
+
class="toast__progress"
|
|
66
|
+
>
|
|
67
|
+
<div
|
|
68
|
+
class="toast__progress-bar"
|
|
69
|
+
:class="`toast__progress-bar--${toast.severity || 'default'}`"
|
|
70
|
+
:style="{ animationDuration: `${toast.life}ms` }"
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</TransitionGroup>
|
|
75
|
+
</div>
|
|
76
|
+
</Teleport>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<style src="./Toast.scss"></style>
|
|
80
|
+
|
|
81
|
+
<script setup lang="ts">
|
|
82
|
+
import type { ToastProps } from '../../types';
|
|
83
|
+
import { ref, onMounted, onUnmounted } from "vue";
|
|
84
|
+
|
|
85
|
+
defineOptions({ name: 'FtpToast' });
|
|
86
|
+
|
|
87
|
+
const props = withDefaults(defineProps<ToastProps>(), {
|
|
88
|
+
position: "top-right",
|
|
89
|
+
group: null,
|
|
90
|
+
showIcon: true,
|
|
91
|
+
showProgress: true,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const toasts = ref<any[]>([]);
|
|
95
|
+
let toastIdCounter = 0;
|
|
96
|
+
const timeoutIds = new Map();
|
|
97
|
+
|
|
98
|
+
function add(toast: any) {
|
|
99
|
+
const id = ++toastIdCounter;
|
|
100
|
+
const newToast = {
|
|
101
|
+
id,
|
|
102
|
+
severity: "default",
|
|
103
|
+
closable: true,
|
|
104
|
+
life: 3000,
|
|
105
|
+
...toast,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
toasts.value.push(newToast);
|
|
109
|
+
|
|
110
|
+
if (newToast.life > 0) {
|
|
111
|
+
const timeoutId = setTimeout(() => {
|
|
112
|
+
timeoutIds.delete(id);
|
|
113
|
+
removeToast(id);
|
|
114
|
+
}, newToast.life);
|
|
115
|
+
timeoutIds.set(id, timeoutId);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return id;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function removeToast(id: any) {
|
|
122
|
+
const timeoutId = timeoutIds.get(id);
|
|
123
|
+
if (timeoutId) {
|
|
124
|
+
clearTimeout(timeoutId);
|
|
125
|
+
timeoutIds.delete(id);
|
|
126
|
+
}
|
|
127
|
+
const index = toasts.value.findIndex((t) => t.id === id);
|
|
128
|
+
if (index > -1) {
|
|
129
|
+
toasts.value.splice(index, 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function removeGroup(group: any) {
|
|
134
|
+
toasts.value.filter((t) => t.group === group).forEach((t) => {
|
|
135
|
+
const timeoutId = timeoutIds.get(t.id);
|
|
136
|
+
if (timeoutId) {
|
|
137
|
+
clearTimeout(timeoutId);
|
|
138
|
+
timeoutIds.delete(t.id);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
toasts.value = toasts.value.filter((t) => t.group !== group);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function removeAllGroups() {
|
|
145
|
+
timeoutIds.forEach((timeoutId) => clearTimeout(timeoutId));
|
|
146
|
+
timeoutIds.clear();
|
|
147
|
+
toasts.value = [];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
onUnmounted(() => {
|
|
151
|
+
timeoutIds.forEach((timeoutId) => clearTimeout(timeoutId));
|
|
152
|
+
timeoutIds.clear();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Expose methods for external use
|
|
156
|
+
defineExpose({
|
|
157
|
+
add,
|
|
158
|
+
remove: removeToast,
|
|
159
|
+
removeGroup,
|
|
160
|
+
removeAllGroups,
|
|
161
|
+
});
|
|
162
|
+
</script>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
@use "../../../dist/scss/tokens" as *;
|
|
2
|
+
|
|
3
|
+
$c: toggle-button;
|
|
4
|
+
|
|
5
|
+
.#{$c} {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
gap: var(--toggleButton-gap, $toggleButton-gap);
|
|
10
|
+
border: var(--toggleButton-border-width, $toggleButton-border-width) solid var(--toggleButton-border-off-default, $toggleButton-border-off-default);
|
|
11
|
+
border-radius: var(--toggleButton-radius, $toggleButton-radius);
|
|
12
|
+
background-color: var(--toggleButton-background-off-default, $toggleButton-background-off-default);
|
|
13
|
+
color: var(--toggleButton-text-off-default, $toggleButton-text-off-default);
|
|
14
|
+
font-weight: var(--toggleButton-fontWeight, $toggleButton-fontWeight);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
user-select: none;
|
|
17
|
+
transition: all var(--toggleButton-transition-duration, $toggleButton-transition-duration) ease;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.#{$c}__icon {
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.#{$c}__label {
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Hover state (off)
|
|
32
|
+
.#{$c}:hover:not(.#{$c}--disabled):not(.#{$c}--checked) {
|
|
33
|
+
background-color: var(--toggleButton-background-off-hover, $toggleButton-background-off-hover);
|
|
34
|
+
border-color: var(--toggleButton-border-off-hover, $toggleButton-border-off-hover);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Focus state
|
|
38
|
+
.#{$c}:focus-visible {
|
|
39
|
+
outline: var(--toggleButton-focus-ringWidth, $toggleButton-focus-ringWidth) solid var(--toggleButton-focus-ringColor, $toggleButton-focus-ringColor);
|
|
40
|
+
outline-offset: var(--toggleButton-focus-ringOffset, $toggleButton-focus-ringOffset);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Checked state
|
|
44
|
+
.#{$c}--checked {
|
|
45
|
+
background-color: var(--toggleButton-background-on-default, $toggleButton-background-on-default);
|
|
46
|
+
border-color: var(--toggleButton-border-on-default, $toggleButton-border-on-default);
|
|
47
|
+
color: var(--toggleButton-text-on-default, $toggleButton-text-on-default);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Hover state (on)
|
|
51
|
+
.#{$c}--checked:hover:not(.#{$c}--disabled) {
|
|
52
|
+
background-color: var(--toggleButton-background-on-hover, $toggleButton-background-on-hover);
|
|
53
|
+
border-color: var(--toggleButton-border-on-hover, $toggleButton-border-on-hover);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Disabled state
|
|
57
|
+
.#{$c}--disabled {
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
background-color: var(--toggleButton-background-disabled, $toggleButton-background-disabled);
|
|
60
|
+
border-color: var(--toggleButton-border-disabled, $toggleButton-border-disabled);
|
|
61
|
+
color: var(--toggleButton-text-disabled, $toggleButton-text-disabled);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Sizes
|
|
65
|
+
.#{$c}--size-sm {
|
|
66
|
+
height: var(--toggleButton-height-sm, $toggleButton-height-sm);
|
|
67
|
+
padding: var(--toggleButton-padding-sm-y, $toggleButton-padding-sm-y) var(--toggleButton-padding-sm-x, $toggleButton-padding-sm-x);
|
|
68
|
+
font-size: var(--toggleButton-fontSize-sm, $toggleButton-fontSize-sm);
|
|
69
|
+
|
|
70
|
+
.#{$c}__icon {
|
|
71
|
+
width: var(--toggleButton-iconSize-sm, $toggleButton-iconSize-sm);
|
|
72
|
+
height: var(--toggleButton-iconSize-sm, $toggleButton-iconSize-sm);
|
|
73
|
+
font-size: var(--toggleButton-iconSize-sm, $toggleButton-iconSize-sm);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.#{$c}--size-md {
|
|
78
|
+
height: var(--toggleButton-height-md, $toggleButton-height-md);
|
|
79
|
+
padding: var(--toggleButton-padding-md-y, $toggleButton-padding-md-y) var(--toggleButton-padding-md-x, $toggleButton-padding-md-x);
|
|
80
|
+
font-size: var(--toggleButton-fontSize-md, $toggleButton-fontSize-md);
|
|
81
|
+
|
|
82
|
+
.#{$c}__icon {
|
|
83
|
+
width: var(--toggleButton-iconSize-md, $toggleButton-iconSize-md);
|
|
84
|
+
height: var(--toggleButton-iconSize-md, $toggleButton-iconSize-md);
|
|
85
|
+
font-size: var(--toggleButton-iconSize-md, $toggleButton-iconSize-md);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.#{$c}--size-lg {
|
|
90
|
+
height: var(--toggleButton-height-lg, $toggleButton-height-lg);
|
|
91
|
+
padding: var(--toggleButton-padding-lg-y, $toggleButton-padding-lg-y) var(--toggleButton-padding-lg-x, $toggleButton-padding-lg-x);
|
|
92
|
+
font-size: var(--toggleButton-fontSize-lg, $toggleButton-fontSize-lg);
|
|
93
|
+
|
|
94
|
+
.#{$c}__icon {
|
|
95
|
+
width: var(--toggleButton-iconSize-lg, $toggleButton-iconSize-lg);
|
|
96
|
+
height: var(--toggleButton-iconSize-lg, $toggleButton-iconSize-lg);
|
|
97
|
+
font-size: var(--toggleButton-iconSize-lg, $toggleButton-iconSize-lg);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<button
|
|
3
|
+
type="button"
|
|
4
|
+
class="toggle-button"
|
|
5
|
+
:class="additionalClasses"
|
|
6
|
+
:disabled="isDisabled"
|
|
7
|
+
:aria-pressed="modelValue"
|
|
8
|
+
@click="onClick"
|
|
9
|
+
>
|
|
10
|
+
<span v-if="currentIcon" class="toggle-button__icon">
|
|
11
|
+
<slot name="icon" :value="modelValue">
|
|
12
|
+
<i :class="currentIcon"></i>
|
|
13
|
+
</slot>
|
|
14
|
+
</span>
|
|
15
|
+
<span v-if="currentLabel" class="toggle-button__label">
|
|
16
|
+
{{ currentLabel }}
|
|
17
|
+
</span>
|
|
18
|
+
</button>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<style src="./ToggleButton.scss"></style>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import type { ToggleButtonProps, ToggleButtonEmits } from '../../types';
|
|
25
|
+
import { computed } from "vue";
|
|
26
|
+
|
|
27
|
+
defineOptions({ name: 'FtpToggleButton' });
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(defineProps<ToggleButtonProps>(), {
|
|
30
|
+
modelValue: false,
|
|
31
|
+
onLabel: "",
|
|
32
|
+
offLabel: "",
|
|
33
|
+
onIcon: "",
|
|
34
|
+
offIcon: "",
|
|
35
|
+
size: "md",
|
|
36
|
+
isDisabled: false,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const emit = defineEmits(["update:modelValue", "change"]);
|
|
40
|
+
|
|
41
|
+
const onClick = (event: MouseEvent) => {
|
|
42
|
+
if (props.isDisabled) return;
|
|
43
|
+
const newValue = !props.modelValue;
|
|
44
|
+
emit("update:modelValue", newValue);
|
|
45
|
+
emit("change", { value: newValue, originalEvent: event });
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const currentLabel = computed(() => {
|
|
49
|
+
return props.modelValue ? props.onLabel : props.offLabel;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const currentIcon = computed(() => {
|
|
53
|
+
return props.modelValue ? props.onIcon : props.offIcon;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const additionalClasses = computed(() =>
|
|
57
|
+
[
|
|
58
|
+
`toggle-button--size-${props.size}`,
|
|
59
|
+
props.modelValue && "toggle-button--checked",
|
|
60
|
+
props.isDisabled && "toggle-button--disabled",
|
|
61
|
+
]
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.join(" ")
|
|
64
|
+
);
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
@use "../../../dist/scss/tokens" as *;
|
|
2
|
+
@use "../../scss/mixins/accent-gradient.scss" as *;
|
|
3
|
+
|
|
4
|
+
$c: toggle-switch;
|
|
5
|
+
|
|
6
|
+
.#{$c} {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
user-select: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.#{$c}__input {
|
|
14
|
+
position: absolute;
|
|
15
|
+
opacity: 0;
|
|
16
|
+
width: 0;
|
|
17
|
+
height: 0;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.#{$c}__track {
|
|
22
|
+
position: relative;
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
width: var(--toggleSwitch-width-md, $toggleSwitch-width-md);
|
|
27
|
+
height: var(--toggleSwitch-height-md, $toggleSwitch-height-md);
|
|
28
|
+
background-color: var(--toggleSwitch-track-background-off, $toggleSwitch-track-background-off);
|
|
29
|
+
border-radius: 9999px;
|
|
30
|
+
transition: background-color 0.2s ease;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.#{$c}__thumb {
|
|
34
|
+
position: absolute;
|
|
35
|
+
left: var(--toggleSwitch-thumb-offset, $toggleSwitch-thumb-offset);
|
|
36
|
+
width: var(--toggleSwitch-thumb-size-md, $toggleSwitch-thumb-size-md);
|
|
37
|
+
height: var(--toggleSwitch-thumb-size-md, $toggleSwitch-thumb-size-md);
|
|
38
|
+
background-color: var(--toggleSwitch-thumb-color-default, $toggleSwitch-thumb-color-default);
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
box-shadow: var(--toggleSwitch-thumb-shadow, $toggleSwitch-thumb-shadow);
|
|
41
|
+
transition: transform 0.2s ease;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Focus state
|
|
45
|
+
.#{$c}__input:focus-visible ~ .#{$c}__track {
|
|
46
|
+
outline: var(--toggleSwitch-focus-ringWidth, $toggleSwitch-focus-ringWidth) solid var(--toggleSwitch-focus-ringColor, $toggleSwitch-focus-ringColor);
|
|
47
|
+
outline-offset: var(--toggleSwitch-focus-ringOffset, $toggleSwitch-focus-ringOffset);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Checked state
|
|
51
|
+
.#{$c}--checked {
|
|
52
|
+
.#{$c}__track {
|
|
53
|
+
@include accent-gradient($angle: 90deg);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.#{$c}__thumb {
|
|
57
|
+
transform: translateX(calc(var(--toggleSwitch-width-md, $toggleSwitch-width-md) - var(--toggleSwitch-thumb-size-md, $toggleSwitch-thumb-size-md) - var(--toggleSwitch-thumb-offset, $toggleSwitch-thumb-offset) * 2));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Disabled state
|
|
62
|
+
.#{$c}--disabled {
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
|
|
65
|
+
.#{$c}__track {
|
|
66
|
+
background-color: var(--toggleSwitch-track-background-disabled, $toggleSwitch-track-background-disabled);
|
|
67
|
+
}
|
|
68
|
+
}
|