srcdev-nuxt-forms 2.1.32 → 2.1.34

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.
Files changed (37) hide show
  1. package/assets/styles/forms/themes/_error.css +8 -6
  2. package/assets/styles/forms/themes/_ghost.css +8 -6
  3. package/assets/styles/forms/themes/_primary.css +8 -6
  4. package/assets/styles/forms/themes/_secondary.css +8 -6
  5. package/assets/styles/forms/themes/_success.css +8 -6
  6. package/assets/styles/forms/themes/_tertiary.css +8 -6
  7. package/assets/styles/forms/themes/_warning.css +8 -6
  8. package/assets/styles/forms/variables/_theme.css +43 -40
  9. package/assets/styles/utils/_margin-helpers.css +91 -91
  10. package/assets/styles/utils/_padding-helpers.css +91 -91
  11. package/assets/styles/utils/_page.css +11 -4
  12. package/components/forms/form-errors/InputError.vue +7 -7
  13. package/components/forms/input-button/InputButtonCore.vue +5 -4
  14. package/components/forms/input-checkbox/MultipleCheckboxes.vue +5 -5
  15. package/components/forms/input-checkbox/SingleCheckbox.vue +5 -5
  16. package/components/forms/input-checkbox-radio/InputCheckboxRadioButton.vue +32 -32
  17. package/components/forms/input-checkbox-radio/InputCheckboxRadioCore.vue +9 -9
  18. package/components/forms/input-checkbox-radio/InputCheckboxRadioWithLabel.vue +2 -2
  19. package/components/forms/input-number/InputNumberCore.vue +3 -3
  20. package/components/forms/input-number/variants/InputNumberDefault.vue +4 -4
  21. package/components/forms/input-radio/MultipleRadiobuttons.vue +5 -5
  22. package/components/forms/input-range/InputRangeCore.vue +9 -9
  23. package/components/forms/input-range/variants/InputRangeDefault.vue +3 -3
  24. package/components/forms/input-range-fancy/InputRangeFancyCore.vue +23 -23
  25. package/components/forms/input-range-fancy/InputRangeFancyWithLabel.vue +3 -3
  26. package/components/forms/input-text/InputTextCore.vue +5 -5
  27. package/components/forms/input-text/variants/InputTextWithLabel.vue +1 -1
  28. package/components/forms/input-textarea/InputTextareaCore.vue +3 -3
  29. package/components/forms/input-textarea/variants/InputTextareaWithLabel.vue +1 -1
  30. package/components/forms/toggle-switch/ToggleSwitchCore.vue +14 -18
  31. package/components/forms/toggle-switch/variants/ToggleSwitchWithLabel.vue +2 -1
  32. package/components/forms/ui/FormField.vue +4 -4
  33. package/components/forms/ui/FormWrapper.vue +2 -2
  34. package/components/utils/dark-mode-switcher/DarkModeSwitcher.vue +23 -0
  35. package/composables/useColourScheme.ts +41 -0
  36. package/nuxt.config.ts +10 -0
  37. package/package.json +1 -1
