srcdev-nuxt-forms 6.1.10 → 6.1.11
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.
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="triple-toggle-switch" :data-size="size" :data-theme="theme">
|
|
3
|
+
<div class="triple-toggle-switch-wrapper">
|
|
4
|
+
<div class="selected-option-marker-wrapper">
|
|
5
|
+
<div class="selected-option-marker" :class="[{ show: showMarker }]"></div>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="option-group-wrapper">
|
|
8
|
+
<div v-for="(option, index) in fieldData.data" :key="option.id" class="option-group" ref="optionGroup">
|
|
9
|
+
<Icon v-if="option.icon" :name="option.icon" class="option-icon" ref="optionIcons" />
|
|
10
|
+
<input
|
|
11
|
+
type="radio"
|
|
12
|
+
:id="option.id"
|
|
13
|
+
name="colour-scheme"
|
|
14
|
+
class="option-input"
|
|
15
|
+
v-model="modelValue"
|
|
16
|
+
:value="option.value"
|
|
17
|
+
/>
|
|
18
|
+
<label :for="option.id" class="sr-only">{{ option.label }}</label>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import propValidators from "../../forms/c12/prop-validators"
|
|
27
|
+
|
|
28
|
+
const props = defineProps({
|
|
29
|
+
name: {
|
|
30
|
+
type: String,
|
|
31
|
+
defaul: "triple-toggle-switch",
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
type: String as PropType<string>,
|
|
35
|
+
default: "medium",
|
|
36
|
+
validator(value: string) {
|
|
37
|
+
return propValidators.size.includes(value)
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
theme: {
|
|
41
|
+
type: String as PropType<string>,
|
|
42
|
+
default: "primary",
|
|
43
|
+
validator(value: string) {
|
|
44
|
+
return propValidators.theme.includes(value)
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
stepAnimationDuration: {
|
|
48
|
+
type: Number as PropType<number>,
|
|
49
|
+
default: 100,
|
|
50
|
+
},
|
|
51
|
+
styleClassPassthrough: {
|
|
52
|
+
type: Array as PropType<string[]>,
|
|
53
|
+
default: () => [],
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const modelValue = defineModel()
|
|
58
|
+
|
|
59
|
+
const fieldData = defineModel("fieldData") as Ref<IFormMultipleOptions>
|
|
60
|
+
|
|
61
|
+
const optionGroupRefs = useTemplateRef<HTMLDivElement>("optionGroup")
|
|
62
|
+
|
|
63
|
+
const iconWidth = ref("0px")
|
|
64
|
+
const showMarker = ref(false)
|
|
65
|
+
|
|
66
|
+
const selectedOptionIndex = computed(() => {
|
|
67
|
+
return fieldData.value.data.findIndex((option) => option.value === modelValue.value)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const setupDefaults = () => {
|
|
71
|
+
if (Array.isArray(optionGroupRefs.value) && optionGroupRefs.value[0]) {
|
|
72
|
+
iconWidth.value = optionGroupRefs.value[0].getBoundingClientRect().width + "px"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
onMounted(() => {
|
|
77
|
+
setupDefaults()
|
|
78
|
+
})
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<style lang="css">
|
|
82
|
+
.triple-toggle-switch {
|
|
83
|
+
--_form-border-colour: var(--theme-form-radio-border);
|
|
84
|
+
|
|
85
|
+
--_form-outline-colour: var(--theme-form-radio-outline);
|
|
86
|
+
|
|
87
|
+
--_form-border-radius: calc(
|
|
88
|
+
(var(--_scheme-icon-font-size) / 2) + var(--form-element-border-width) + var(--form-element-outline-width) +
|
|
89
|
+
var(--_form-padding) + var(--_select-scheme-group-padding) + var(--form-element-border-width) +
|
|
90
|
+
var(--form-element-outline-width)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
--_form-items-gap: 1rem;
|
|
94
|
+
--_form-padding: 0.6rem;
|
|
95
|
+
|
|
96
|
+
--_select-scheme-group-background-color: var(--theme-form-checkbox-bg);
|
|
97
|
+
--_select-scheme-group-background-image: none;
|
|
98
|
+
--_select-scheme-group-padding: 0.5rem;
|
|
99
|
+
--_scheme-icon-font-size: 2rem;
|
|
100
|
+
--_scheme-icon-colour: black;
|
|
101
|
+
|
|
102
|
+
&:has(input[value="auto"]:checked) {
|
|
103
|
+
--_select-scheme-group-background-color: transparent;
|
|
104
|
+
--_select-scheme-group-background-image: radial-gradient(
|
|
105
|
+
circle,
|
|
106
|
+
rgb(66, 180, 58) 0%,
|
|
107
|
+
rgb(17, 199, 0) 27%,
|
|
108
|
+
rgb(8, 117, 3) 100%
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&:has(input[value="light"]:checked) {
|
|
113
|
+
--_select-scheme-group-background-color: transparent;
|
|
114
|
+
--_select-scheme-group-background-image: radial-gradient(
|
|
115
|
+
circle,
|
|
116
|
+
rgba(180, 58, 91, 1) 0%,
|
|
117
|
+
rgba(253, 29, 29, 1) 27%,
|
|
118
|
+
rgba(252, 176, 69, 1) 100%
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:has(input[value="dark"]:checked) {
|
|
123
|
+
--_select-scheme-group-background-color: transparent;
|
|
124
|
+
--_select-scheme-group-background-image: radial-gradient(
|
|
125
|
+
circle,
|
|
126
|
+
rgb(50, 20, 25) 0%,
|
|
127
|
+
rgb(0, 0, 0) 27%,
|
|
128
|
+
rgb(100, 100, 100) 100%
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.triple-toggle-switch-wrapper {
|
|
133
|
+
display: inline-grid;
|
|
134
|
+
grid-template-areas: "select-stack";
|
|
135
|
+
width: fit-content;
|
|
136
|
+
|
|
137
|
+
background-color: var(--theme-input-surface);
|
|
138
|
+
border: var(--form-element-border-width) solid var(--theme-input-border);
|
|
139
|
+
outline: var(--form-element-outline-width) solid var(--theme-input-outline);
|
|
140
|
+
border-radius: var(--_form-border-radius);
|
|
141
|
+
padding: var(--_form-padding);
|
|
142
|
+
|
|
143
|
+
transition: all var(--theme-form-transition-duration) ease-in-out;
|
|
144
|
+
|
|
145
|
+
&:has(input:focus-visible) {
|
|
146
|
+
outline: var(--form-element-outline-width) solid var(--theme-input-outline-hover);
|
|
147
|
+
outline-offset: 0.2rem;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.selected-option-marker-wrapper {
|
|
151
|
+
grid-area: select-stack;
|
|
152
|
+
z-index: 1;
|
|
153
|
+
display: flex;
|
|
154
|
+
align-items: center;
|
|
155
|
+
position: relative;
|
|
156
|
+
|
|
157
|
+
.selected-option-marker {
|
|
158
|
+
aspect-ratio: 1;
|
|
159
|
+
width: v-bind(iconWidth);
|
|
160
|
+
transition: all 400ms ease-in-out;
|
|
161
|
+
background-color: var(--_select-scheme-group-background-color);
|
|
162
|
+
background-image: var(--_select-scheme-group-background-image);
|
|
163
|
+
border: var(--form-element-border-width) solid light-dark(var(--gray-12), var(--gray-0));
|
|
164
|
+
|
|
165
|
+
border-radius: 50%;
|
|
166
|
+
|
|
167
|
+
position: absolute;
|
|
168
|
+
left: calc(
|
|
169
|
+
v-bind(selectedOptionIndex) * v-bind(iconWidth) + (var(--_form-items-gap) * v-bind(selectedOptionIndex))
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
opacity: 1;
|
|
173
|
+
|
|
174
|
+
&.show {
|
|
175
|
+
opacity: 1;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.option-group-wrapper {
|
|
181
|
+
display: grid;
|
|
182
|
+
grid-area: select-stack;
|
|
183
|
+
grid-template-columns: repeat(3, 1fr);
|
|
184
|
+
align-items: center;
|
|
185
|
+
width: fit-content;
|
|
186
|
+
z-index: 2;
|
|
187
|
+
gap: var(--_form-items-gap);
|
|
188
|
+
position: relative;
|
|
189
|
+
|
|
190
|
+
.option-group {
|
|
191
|
+
aspect-ratio: 1;
|
|
192
|
+
display: grid;
|
|
193
|
+
grid-template-areas: "icon-stack";
|
|
194
|
+
place-content: center;
|
|
195
|
+
background: transparent;
|
|
196
|
+
border: var(--form-element-border-width) solid #ffffff50;
|
|
197
|
+
outline: var(--form-element-outline-width) solid transparent;
|
|
198
|
+
border-radius: 50%;
|
|
199
|
+
padding: var(--_select-scheme-group-padding);
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
|
|
202
|
+
transition: all calc(var(--theme-form-transition-duration) / 3);
|
|
203
|
+
|
|
204
|
+
&:has(.option-icon:hover) {
|
|
205
|
+
outline: var(--form-element-outline-width) solid light-dark(var(--gray-12), var(--gray-0));
|
|
206
|
+
}
|
|
207
|
+
&:has(input:focus-visible) {
|
|
208
|
+
outline: var(--form-element-outline-width) solid var(--theme-input-outline-hover);
|
|
209
|
+
outline-offset: 0.2rem;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.option-icon {
|
|
213
|
+
grid-area: icon-stack;
|
|
214
|
+
display: block;
|
|
215
|
+
color: light-dark(var(--gray-12), var(--gray-0));
|
|
216
|
+
font-size: var(--_scheme-icon-font-size);
|
|
217
|
+
|
|
218
|
+
.icon {
|
|
219
|
+
background-color: transparent;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&:hover {
|
|
223
|
+
cursor: pointer;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.option-input {
|
|
228
|
+
grid-area: icon-stack;
|
|
229
|
+
opacity: 0;
|
|
230
|
+
aspect-ratio: 1;
|
|
231
|
+
width: var(--_scheme-icon-font-size);
|
|
232
|
+
&:hover {
|
|
233
|
+
cursor: pointer;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
&:has(input[value="auto"]:checked) {
|
|
238
|
+
--_scheme-icon-colour: white;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
&:has(input[value="light"]:checked) {
|
|
242
|
+
--_scheme-icon-colour: white;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&:has(input[value="dark"]:checked) {
|
|
246
|
+
--_scheme-icon-colour: white;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
</style>
|
|
@@ -54,10 +54,10 @@ defineProps({
|
|
|
54
54
|
|
|
55
55
|
const colourMode = ref<"light" | "dark" | "auto">("dark")
|
|
56
56
|
|
|
57
|
-
const { currentColourScheme, setColourScheme } = useSettingsStore()
|
|
57
|
+
// const { currentColourScheme, setColourScheme } = useSettingsStore()
|
|
58
58
|
|
|
59
59
|
watch(colourMode, (newVal) => {
|
|
60
|
-
console.log("Colour mode changed:", newVal)
|
|
61
|
-
setColourScheme(newVal)
|
|
60
|
+
// console.log("Colour mode changed:", newVal)
|
|
61
|
+
// setColourScheme(newVal)
|
|
62
62
|
})
|
|
63
63
|
</script>
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// const delay = (t: number) => new Promise((r) => setTimeout(r, t))
|
|
2
|
-
|
|
3
|
-
export const useSettingsStore = defineStore(
|
|
4
|
-
"settingsStore",
|
|
5
|
-
() => {
|
|
6
|
-
// State
|
|
7
|
-
const colourScheme = ref<"auto" | "dark" | "light" | null>(null)
|
|
8
|
-
|
|
9
|
-
// Getters
|
|
10
|
-
const currentColourScheme = computed(() => colourScheme.value)
|
|
11
|
-
|
|
12
|
-
// Actions
|
|
13
|
-
const setColourScheme = (state: "auto" | "dark" | "light" | null) => {
|
|
14
|
-
console.log("Setting colour scheme:", state)
|
|
15
|
-
colourScheme.value = state
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
currentColourScheme,
|
|
20
|
-
setColourScheme,
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
persist: {
|
|
25
|
-
storage: piniaPluginPersistedstate.cookies(),
|
|
26
|
-
},
|
|
27
|
-
}
|
|
28
|
-
)
|