Skip to content

Commit 3233e09

Browse files
committed
feat: refactor FieldSwitch and Advanced components to use FieldDescription for better semantics, and update ImageUploader to utilize AspectRatio for improved layout
1 parent fa292f2 commit 3233e09

3 files changed

Lines changed: 26 additions & 27 deletions

File tree

layers/dashboard/app/components/dashboard/links/editor/Advanced.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ async function aiOg() {
138138
<FieldLabel :for="field.name">
139139
{{ $t('links.form.expiration') }}
140140
</FieldLabel>
141-
<p class="text-xs text-muted-foreground">
141+
<FieldDescription class="text-xs">
142142
{{ $t('links.form.expiration_description') }}
143-
</p>
143+
</FieldDescription>
144144
<Popover v-model:open="datePickerOpen">
145145
<PopoverTrigger as-child>
146146
<Button
@@ -184,9 +184,9 @@ async function aiOg() {
184184
<FieldLabel :for="field.name">
185185
{{ $t('links.form.password_label') }}
186186
</FieldLabel>
187-
<p class="text-xs text-muted-foreground">
187+
<FieldDescription class="text-xs">
188188
{{ $t('links.form.password_description') }}
189-
</p>
189+
</FieldDescription>
190190
<Input
191191
:id="field.name"
192192
:name="field.name"

layers/dashboard/app/components/dashboard/links/editor/FieldSwitch.vue

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@ const emit = defineEmits<{
1212
</script>
1313

1414
<template>
15-
<Field>
16-
<div class="flex items-center justify-between">
17-
<div class="space-y-0.5">
18-
<FieldLabel :for="id">
19-
{{ label }}
20-
</FieldLabel>
21-
<p v-if="description" class="text-xs text-muted-foreground">
22-
{{ description }}
23-
</p>
24-
</div>
25-
<Switch
26-
:id="id"
27-
:model-value="modelValue"
28-
@update:model-value="emit('update:modelValue', $event)"
29-
/>
30-
</div>
15+
<Field orientation="horizontal">
16+
<FieldContent>
17+
<FieldLabel :for="id">
18+
{{ label }}
19+
</FieldLabel>
20+
<FieldDescription v-if="description" class="text-xs">
21+
{{ description }}
22+
</FieldDescription>
23+
</FieldContent>
24+
<Switch
25+
:id="id"
26+
:model-value="modelValue"
27+
@update:model-value="emit('update:modelValue', $event)"
28+
/>
3129
</Field>
3230
</template>

layers/dashboard/app/components/dashboard/links/editor/ImageUploader.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ function openFilePicker() {
9090

9191
<template>
9292
<div class="space-y-2">
93-
<div
93+
<AspectRatio
9494
v-if="!imageUrl"
95+
:ratio="1200 / 630"
9596
class="
96-
relative flex aspect-[1200/630] cursor-pointer items-center
97-
justify-center rounded-md border-2 border-dashed transition-colors
97+
relative flex cursor-pointer items-center justify-center rounded-md
98+
border-2 border-dashed transition-colors
9899
"
99100
:class="[
100101
!canUpload ? 'cursor-not-allowed opacity-50' : 'cursor-pointer',
@@ -121,13 +122,13 @@ function openFilePicker() {
121122
class="hidden"
122123
@change="onFileChange"
123124
>
124-
</div>
125+
</AspectRatio>
125126

126-
<div v-else class="relative aspect-[1200/630]">
127+
<AspectRatio v-else :ratio="1200 / 630" class="relative">
127128
<img
128129
:src="imageUrl"
129130
:alt="$t('links.form.image_preview')"
130-
class="aspect-[1200/630] w-full rounded-md object-cover"
131+
class="h-full w-full rounded-md object-cover"
131132
>
132133
<Button
133134
type="button"
@@ -138,6 +139,6 @@ function openFilePicker() {
138139
>
139140
<X class="h-4 w-4" />
140141
</Button>
141-
</div>
142+
</AspectRatio>
142143
</div>
143144
</template>

0 commit comments

Comments
 (0)