@umbra.ui/core 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/components/controls/Dropdown/types.d.ts +5 -0
- package/dist/components/controls/Dropdown/types.d.ts.map +1 -0
- package/dist/components/controls/Dropdown/types.js +1 -0
- package/dist/components/controls/SegmentedControl/types.d.ts +6 -0
- package/dist/components/controls/SegmentedControl/types.d.ts.map +1 -0
- package/dist/components/controls/SegmentedControl/types.js +1 -0
- package/dist/components/dialogs/Alert/types.d.ts +7 -0
- package/dist/components/dialogs/Alert/types.d.ts.map +1 -0
- package/dist/components/dialogs/Alert/types.js +1 -0
- package/dist/components/dialogs/Toast/types.d.ts +34 -0
- package/dist/components/dialogs/Toast/types.d.ts.map +1 -0
- package/dist/components/dialogs/Toast/types.js +10 -0
- package/dist/components/dialogs/Toast/useToast.d.ts +36 -0
- package/dist/components/dialogs/Toast/useToast.d.ts.map +1 -0
- package/dist/components/dialogs/Toast/useToast.js +90 -0
- package/dist/components/indicators/Tooltip/tooltip.d.ts +3 -0
- package/dist/components/indicators/Tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/indicators/Tooltip/tooltip.js +33 -0
- package/dist/components/indicators/Tooltip/types.d.ts +14 -0
- package/dist/components/indicators/Tooltip/types.d.ts.map +1 -0
- package/dist/components/indicators/Tooltip/types.js +1 -0
- package/dist/components/indicators/Tooltip/useTooltip.d.ts +18 -0
- package/dist/components/indicators/Tooltip/useTooltip.d.ts.map +1 -0
- package/dist/components/indicators/Tooltip/useTooltip.js +57 -0
- package/dist/components/inputs/Tags/tag-bar-styles.d.ts +14 -0
- package/dist/components/inputs/Tags/tag-bar-styles.d.ts.map +1 -0
- package/dist/components/inputs/Tags/tag-bar-styles.js +313 -0
- package/dist/components/inputs/Tags/types.d.ts +93 -0
- package/dist/components/inputs/Tags/types.d.ts.map +1 -0
- package/dist/components/inputs/Tags/types.js +216 -0
- package/dist/components/inputs/search/types.d.ts +9 -0
- package/dist/components/inputs/search/types.d.ts.map +1 -0
- package/dist/components/inputs/search/types.js +1 -0
- package/dist/components/navigation/adaptive/types.d.ts +16 -0
- package/dist/components/navigation/adaptive/types.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/types.js +1 -0
- package/dist/components/navigation/adaptive/useAdaptiveLayout.d.ts +27 -0
- package/dist/components/navigation/adaptive/useAdaptiveLayout.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useAdaptiveLayout.js +40 -0
- package/dist/components/navigation/adaptive/useBreakpoints.d.ts +6 -0
- package/dist/components/navigation/adaptive/useBreakpoints.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useBreakpoints.js +37 -0
- package/dist/components/navigation/adaptive/useContainerMonitor.d.ts +93 -0
- package/dist/components/navigation/adaptive/useContainerMonitor.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useContainerMonitor.js +145 -0
- package/dist/components/navigation/adaptive/useViewAnimation.d.ts +31 -0
- package/dist/components/navigation/adaptive/useViewAnimation.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useViewAnimation.js +591 -0
- package/dist/components/navigation/adaptive/useViewResize.d.ts +52 -0
- package/dist/components/navigation/adaptive/useViewResize.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useViewResize.js +146 -0
- package/dist/components/navigation/navstack/useNavigationStack.d.ts +25 -0
- package/dist/components/navigation/navstack/useNavigationStack.d.ts.map +1 -0
- package/dist/components/navigation/navstack/useNavigationStack.js +133 -0
- package/dist/components/navigation/slideover/useSlideoverController.d.ts +20 -0
- package/dist/components/navigation/slideover/useSlideoverController.d.ts.map +1 -0
- package/dist/components/navigation/slideover/useSlideoverController.js +267 -0
- package/dist/components/navigation/splitview/useSplitViewController.d.ts +20 -0
- package/dist/components/navigation/splitview/useSplitViewController.d.ts.map +1 -0
- package/dist/components/navigation/splitview/useSplitViewController.js +325 -0
- package/dist/components/navigation/tabcontroller/types.d.ts +21 -0
- package/dist/components/navigation/tabcontroller/types.d.ts.map +1 -0
- package/dist/components/navigation/tabcontroller/types.js +1 -0
- package/dist/components/navigation/tabcontroller/useTabController.d.ts +5 -0
- package/dist/components/navigation/tabcontroller/useTabController.d.ts.map +1 -0
- package/dist/components/navigation/tabcontroller/useTabController.js +10 -0
- package/dist/components/navigation/types.d.ts +8 -0
- package/dist/components/navigation/types.d.ts.map +1 -0
- package/dist/components/navigation/types.js +1 -0
- package/dist/components/pickers/CollectionPicker/types.d.ts +11 -0
- package/dist/components/pickers/CollectionPicker/types.d.ts.map +1 -0
- package/dist/components/pickers/CollectionPicker/types.js +1 -0
- package/dist/components/pickers/ColorPicker/colors.d.ts +13 -0
- package/dist/components/pickers/ColorPicker/colors.d.ts.map +1 -0
- package/dist/components/pickers/ColorPicker/colors.js +266 -0
- package/dist/components/pickers/FilePicker/types.d.ts +10 -0
- package/dist/components/pickers/FilePicker/types.d.ts.map +1 -0
- package/dist/components/pickers/FilePicker/types.js +1 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +196 -0
- package/dist/theme.d.ts +73 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +279 -0
- package/dist/themes/blank.d.ts +7 -0
- package/dist/themes/blank.d.ts.map +1 -0
- package/dist/themes/blank.js +543 -0
- package/dist/themes/crimson-dark.d.ts +4 -0
- package/dist/themes/crimson-dark.d.ts.map +1 -0
- package/dist/themes/crimson-dark.js +552 -0
- package/dist/themes/cyan-light.d.ts +4 -0
- package/dist/themes/cyan-light.d.ts.map +1 -0
- package/dist/themes/cyan-light.js +552 -0
- package/dist/themes/dark.d.ts +4 -0
- package/dist/themes/dark.d.ts.map +1 -0
- package/dist/themes/dark.js +551 -0
- package/dist/themes/gold-dark.d.ts +4 -0
- package/dist/themes/gold-dark.d.ts.map +1 -0
- package/dist/themes/gold-dark.js +552 -0
- package/dist/themes/grass-dark.d.ts +4 -0
- package/dist/themes/grass-dark.d.ts.map +1 -0
- package/dist/themes/grass-dark.js +552 -0
- package/dist/themes/indigo.d.ts +4 -0
- package/dist/themes/indigo.d.ts.map +1 -0
- package/dist/themes/indigo.js +552 -0
- package/dist/themes/light.d.ts +4 -0
- package/dist/themes/light.d.ts.map +1 -0
- package/dist/themes/light.js +551 -0
- package/dist/themes/orange-dark.d.ts +4 -0
- package/dist/themes/orange-dark.d.ts.map +1 -0
- package/dist/themes/orange-dark.js +551 -0
- package/dist/themes/orange-light.d.ts +4 -0
- package/dist/themes/orange-light.d.ts.map +1 -0
- package/dist/themes/orange-light.js +551 -0
- package/package.json +62 -0
- package/src/components/controls/Button/Button.vue +417 -0
- package/src/components/controls/Button/README.md +348 -0
- package/src/components/controls/Button/theme.css +200 -0
- package/src/components/controls/Checkbox/Checkbox.vue +164 -0
- package/src/components/controls/Checkbox/README.md +441 -0
- package/src/components/controls/Checkbox/theme.css +36 -0
- package/src/components/controls/Dropdown/Dropdown.vue +476 -0
- package/src/components/controls/Dropdown/README.md +370 -0
- package/src/components/controls/Dropdown/theme.css +50 -0
- package/src/components/controls/Dropdown/types.ts +6 -0
- package/src/components/controls/IconButton/IconButton.vue +267 -0
- package/src/components/controls/IconButton/README.md +502 -0
- package/src/components/controls/IconButton/theme.css +89 -0
- package/src/components/controls/Radio/README.md +591 -0
- package/src/components/controls/Radio/Radio.vue +89 -0
- package/src/components/controls/Radio/theme.css +14 -0
- package/src/components/controls/RangeSlider/README.md +608 -0
- package/src/components/controls/RangeSlider/RangeSlider.vue +535 -0
- package/src/components/controls/RangeSlider/theme.css +80 -0
- package/src/components/controls/SegmentedControl/README.md +587 -0
- package/src/components/controls/SegmentedControl/SegmentedControl.vue +284 -0
- package/src/components/controls/SegmentedControl/theme.css +60 -0
- package/src/components/controls/SegmentedControl/types.ts +5 -0
- package/src/components/controls/Slider/README.md +627 -0
- package/src/components/controls/Slider/Slider.vue +260 -0
- package/src/components/controls/Slider/theme.css +74 -0
- package/src/components/controls/Stepper/README.md +601 -0
- package/src/components/controls/Stepper/Stepper.vue +103 -0
- package/src/components/controls/Stepper/theme.css +53 -0
- package/src/components/controls/Switch/README.md +667 -0
- package/src/components/controls/Switch/Switch.vue +127 -0
- package/src/components/controls/Switch/theme.css +42 -0
- package/src/components/dialogs/Alert/Alert.vue +218 -0
- package/src/components/dialogs/Alert/README.md +450 -0
- package/src/components/dialogs/Alert/theme.css +44 -0
- package/src/components/dialogs/Alert/types.ts +11 -0
- package/src/components/dialogs/Toast/README.md +522 -0
- package/src/components/dialogs/Toast/Toast.vue +296 -0
- package/src/components/dialogs/Toast/ToastContainer.vue +330 -0
- package/src/components/dialogs/Toast/theme.css +44 -0
- package/src/components/dialogs/Toast/types.ts +46 -0
- package/src/components/dialogs/Toast/useToast.ts +127 -0
- package/src/components/indicators/ProgressBar/ProgressBar.vue +98 -0
- package/src/components/indicators/ProgressBar/README.md +744 -0
- package/src/components/indicators/ProgressBar/theme.css +36 -0
- package/src/components/indicators/Tooltip/README.md +723 -0
- package/src/components/indicators/Tooltip/TooltipProvider.vue +142 -0
- package/src/components/indicators/Tooltip/theme.css +18 -0
- package/src/components/indicators/Tooltip/tooltip.ts +48 -0
- package/src/components/indicators/Tooltip/types.ts +15 -0
- package/src/components/indicators/Tooltip/useTooltip.ts +71 -0
- package/src/components/inputs/AutogrowTextView/AutogrowTextView.vue +110 -0
- package/src/components/inputs/AutogrowTextView/README.md +643 -0
- package/src/components/inputs/AutogrowTextView/theme.css +28 -0
- package/src/components/inputs/InputCard/InputCard.vue +600 -0
- package/src/components/inputs/InputCard/README.md +636 -0
- package/src/components/inputs/InputEmail/InputEmail.vue +698 -0
- package/src/components/inputs/InputEmail/README.md +764 -0
- package/src/components/inputs/InputNumber/InputNumber.vue +300 -0
- package/src/components/inputs/InputNumber/README.md +749 -0
- package/src/components/inputs/InputPhone/InputPhone.vue +645 -0
- package/src/components/inputs/InputPhone/README.md +636 -0
- package/src/components/inputs/InputSecure/InputSecure.vue +646 -0
- package/src/components/inputs/InputSecure/README.md +771 -0
- package/src/components/inputs/InputText/InputText.vue +225 -0
- package/src/components/inputs/InputText/README.md +844 -0
- package/src/components/inputs/OTP/OTP.vue +349 -0
- package/src/components/inputs/OTP/README.md +736 -0
- package/src/components/inputs/OTP/theme.css +50 -0
- package/src/components/inputs/StringCapture/README.md +718 -0
- package/src/components/inputs/StringCapture/StringCapture.vue +315 -0
- package/src/components/inputs/StringCapture/theme.css +86 -0
- package/src/components/inputs/Tags/README.md +897 -0
- package/src/components/inputs/Tags/TagBar.vue +793 -0
- package/src/components/inputs/Tags/TagCreation.vue +219 -0
- package/src/components/inputs/Tags/TagPicker.vue +380 -0
- package/src/components/inputs/Tags/tag-bar-styles.ts +354 -0
- package/src/components/inputs/Tags/theme.css +121 -0
- package/src/components/inputs/Tags/types.ts +346 -0
- package/src/components/inputs/search/README.md +759 -0
- package/src/components/inputs/search/SearchBar.vue +394 -0
- package/src/components/inputs/search/SearchResults.vue +310 -0
- package/src/components/inputs/search/theme.css +187 -0
- package/src/components/inputs/search/types.ts +8 -0
- package/src/components/inputs/theme.css +102 -0
- package/src/components/menus/ActionMenu/ActionMenu.vue +383 -0
- package/src/components/menus/ActionMenu/README.md +825 -0
- package/src/components/menus/ActionMenu/theme.css +93 -0
- package/src/components/models/Popover/Popover.vue +551 -0
- package/src/components/models/Popover/README.md +885 -0
- package/src/components/models/Popover/theme.css +52 -0
- package/src/components/models/Sheet/README.md +1159 -0
- package/src/components/models/Sheet/Sheet.vue +465 -0
- package/src/components/models/Sheet/theme.css +72 -0
- package/src/components/models/Sidebar/README.md +1228 -0
- package/src/components/models/Sidebar/Sidebar.vue +480 -0
- package/src/components/models/Sidebar/theme.css +90 -0
- package/src/components/navigation/adaptive/AdaptiveLayout.vue +779 -0
- package/src/components/navigation/adaptive/AdaptiveLayoutBreadcrumbs.vue +192 -0
- package/src/components/navigation/adaptive/AdaptiveLayoutMenuButton.vue +149 -0
- package/src/components/navigation/adaptive/README.md +768 -0
- package/src/components/navigation/adaptive/types.ts +19 -0
- package/src/components/navigation/adaptive/useAdaptiveLayout.ts +89 -0
- package/src/components/navigation/adaptive/useBreakpoints.ts +41 -0
- package/src/components/navigation/adaptive/useContainerMonitor.ts +214 -0
- package/src/components/navigation/adaptive/useViewAnimation.ts +721 -0
- package/src/components/navigation/adaptive/useViewResize.ts +211 -0
- package/src/components/navigation/navstack/NavigationStack.vue +180 -0
- package/src/components/navigation/navstack/README.md +994 -0
- package/src/components/navigation/navstack/useNavigationStack.ts +164 -0
- package/src/components/navigation/slideover/README.md +1275 -0
- package/src/components/navigation/slideover/SlideoverController.vue +287 -0
- package/src/components/navigation/slideover/useSlideoverController.ts +320 -0
- package/src/components/navigation/splitview/README.md +1115 -0
- package/src/components/navigation/splitview/SplitViewController.vue +176 -0
- package/src/components/navigation/splitview/useSplitViewController.ts +388 -0
- package/src/components/navigation/tabcontroller/README.md +919 -0
- package/src/components/navigation/tabcontroller/TabController.vue +307 -0
- package/src/components/navigation/tabcontroller/TabItem.vue +57 -0
- package/src/components/navigation/tabcontroller/types.ts +24 -0
- package/src/components/navigation/tabcontroller/useTabController.ts +18 -0
- package/src/components/navigation/theme.css +91 -0
- package/src/components/navigation/types.ts +7 -0
- package/src/components/pickers/CollectionPicker/CollectionPicker.vue +398 -0
- package/src/components/pickers/CollectionPicker/README.md +1115 -0
- package/src/components/pickers/CollectionPicker/theme.css +14 -0
- package/src/components/pickers/CollectionPicker/types.ts +11 -0
- package/src/components/pickers/ColorPicker/ColorPicker.vue +376 -0
- package/src/components/pickers/ColorPicker/README.md +1439 -0
- package/src/components/pickers/ColorPicker/colors.ts +299 -0
- package/src/components/pickers/ColorPicker/theme.css +32 -0
- package/src/components/pickers/DatePicker/DatePicker.vue +660 -0
- package/src/components/pickers/DatePicker/README.md +1195 -0
- package/src/components/pickers/DatePicker/theme.css +22 -0
- package/src/components/pickers/FilePicker/FilePicker.vue +534 -0
- package/src/components/pickers/FilePicker/README.md +1542 -0
- package/src/components/pickers/FilePicker/theme.css +48 -0
- package/src/components/pickers/FilePicker/types.ts +10 -0
- package/src/components/pickers/IconPicker/IconPicker.vue +327 -0
- package/src/components/pickers/IconPicker/README.md +1161 -0
- package/src/components/pickers/IconPicker/theme.css +28 -0
- package/src/components/pickers/theme.css +82 -0
- package/src/components/views/MarkdownViewer/MarkdownViewer.vue +442 -0
- package/src/components/views/MarkdownViewer/README.md +833 -0
- package/src/components/views/MarkdownViewer/theme.css +130 -0
- package/src/index.ts +263 -0
- package/src/theme.ts +378 -0
- package/src/themes/crimson-dark.ts +556 -0
- package/src/themes/cyan-light.ts +556 -0
- package/src/themes/dark.ts +557 -0
- package/src/themes/gold-dark.ts +556 -0
- package/src/themes/grass-dark.ts +556 -0
- package/src/themes/indigo.ts +556 -0
- package/src/themes/light.ts +557 -0
- package/src/themes/orange-dark.ts +557 -0
- package/src/themes/orange-light.ts +557 -0
- package/src/vue.d.ts +45 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed } from "vue";
|
|
3
|
+
import "./theme.css";
|
|
4
|
+
|
|
5
|
+
export interface Props {
|
|
6
|
+
switchType?: "default" | "outline";
|
|
7
|
+
isChecked?: boolean;
|
|
8
|
+
size?: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const emit = defineEmits(["update:isChecked"]);
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
15
|
+
switchType: "default",
|
|
16
|
+
isChecked: false,
|
|
17
|
+
size: 24, // px value
|
|
18
|
+
color: "var(--switch-default-color)",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const colorWithOpacity = computed(() => {
|
|
22
|
+
return `color-mix(in srgb, ${props.color} 25%, transparent)`;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Convert px to rem (assuming 17px base)
|
|
26
|
+
const pxToRem = (px: number) => px / 17;
|
|
27
|
+
|
|
28
|
+
// Calculate dynamic values based on size prop
|
|
29
|
+
const padding = computed(() => pxToRem(2)); // 2px padding
|
|
30
|
+
const borderWidth = computed(() =>
|
|
31
|
+
pxToRem(Math.max(2, Math.round(props.size * 0.08)))
|
|
32
|
+
); // ~8% of size, min 2px
|
|
33
|
+
const switchSize = computed(() => pxToRem(props.size)); // The knob size in rem
|
|
34
|
+
const containerHeight = computed(
|
|
35
|
+
() => switchSize.value + padding.value * 2 + borderWidth.value * 2
|
|
36
|
+
);
|
|
37
|
+
const containerWidth = computed(
|
|
38
|
+
() => switchSize.value * 2 + padding.value * 2 + borderWidth.value * 2
|
|
39
|
+
);
|
|
40
|
+
const translateDistance = computed(() => switchSize.value); // Move by exactly one knob width
|
|
41
|
+
|
|
42
|
+
const onClick = () => {
|
|
43
|
+
emit("update:isChecked", !props.isChecked);
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<div
|
|
49
|
+
:class="[$style.container, { [$style.checked]: isChecked }, $style[switchType!]]"
|
|
50
|
+
@click="onClick"
|
|
51
|
+
:style="{
|
|
52
|
+
'--switch-color': color,
|
|
53
|
+
'--switch-color-opacity': colorWithOpacity,
|
|
54
|
+
'--container-width': `${containerWidth}rem`,
|
|
55
|
+
'--container-height': `${containerHeight}rem`,
|
|
56
|
+
'--padding': `${padding}rem`,
|
|
57
|
+
'--switch-size': `${switchSize}rem`,
|
|
58
|
+
'--translate-distance': `${translateDistance}rem`,
|
|
59
|
+
'--border-width': `${borderWidth}rem`,
|
|
60
|
+
'--border-radius': `${containerHeight / 2}rem`,
|
|
61
|
+
}"
|
|
62
|
+
>
|
|
63
|
+
<div :class="$style.switch"></div>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<style module>
|
|
68
|
+
.container {
|
|
69
|
+
width: var(--container-width);
|
|
70
|
+
height: var(--container-height);
|
|
71
|
+
padding: var(--padding);
|
|
72
|
+
border-radius: var(--border-radius);
|
|
73
|
+
border: var(--border-width) solid;
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
transition: background-color 0.3s ease, border-color 0.3s ease;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.container.default {
|
|
82
|
+
background-color: var(--switch-default-bg);
|
|
83
|
+
border-color: var(--switch-default-border);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.container.checked.default {
|
|
87
|
+
background-color: var(--switch-color);
|
|
88
|
+
border-color: var(--switch-color);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.container.outline {
|
|
92
|
+
background-color: transparent;
|
|
93
|
+
border-color: var(--switch-outline-border);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.container.checked.outline {
|
|
97
|
+
background-color: var(--switch-color-opacity);
|
|
98
|
+
border-color: var(--switch-color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.switch {
|
|
102
|
+
width: var(--switch-size);
|
|
103
|
+
height: var(--switch-size);
|
|
104
|
+
border-radius: 50%;
|
|
105
|
+
transition: transform 0.3s ease;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.container.default .switch {
|
|
109
|
+
background-color: var(--switch-default-switch);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.container.outline .switch {
|
|
113
|
+
background-color: var(--switch-outline-switch);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.container.checked.default .switch {
|
|
117
|
+
background-color: var(--switch-default-switch-checked);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.container.checked.outline .switch {
|
|
121
|
+
background-color: var(--switch-color);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.container.checked .switch {
|
|
125
|
+
transform: translateX(var(--translate-distance));
|
|
126
|
+
}
|
|
127
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* Light theme using Colors */
|
|
2
|
+
:root {
|
|
3
|
+
/* Switch default colors */
|
|
4
|
+
--switch-default-bg: #e3e5e8; /* gray5 - light background for light mode */
|
|
5
|
+
--switch-default-border: rgba(
|
|
6
|
+
0,
|
|
7
|
+
0,
|
|
8
|
+
0,
|
|
9
|
+
0.04
|
|
10
|
+
); /* blackA2 - subtle border for light mode */
|
|
11
|
+
--switch-default-switch: #8b8d98; /* gray9 - muted color for light mode */
|
|
12
|
+
--switch-default-switch-checked: #ffffff; /* white - for checked state in light mode */
|
|
13
|
+
|
|
14
|
+
/* Switch outline colors */
|
|
15
|
+
--switch-outline-border: #9b9ea6; /* gray8 - light border for light mode */
|
|
16
|
+
--switch-outline-switch: #8b8d98; /* gray9 - muted color for light mode */
|
|
17
|
+
|
|
18
|
+
/* Switch default color scheme */
|
|
19
|
+
--switch-default-color: #0090ff; /* green9 - default switch color */
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Dark theme */
|
|
23
|
+
.dark,
|
|
24
|
+
.dark-theme {
|
|
25
|
+
/* Switch default colors */
|
|
26
|
+
--switch-default-bg: #484848; /* Original dark mode value */
|
|
27
|
+
--switch-default-border: rgba(
|
|
28
|
+
255,
|
|
29
|
+
255,
|
|
30
|
+
255,
|
|
31
|
+
0.05
|
|
32
|
+
); /* Original dark mode value */
|
|
33
|
+
--switch-default-switch: #b4b4b4; /* Original dark mode value */
|
|
34
|
+
--switch-default-switch-checked: #eeeeee; /* Original dark mode value */
|
|
35
|
+
|
|
36
|
+
/* Switch outline colors */
|
|
37
|
+
--switch-outline-border: #484848; /* Original dark mode value */
|
|
38
|
+
--switch-outline-switch: #484848; /* Original dark mode value */
|
|
39
|
+
|
|
40
|
+
/* Switch default color scheme */
|
|
41
|
+
--switch-default-color: #0090ff; /* green9 - default switch color */
|
|
42
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<!-- ================================================================================================ -->
|
|
2
|
+
<!-- SCRIPT -->
|
|
3
|
+
<!-- ================================================================================================ -->
|
|
4
|
+
<script setup lang="ts">
|
|
5
|
+
import { watch, ref } from "vue";
|
|
6
|
+
import Button from "../../controls/Button/Button.vue";
|
|
7
|
+
import { AlertAction, AlertActionType } from "./types";
|
|
8
|
+
import "./theme.css";
|
|
9
|
+
|
|
10
|
+
// Props for customization
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
show: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
title: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
description: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
actions: {
|
|
25
|
+
type: Array as () => AlertAction[],
|
|
26
|
+
required: false,
|
|
27
|
+
default: () => [{ title: "Ok", action: () => {}, type: "Cancel" }],
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits(["update:show"]);
|
|
32
|
+
|
|
33
|
+
watch(
|
|
34
|
+
() => props.show,
|
|
35
|
+
(newValue) => {
|
|
36
|
+
if (newValue === true) {
|
|
37
|
+
showPopup();
|
|
38
|
+
} else if (newValue === false) {
|
|
39
|
+
hidePopup();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const overlayOpacity = ref<number>(0);
|
|
45
|
+
const popupOpacity = ref<number>(0);
|
|
46
|
+
const popoverScale = ref<number>(1.1);
|
|
47
|
+
|
|
48
|
+
// Method to show the popup
|
|
49
|
+
const showPopup = () => {
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
overlayOpacity.value = 1;
|
|
52
|
+
popupOpacity.value = 1;
|
|
53
|
+
popoverScale.value = 1;
|
|
54
|
+
}, 10);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Method to hide the popup
|
|
58
|
+
const hidePopup = () => {
|
|
59
|
+
overlayOpacity.value = 0;
|
|
60
|
+
popupOpacity.value = 0;
|
|
61
|
+
popoverScale.value = 1.1;
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
emit("update:show", false);
|
|
64
|
+
}, 300);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Method to get the color of the button
|
|
68
|
+
const buttonColor = (
|
|
69
|
+
type: AlertActionType
|
|
70
|
+
): "primary" | "secondary" | "tertiary" | "quaternary" | "danger" => {
|
|
71
|
+
switch (type) {
|
|
72
|
+
case "Default":
|
|
73
|
+
return "primary";
|
|
74
|
+
case "Secondary":
|
|
75
|
+
return "secondary";
|
|
76
|
+
case "Cancel":
|
|
77
|
+
return "tertiary";
|
|
78
|
+
case "Destructive":
|
|
79
|
+
return "danger";
|
|
80
|
+
default:
|
|
81
|
+
return "primary";
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const buttonOrder = (type: AlertActionType, index: number) => {
|
|
85
|
+
if (type === "Cancel") {
|
|
86
|
+
if (props.actions.length > 2) {
|
|
87
|
+
return props.actions.length;
|
|
88
|
+
}
|
|
89
|
+
return -1;
|
|
90
|
+
} else if (type === "Default") {
|
|
91
|
+
if (props.actions.length > 2) {
|
|
92
|
+
return -1;
|
|
93
|
+
}
|
|
94
|
+
return props.actions.length;
|
|
95
|
+
}
|
|
96
|
+
return index;
|
|
97
|
+
};
|
|
98
|
+
const onClick = (action: AlertAction) => {
|
|
99
|
+
hidePopup();
|
|
100
|
+
action.action();
|
|
101
|
+
};
|
|
102
|
+
</script>
|
|
103
|
+
<!-- ================================================================================================ -->
|
|
104
|
+
<!-- TEMPLATE -->
|
|
105
|
+
<!-- ================================================================================================ -->
|
|
106
|
+
<template>
|
|
107
|
+
<div>
|
|
108
|
+
<!-- Teleport the overlay and popup to body -->
|
|
109
|
+
<Teleport to="body">
|
|
110
|
+
<div
|
|
111
|
+
v-if="props.show"
|
|
112
|
+
:class="$style.overlay"
|
|
113
|
+
:style="{ opacity: overlayOpacity }"
|
|
114
|
+
></div>
|
|
115
|
+
|
|
116
|
+
<!-- Popup container -->
|
|
117
|
+
<div
|
|
118
|
+
v-if="props.show"
|
|
119
|
+
:class="$style.popup"
|
|
120
|
+
:style="{ opacity: popupOpacity, scale: popoverScale }"
|
|
121
|
+
>
|
|
122
|
+
<div :class="$style.content">
|
|
123
|
+
<!-- Title -->
|
|
124
|
+
<h2 :class="[$style.title, 'headline']">{{ title }}</h2>
|
|
125
|
+
|
|
126
|
+
<!-- Description -->
|
|
127
|
+
<p :class="[$style.description, 'body']">{{ description }}</p>
|
|
128
|
+
|
|
129
|
+
<!-- Actions -->
|
|
130
|
+
<div
|
|
131
|
+
:class="[
|
|
132
|
+
actions.length === 1 ? $style.single_action : '',
|
|
133
|
+
actions.length === 2 ? $style.binary_action : '',
|
|
134
|
+
actions.length > 2 ? $style.multiple_actions : '',
|
|
135
|
+
]"
|
|
136
|
+
>
|
|
137
|
+
<div
|
|
138
|
+
v-for="(action, index) in actions"
|
|
139
|
+
:key="`action-${index}`"
|
|
140
|
+
:style="{ order: buttonOrder(action.type, index) }"
|
|
141
|
+
>
|
|
142
|
+
<Button
|
|
143
|
+
:title="action.title"
|
|
144
|
+
:button-style="buttonColor(action.type)"
|
|
145
|
+
@click="onClick(action)"
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</Teleport>
|
|
152
|
+
</div>
|
|
153
|
+
</template>
|
|
154
|
+
<!-- ================================================================================================ -->
|
|
155
|
+
<!-- STYLE -->
|
|
156
|
+
<!-- ================================================================================================ -->
|
|
157
|
+
<style module>
|
|
158
|
+
.popup {
|
|
159
|
+
position: fixed;
|
|
160
|
+
top: 0;
|
|
161
|
+
left: 0;
|
|
162
|
+
width: 100%;
|
|
163
|
+
height: 100%;
|
|
164
|
+
display: flex;
|
|
165
|
+
justify-content: center;
|
|
166
|
+
align-items: center;
|
|
167
|
+
z-index: 1000;
|
|
168
|
+
transition: 0.2s ease-in-out opacity, 0.2s ease-in-out scale;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.overlay {
|
|
172
|
+
position: fixed;
|
|
173
|
+
top: 0;
|
|
174
|
+
left: 0;
|
|
175
|
+
bottom: 0;
|
|
176
|
+
right: 0;
|
|
177
|
+
background: var(--alert-overlay-bg);
|
|
178
|
+
transition: 0.2s ease-in-out opacity;
|
|
179
|
+
z-index: 999;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.content {
|
|
183
|
+
position: relative;
|
|
184
|
+
background: var(--alert-content-bg);
|
|
185
|
+
padding: 1.176rem;
|
|
186
|
+
border-radius: 0.471rem;
|
|
187
|
+
box-shadow: 0 2px 10px var(--alert-content-shadow);
|
|
188
|
+
z-index: 1001;
|
|
189
|
+
max-width: 20.588rem;
|
|
190
|
+
display: flex;
|
|
191
|
+
flex-direction: column;
|
|
192
|
+
gap: 0.706rem;
|
|
193
|
+
color: var(--alert-content-color);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.title {
|
|
197
|
+
font-weight: bold;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.description {
|
|
201
|
+
opacity: var(--alert-description-opacity);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.single_action {
|
|
205
|
+
display: flex;
|
|
206
|
+
justify-content: end;
|
|
207
|
+
}
|
|
208
|
+
.binary_action {
|
|
209
|
+
display: flex;
|
|
210
|
+
align-items: center;
|
|
211
|
+
gap: 0.706rem;
|
|
212
|
+
}
|
|
213
|
+
.multiple_actions {
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
216
|
+
gap: 0.706rem;
|
|
217
|
+
}
|
|
218
|
+
</style>
|