Skip to content

Commit f976cc2

Browse files
committed
improve locale error
1 parent 40ec846 commit f976cc2

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

resources/js/components/LocaleSelectTrigger.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
import { Languages } from "lucide-vue-next";
33
import { SelectTrigger, SelectValue } from "@/components/ui/select/index.js";
44
import { __ } from "@/utils/i18n";
5+
6+
defineProps<{
7+
errorCount?: number,
8+
}>();
59
</script>
610

711
<template>
8-
<SelectTrigger class="w-auto h-8" :aria-label="$attrs['aria-label'] ?? __('sharp::action_bar.locale_selector.label')">
12+
<SelectTrigger class="w-auto gap-0 h-8" :aria-label="$attrs['aria-label'] ?? __('sharp::action_bar.locale_selector.label')">
913
<Languages class="size-3 mr-2.5 opacity-50" />
1014
<SelectValue class="uppercase text-xs" placeholder="-" />
15+
<template v-if="errorCount">
16+
<div class="ml-1.5 -mr-0.5 grid place-content-center text-[.625rem]/2.5 px-1 h-3.5 min-w-3.5 bg-destructive rounded-full text-destructive-foreground font-semibold">
17+
{{ errorCount }}
18+
</div>
19+
</template>
1120
</SelectTrigger>
1221
</template>

resources/js/form/components/FormFieldLocaleSelect.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ const form = useParentForm();
1818
class="ml-auto w-auto border-transparent hover:border-input aria-expanded:border-input"
1919
:class="{ '-my-2': isFieldLayout }"
2020
:aria-label="__('sharp::form.field_locale_selector.aria_label', { field_label:field.label })"
21+
:error-count="form.fieldLocalesContainingError(fieldErrorKey).length"
2122
/>
2223
<SelectContent @close-auto-focus="emit('close-auto-focus', $event)">
2324
<template v-for="formLocale in form.locales" :key="formLocale">
2425
<SelectItem :value="formLocale">
2526
<div class="flex items-center">
26-
<span class="uppercase text-xs">{{ formLocale }}</span>
27-
<template v-if="form.fieldLocalesContainingError(fieldErrorKey).includes(formLocale)">
28-
<svg class="ml-1 size-2 fill-destructive" viewBox="0 0 8 8" aria-hidden="true">
27+
<span class="uppercase text-xs">
28+
{{ formLocale }}
29+
</span>
30+
<template v-if="form.fieldHasError(field, fieldErrorKey, formLocale)">
31+
<svg class="ml-1 size-1.5 fill-destructive" viewBox="0 0 8 8" aria-hidden="true">
2932
<circle cx="4" cy="4" r="3" />
3033
</svg>
3134
</template>

resources/js/form/components/fields/editor/Editor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@
412412
{{ formLocale }}
413413
</div>
414414
<template v-if="form.fieldHasError(field, fieldErrorKey, formLocale)">
415-
<svg class="absolute top-1/2 right-2.5 -translate-y-1/2 translate-x-1/2 size-1.5 fill-destructive opacity-75 group-data-[state=active]/tab:opacity-100" viewBox="0 0 8 8" aria-hidden="true">
415+
<svg class="absolute top-1/2 right-2.5 -translate-y-1/2 translate-x-1/2 size-2 fill-destructive" viewBox="0 0 8 8" aria-hidden="true">
416416
<circle cx="4" cy="4" r="3" />
417417
</svg>
418418
</template>

0 commit comments

Comments
 (0)