@@ -113,8 +113,8 @@ const isChecked = computed(() => {
113
113
  <style lang="css">
114
114
  .input-checkbox-radio-wrapper {
115
115
  --_checkbox-size: initial;
116
- --_outline-width: 1px;
117
- --_border-width: 1px;
116
+ --_outline-width: 0.1rem;
117
+ --_border-width: 0.1rem;
118
118
  --_border-radius: 50%;
119
119
  --_background-color: var(--theme-form-checkbox-bg);
120
120
  --_box-shadow: none;
@@ -125,7 +125,7 @@ const isChecked = computed(() => {
125
125
  &.checkbox {
126
126
  --_background-color: var(--theme-form-checkbox-bg);
127
127
  --_border-color: var(--theme-form-checkbox-border);
128
- --_border-radius: 4px;
128
+ --_border-radius: 0.4rem;
129
129
  --_outline-color: var(--theme-form-checkbox-outline);
130
130
  }
131
131
 
@@ -144,7 +144,7 @@ const isChecked = computed(() => {
144
144
  background-color: var(--_background-color);
145
145
  border: var(--_border-width) solid var(--_border-color);
146
146
  border-radius: var(--_border-radius);
147
- outline: 1px solid var(--_outline-color);
147
+ outline: 0.1rem solid var(--_outline-color);
148
148
  box-shadow: var(--_box-shadow);
149
149
 
150
150
  height: var(--_checkbox-size);
@@ -158,19 +158,19 @@ const isChecked = computed(() => {
158
158
 
159
159
  /* Sizes */
160
160
  &.x-small {
161
- --_checkbox-size: 20px;
161
+ --_checkbox-size: 2rem;
162
162
  }
163
163
  &.small {
164
- --_checkbox-size: 24px;
164
+ --_checkbox-size: 2.4rem;
165
165
  }
166
166
  &.normal {
167
- --_checkbox-size: 34px;
167
+ --_checkbox-size: 3.4rem;
168
168
  }
169
169
  &.medium {
170
- --_checkbox-size: 40px;
170
+ --_checkbox-size: 4rem;
171
171
  }
172
172
  &.large {
173
- --_checkbox-size: 44px;
173
+ --_checkbox-size: 4.4rem;
174
174
  }
175
175
 
176
176
  .input-checked-icon {
@@ -102,8 +102,8 @@ const modelValue = defineModel();
102
102
  width: 100%;
103
103
  height: 100%;
104
104
  align-items: center;
105
- margin-block: 8px;
106
- padding-inline: 8px;
105
+ margin-block: 0.8rem;
106
+ padding-inline: 0.8rem;
107
107
  white-space: var(--_white-space);
108
108
 
109
109
  &:hover {
@@ -109,7 +109,7 @@ onMounted(() => {
109
109
 
110
110
  <style lang="css">
111
111
  .input-number-wrapper {
112
- --_gutter: 12px;
112
+ --_gutter: 1.2rem;
113
113
  --_border-width: var(--input-border-width-default);
114
114
  --_min-width: v-bind(minLength);
115
115
 
@@ -120,7 +120,7 @@ onMounted(() => {
120
120
 
121
121
  .slot {
122
122
  display: inline-block;
123
- padding-inline: 8px;
123
+ padding-inline: 0.8rem;
124
124
 
125
125
  .icon {
126
126
  font-weight: 900;
@@ -156,7 +156,7 @@ onMounted(() => {
156
156
  font-family: var(--font-family);
157
157
  font-size: var(--theme-form-button-font-size-normal);
158
158
  line-height: var(--line-height);
159
- padding: 4px 16px;
159
+ padding: 0.4rem 1.6rem;
160
160
  text-align: center;
161
161
  min-width: var(--_min-width);
162
162
 
@@ -135,11 +135,11 @@ const updateValue = (step: number, withinRangeLimit: boolean) => {
135
135
  .input-number-with-label {
136
136
  --_border-width: var(--input-border-width-default);
137
137
  --_outline-width: var(--input-outline-width-thin);
138
- --_label-padding-inline: 10px;
138
+ --_label-padding-inline: 1rem;
139
139
 
140
140
  .input-number-label {
141
141
  display: block;
142
- margin-block: 8px;
142
+ margin-block: 0.8rem;
143
143
 
144
144
  &:hover {
145
145
  cursor: pointer;
@@ -148,8 +148,8 @@ const updateValue = (step: number, withinRangeLimit: boolean) => {
148
148
 
149
149
  .label-description {
150
150
  font-family: var(--font-family);
151
- font-size: 16px;
152
- margin-top: 12px;
151
+ font-size: 1.6rem;
152
+ margin-top: 1.2rem;
153
153
  }
154
154
  }
155
155
  </style>
@@ -167,7 +167,7 @@ const fieldData = defineModel('fieldData') as Ref<IFormMultipleOptions>;
167
167
 
168
168
  legend {
169
169
  font-family: var(--font-family);
170
- font-size: 16px;
170
+ font-size: 1.6rem;
171
171
  font-weight: 500;
172
172
 
173
173
  &.has-description {
@@ -177,15 +177,15 @@ const fieldData = defineModel('fieldData') as Ref<IFormMultipleOptions>;
177
177
 
178
178
  .label-description {
179
179
  font-family: var(--font-family);
180
- font-size: 16px;
181
- margin-top: 12px;
180
+ font-size: 1.6rem;
181
+ margin-top: 1.2rem;
182
182
  }
183
183
  }
184
184
 
185
185
  .multiple-radiobuttons-items {
186
186
  display: flex;
187
- gap: 12px;
188
- margin-top: 12px;
187
+ gap: 1.2rem;
188
+ margin-top: 1.2rem;
189
189
 
190
190
  &.inline {
191
191
  flex-direction: row;
@@ -115,17 +115,17 @@ const changeBackgroundColor = () => {
115
115
 
116
116
  <style lang="css">
117
117
  .input-range-wrapper {
118
- --_gutter: 12px;
118
+ --_gutter: 1.2rem;
119
119
  --_border-width: var(--input-border-width-default);
120
120
  --_outline-width: var(--input-outline-width-thin);
121
121
 
122
- --_input-range-height: 24px;
122
+ --_input-range-height: 2.4rem;
123
123
  --_slot-translate-y: calc(var(--_input-range-height) / 4);
124
124
 
125
125
  display: flex;
126
126
  align-items: center;
127
127
  justify-content: space-between;
128
- gap: 10px;
128
+ gap: 1rem;
129
129
 
130
130
  .slot {
131
131
  align-self: flex-start;
@@ -160,8 +160,8 @@ const changeBackgroundColor = () => {
160
160
  /* -webkit-appearance: none; */
161
161
  accent-color: blue;
162
162
  color: blue;
163
- background-color: 1px solid green;
164
- outline: 1px solid blue;
163
+ background-color: 0.1rem solid green;
164
+ outline: 0.1rem solid blue;
165
165
  border-radius: 50%;
166
166
  }
167
167
 
@@ -169,7 +169,7 @@ const changeBackgroundColor = () => {
169
169
  appearance: none;
170
170
  -webkit-appearance: none;
171
171
  /* background: hsl(10 80% 50% / 0.5); */
172
- /* box-shadow: 1px 1px 1px #fff, 0px 0px 1px #fff; */
172
+ /* box-shadow: 0.1rem 0.1rem 0.1rem #fff, 0rem 0rem 0.1rem #fff; */
173
173
  }
174
174
 
175
175
  /* For Chrome, Safari, Opera, and Edge */
@@ -190,7 +190,7 @@ const changeBackgroundColor = () => {
190
190
  background: #5cd5eb;
191
191
  height: 2rem;
192
192
  width: 1rem;
193
- border-radius: 10px;
193
+ border-radius: 1rem;
194
194
  } */
195
195
 
196
196
  /* For Firefox */
@@ -198,7 +198,7 @@ const changeBackgroundColor = () => {
198
198
  background: #5cd5eb;
199
199
  height: 2rem;
200
200
  width: 1rem;
201
- border-radius: 10px;
201
+ border-radius: 1rem;
202
202
  border: none;
203
203
  } */
204
204
 
@@ -211,7 +211,7 @@ const changeBackgroundColor = () => {
211
211
  display: flex;
212
212
  flex-direction: column;
213
213
  font-family: var(--font-family);
214
- font-size: 14px;
214
+ font-size: 1.4rem;
215
215
  font-weight: 500;
216
216
  justify-content: space-between;
217
217
  writing-mode: vertical-lr;
@@ -143,7 +143,7 @@ const updateRange = (step: number, withinRangeLimit: boolean) => {
143
143
  .input-range-with-label {
144
144
  .input-range-label {
145
145
  display: block;
146
- margin-block: 8px;
146
+ margin-block: 0.8rem;
147
147
 
148
148
  &:hover {
149
149
  cursor: pointer;
@@ -152,8 +152,8 @@ const updateRange = (step: number, withinRangeLimit: boolean) => {
152
152
 
153
153
  .label-description {
154
154
  font-family: var(--font-family);
155
- font-size: 16px;
156
- margin-top: 12px;
155
+ font-size: 1.6rem;
156
+ margin-top: 1.2rem;
157
157
  }
158
158
  }
159
159
  </style>
@@ -156,10 +156,10 @@ onMounted(() => {
156
156
 
157
157
  .sr-only {
158
158
  position: absolute;
159
- width: 1px;
160
- height: 1px;
159
+ width: 0.1rem;
160
+ height: 0.1rem;
161
161
  padding: 0;
162
- margin: -1px;
162
+ margin: -0.1rem;
163
163
  overflow: hidden;
164
164
  clip: rect(0, 0, 0, 0);
165
165
  white-space: nowrap;
@@ -174,7 +174,7 @@ onMounted(() => {
174
174
  [type='range'] {
175
175
  width: 100%;
176
176
  opacity: 0;
177
- height: 60px;
177
+ height: 6rem;
178
178
  }
179
179
 
180
180
  [type='range']:hover {
@@ -237,23 +237,23 @@ onMounted(() => {
237
237
  [type='range']::-webkit-slider-thumb {
238
238
  appearance: none;
239
239
  -webkit-appearance: none;
240
- height: 60px;
241
- width: 40px;
242
- margin-top: 0px;
240
+ height: 6rem;
241
+ width: 4rem;
242
+ margin-top: 0rem;
243
243
  opacity: 1;
244
244
  }
245
245
  [type='range']::-webkit-slider-runnable-track {
246
246
  -webkit-appearance: none;
247
- height: 60px;
247
+ height: 6rem;
248
248
  /* background: hsl(10 80% 50% / 0.5); */
249
- margin-top: 0px; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
250
- box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
249
+ margin-top: 0rem; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
250
+ box-shadow: 0.1rem 0.1rem 0.1rem #000000, 0rem 0rem 0.1rem #0d0d0d;
251
251
  }
252
252
  [type='range']::-moz-range-track {
253
- height: 60px;
253
+ height: 6rem;
254
254
  /* background: hsl(10 80% 50% / 0.5); */
255
- margin-top: 0px; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
256
- box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
255
+ margin-top: 0rem; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
256
+ box-shadow: 0.1rem 0.1rem 0.1rem #000000, 0rem 0rem 0.1rem #0d0d0d;
257
257
  }
258
258
  }
259
259
 
@@ -276,7 +276,7 @@ onMounted(() => {
276
276
  touch-action: none;
277
277
  /* extras */
278
278
  accent-color: hsl(24 74% calc(24% + (30% * ((100 - var(--value, 0)) / 100)) / 1) / 0.4);
279
- outline: 2px dashed #0000;
279
+ outline: 0.2rem dashed #0000;
280
280
  transition-property: outline-color, opacity, translate;
281
281
  transition-duration: 0.25s;
282
282
  }
@@ -305,12 +305,12 @@ onMounted(() => {
305
305
  pointer-events: none;
306
306
  transition: height var(--speed) var(--timing);
307
307
  z-index: 5;
308
- clip-path: inset(0 -0.25rem 0 -0.25rem round 6px);
308
+ clip-path: inset(0 -0.25rem 0 -0.25rem round 0.6rem);
309
309
  }
310
310
 
311
311
  [data-reveal='true'] .control__track {
312
312
  clip-path: unset;
313
- outline: 2px dashed white;
313
+ outline: 0.2rem dashed white;
314
314
  }
315
315
 
316
316
  .control__track-slide {
@@ -324,7 +324,7 @@ onMounted(() => {
324
324
  width: 100%;
325
325
  height: 100%;
326
326
  position: absolute;
327
- border-radius: 6px;
327
+ border-radius: 0.6rem;
328
328
 
329
329
  &:nth-of-type(1) {
330
330
  background: var(--coffee);
@@ -338,8 +338,8 @@ onMounted(() => {
338
338
 
339
339
  .control__indicator {
340
340
  height: 75%;
341
- border-radius: 4px;
342
- width: 4px;
341
+ border-radius: 0.4rem;
342
+ width: 0.4rem;
343
343
  position: absolute;
344
344
  top: 50%;
345
345
  left: 50%;
@@ -431,13 +431,13 @@ onMounted(() => {
431
431
  --range: calc((70 - (var(--value) / 100 * 10)) * 1%);
432
432
 
433
433
  display: flex;
434
- gap: 12px;
434
+ gap: 1.2rem;
435
435
  color: hsl(24 74% 54%);
436
436
  mask: linear-gradient(90deg, hsl(0 0% 100% / 0.6) var(--range), hsl(0 0% 100% / 1) var(--range));
437
437
  left: 0.5rem;
438
438
  .low-value {
439
439
  display: inline-block;
440
- border: 1px solid white;
440
+ border: 0.1rem solid white;
441
441
  height: 2rem;
442
442
  width: 5rem;
443
443
  }
@@ -447,12 +447,12 @@ onMounted(() => {
447
447
  --range: calc((50 - (var(--value) / 100 * 10)) * 1%);
448
448
 
449
449
  display: flex;
450
- gap: 12px;
450
+ gap: 1.2rem;
451
451
  mask: linear-gradient(90deg, hsl(0 0% 100% / 1) var(--range), hsl(0 0% 100% / 0.5) var(--range));
452
452
  right: 0.5rem;
453
453
  .high-value {
454
454
  display: inline-block;
455
- border: 1px solid white;
455
+ border: 0.1rem solid white;
456
456
  height: 2rem;
457
457
  width: 5rem;
458
458
  }
@@ -108,7 +108,7 @@ const modelValue = defineModel<number | readonly number[]>();
108
108
  .input-range-fancy-with-label {
109
109
  .input-range-fancy-label {
110
110
  display: block;
111
- margin-block: 8px;
111
+ margin-block: 0.8rem;
112
112
 
113
113
  &:hover {
114
114
  cursor: pointer;
@@ -117,8 +117,8 @@ const modelValue = defineModel<number | readonly number[]>();
117
117
 
118
118
  .label-description {
119
119
  font-family: var(--font-family);
120
- font-size: 16px;
121
- margin-top: 12px;
120
+ font-size: 1.6rem;
121
+ margin-top: 1.2rem;
122
122
  }
123
123
  }
124
124
  </style>
@@ -144,7 +144,7 @@ onMounted(() => {
144
144
 
145
145
  <style lang="css">
146
146
  .input-text-wrapper {
147
- --_gutter: 12px;
147
+ --_gutter: 1.2rem;
148
148
  --_border-width: var(--input-border-width-default);
149
149
  --_outline-width: var(--input-border-width-default);
150
150
 
@@ -164,7 +164,7 @@ onMounted(() => {
164
164
  &:not(:has(.btn)) {
165
165
  .slot {
166
166
  display: inline-block;
167
- padding-inline: 8px;
167
+ padding-inline: 0.8rem;
168
168
 
169
169
  .icon {
170
170
  color: var(--theme-form-input-text);
@@ -174,7 +174,7 @@ onMounted(() => {
174
174
 
175
175
  &:has(.btn) {
176
176
  .btn {
177
- margin-inline: 6px;
177
+ margin-inline: 0.6rem;
178
178
  }
179
179
  }
180
180
 
@@ -203,7 +203,7 @@ onMounted(() => {
203
203
  font-family: var(--font-family);
204
204
  font-size: var(--theme-form-button-font-size-normal);
205
205
  line-height: var(--line-height);
206
- padding: 8px 12px;
206
+ padding: 0.8rem 1.2rem;
207
207
 
208
208
  &::placeholder,
209
209
  &::-webkit-input-placeholder {
@@ -223,7 +223,7 @@ input:-webkit-autofill-and-obscured {
223
223
  background-color: var(--theme-form-input-bg) !important;
224
224
  background-image: none !important;
225
225
  color: var(--theme-form-input-text) !important;
226
- -webkit-box-shadow: 0 0 0px 1000px var(--theme-form-input-bg) inset;
226
+ -webkit-box-shadow: 0 0 0rem 1000px var(--theme-form-input-bg) inset;
227
227
  -webkit-text-fill-color: var(--theme-form-input-text);
228
228
  transition: background-color 5000s ease-in-out 0s;
229
229
  }
@@ -139,7 +139,7 @@ watch(
139
139
  .input-text-with-label {
140
140
  .input-text-label {
141
141
  display: block;
142
- margin-block: 8px;
142
+ margin-block: 0.8rem;
143
143
  }
144
144
  }
145
145
  </style>
@@ -96,7 +96,7 @@ onMounted(() => {
96
96
 
97
97
  <style lang="css">
98
98
  .input-textarea-wrapper {
99
- --_gutter: 12px;
99
+ --_gutter: 1.2rem;
100
100
  --_border-width: var(--input-border-width-default);
101
101
  --_outline-width: var(--input-border-width-default);
102
102
 
@@ -115,7 +115,7 @@ onMounted(() => {
115
115
 
116
116
  .slot {
117
117
  display: inline-block;
118
- padding-inline: 8px;
118
+ padding-inline: 0.8rem;
119
119
 
120
120
  .icon {
121
121
  color: var(--theme-form-input-text);
@@ -147,7 +147,7 @@ onMounted(() => {
147
147
  font-family: var(--font-family);
148
148
  font-size: var(--theme-form-button-font-size-normal);
149
149
  line-height: var(--line-height);
150
- padding: 8px 12px;
150
+ padding: 0.8rem 1.2rem;
151
151
 
152
152
  &::placeholder,
153
153
  &::-webkit-input-placeholder {
@@ -100,7 +100,7 @@ watch(
100
100
  .input-textarea-with-label {
101
101
  .input-textarea-label {
102
102
  display: block;
103
- margin-block: 8px;
103
+ margin-block: 0.8rem;
104
104
  }
105
105
  }
106
106
  </style>
@@ -109,7 +109,6 @@ const inputId = computed(() => `toggle-sitch-${id}`);
109
109
  --_icon-off-opacity: 0;
110
110
  }
111
111
 
112
- /* The symbol */
113
112
  .symbol-wrapper {
114
113
  position: absolute;
115
114
  cursor: pointer;
@@ -137,37 +136,34 @@ const inputId = computed(() => `toggle-sitch-${id}`);
137
136
  }
138
137
 
139
138
  /*
140
- * ToggleSwitch configurable
141
- **/
139
+ * ToggleSwitch configurable
140
+ **/
142
141
  .toggle-switch-core {
143
142
  /* Sizes */
144
143
  &.x-small {
145
- --_symbol-size: 20px;
144
+ --_symbol-size: 2rem;
146
145
  }
147
146
  &.small {
148
- --_symbol-size: 24px;
147
+ --_symbol-size: 2.4rem;
149
148
  }
150
149
  &.normal {
151
- --_symbol-size: 34px;
150
+ --_symbol-size: 3.4rem;
152
151
  }
153
152
  &.medium {
154
- --_symbol-size: 40px;
153
+ --_symbol-size: 4rem;
155
154
  }
156
155
  &.large {
157
- --_symbol-size: 44px;
156
+ --_symbol-size: 4.4rem;
158
157
  }
159
158
 
160
- /* .toggle-switch-label {
161
- } */
162
-
163
159
  .toggle-switch-input {
164
160
  border: var(--theme-form-toggle-border);
165
161
  outline: var(--theme-form-toggle-outline);
166
- width: calc(var(--_symbol-size) * 2 - 4px);
167
- height: calc(var(--_symbol-size) + 4px);
162
+ width: calc(var(--_symbol-size) * 2 - calc(var(--theme-form-toggle-border-width) * 4));
163
+ height: calc(var(--_symbol-size) + calc(var(--theme-form-toggle-border-width) * 4));
168
164
 
169
165
  &.round {
170
- border-radius: calc(var(--_symbol-size) + 2px);
166
+ border-radius: calc(var(--_symbol-size) + calc(var(--theme-form-toggle-border-width) * 2));
171
167
  }
172
168
 
173
169
  .symbol-wrapper {
@@ -178,10 +174,10 @@ const inputId = computed(() => `toggle-sitch-${id}`);
178
174
  border-radius: var(--_symbol-size);
179
175
  }
180
176
  .symbol {
181
- height: calc(var(--_symbol-size) - 6px);
182
- width: calc(var(--_symbol-size) - 6px);
183
- left: 4px;
184
- bottom: 4px;
177
+ height: calc(var(--_symbol-size) - 0.6rem);
178
+ width: calc(var(--_symbol-size) - 0.6rem);
179
+ left: 0.4rem;
180
+ bottom: 0.4rem;
185
181
  background-color: var(--theme-form-toggle-symbol-off);
186
182
  transition: var(--_transition-duration);
187
183
 
@@ -39,7 +39,8 @@ const { id, name, label, required, errorMessage, fieldHasError, trueValue, false
39
39
  },
40
40
  errorMessage: {
41
41
  type: [Object, String],
42
- required: true,
42
+ default: '',
43
+ required: false,
43
44
  },
44
45
  fieldHasError: {
45
46
  type: Boolean,
@@ -24,17 +24,17 @@ defineProps({
24
24
 
25
25
  <style lang="css">
26
26
  .form-field {
27
- --_gutter-width: 0px;
27
+ --_gutter-width: 0rem;
28
28
  --_max-width: 400px;
29
29
 
30
30
  margin-inline: auto;
31
- margin-bottom: 16px;
31
+ margin-bottom: 1.6rem;
32
32
 
33
33
  width: min(100% - calc(2 * var(--_gutter-width)), var(--_max-width));
34
- outline: 0px solid var(--gray-5);
34
+ outline: 0rem solid var(--gray-5);
35
35
 
36
36
  &.has-gutter {
37
- --_gutter-width: 16px;
37
+ --_gutter-width: 1.6rem;
38
38
  }
39
39
 
40
40
  &.narrow {
@@ -16,8 +16,8 @@ defineProps({
16
16
 
17
17
  <style lang="css">
18
18
  .form-wrapper {
19
- outline: 0px solid var(--gray-12);
20
- padding-bottom: 20px;
19
+ outline: 0rem solid var(--gray-12);
20
+ padding-bottom: 2rem;
21
21
 
22
22
  &.narrow {
23
23
  max-width: 400px;
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <ToggleSwitchCore v-model="displayMode" class="dark-mode-switcher" :class="elementClasses" true-value="dark" false-value="light" name="header-dark-mode-switcher" id="header-dark-mode-switcher">
3
+ <template #iconOn>
4
+ <Icon name="radix-icons:moon" class="icon" />
5
+ </template>
6
+ <template #iconOff>
7
+ <Icon name="radix-icons:sun" class="icon" />
8
+ </template>
9
+ </ToggleSwitchCore>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ const { styleClassPassthrough } = defineProps({
14
+ styleClassPassthrough: {
15
+ type: Array as PropType<string[]>,
16
+ default: () => [],
17
+ },
18
+ });
19
+
20
+ const displayMode = ref<'auto' | 'dark' | 'light'>('auto');
21
+ const { elementClasses } = useStyleClassPassthrough(styleClassPassthrough);
22
+ useColourScheme(displayMode);
23
+ </script>
@@ -0,0 +1,41 @@
1
+ export const useColourScheme = (colourScheme: Ref<'auto' | 'dark' | 'light'> = ref('light')) => {
2
+ const updateColourScheme = (newColourScheme: 'auto' | 'dark' | 'light') => {
3
+ colourScheme.value = newColourScheme;
4
+ };
5
+
6
+ const getSetPrefereredColourScheme = () => {
7
+ if (import.meta.client) {
8
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
9
+ colourScheme.value = 'dark';
10
+ } else {
11
+ colourScheme.value = 'light';
12
+ }
13
+ }
14
+ };
15
+
16
+ onMounted(() => {
17
+ if (import.meta.client) {
18
+ const storedMode = localStorage.getItem('colourScheme');
19
+ if (storedMode) {
20
+ colourScheme.value = storedMode as 'dark' | 'light';
21
+ } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
22
+ colourScheme.value = 'dark';
23
+ } else {
24
+ colourScheme.value = 'light';
25
+ }
26
+ }
27
+ });
28
+
29
+ watch(colourScheme, (newVal) => {
30
+ if (import.meta.client) {
31
+ localStorage.setItem('colourScheme', newVal);
32
+ document.documentElement.dataset.colorScheme = newVal;
33
+ }
34
+ });
35
+
36
+ return {
37
+ colourScheme,
38
+ updateColourScheme,
39
+ getSetPrefereredColourScheme,
40
+ };
41
+ };
package/nuxt.config.ts CHANGED
@@ -11,6 +11,16 @@ export default defineNuxtConfig({
11
11
  },
12
12
  },
13
13
  },
14
+ app: {
15
+ head: {
16
+ htmlAttrs: {
17
+ lang: 'en',
18
+ 'data-color-scheme': 'auto',
19
+ },
20
+ titleTemplate: '%s - Website name',
21
+ meta: [{ charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }],
22
+ },
23
+ },
14
24
  components: [
15
25
  {
16
26
  path: './components',