Browse Source

update: setup page

- use radix select component to reduce boilerplate
pull/1397/head
tetuaoro 7 months ago
committed by Bernd Storath
parent
commit
2331677ecb
  1. 71
      src/app/components/ui/ChooseLang.vue
  2. 0
      src/app/components/ui/StepProgress.vue
  3. 39
      src/app/pages/setup.vue

71
src/app/components/ui/ChooseLang.vue

@ -0,0 +1,71 @@
<template>
<SelectRoot v-model="langProxy">
<SelectTrigger
class="inline-flex min-w-[160px] items-center justify-between rounded px-[15px] text-[13px] leading-none h-[35px] gap-[5px] bg-white text-grass11 shadow-[0_2px_10px] shadow-black/10 hover:bg-mauve3 focus:shadow-[0_0_0_2px] focus:shadow-black data-[placeholder]:text-green9 outline-none"
aria-label="Customise options"
>
<SelectValue placeholder="Select a fruit..." />
<Icon icon="radix-icons:chevron-down" class="h-3.5 w-3.5" />
</SelectTrigger>
<SelectPortal>
<SelectContent
class="min-w-[160px] bg-white rounded shadow-[0px_10px_38px_-10px_rgba(22,_23,_24,_0.35),_0px_10px_20px_-15px_rgba(22,_23,_24,_0.2)] will-change-[opacity,transform] data-[side=top]:animate-slideDownAndFade data-[side=right]:animate-slideLeftAndFade data-[side=bottom]:animate-slideUpAndFade data-[side=left]:animate-slideRightAndFade z-[100]"
:side-offset="5"
>
<SelectScrollUpButton
class="flex items-center justify-center h-[25px] bg-white text-violet11 cursor-default"
>
<Icon icon="radix-icons:chevron-up" />
</SelectScrollUpButton>
<SelectViewport class="p-[5px]">
<SelectItem
v-for="(option, index) in langs"
:key="index"
class="text-[13px] leading-none text-grass11 rounded-[3px] flex items-center h-[25px] pr-[35px] pl-[25px] relative select-none data-[disabled]:text-mauve8 data-[disabled]:pointer-events-none data-[highlighted]:outline-none data-[highlighted]:bg-green9 data-[highlighted]:text-green1"
:value="option.value"
>
<SelectItemText>
{{ option.name }}
</SelectItemText>
</SelectItem>
</SelectViewport>
<SelectScrollDownButton
class="flex items-center justify-center h-[25px] bg-white text-violet11 cursor-default"
>
<Icon icon="radix-icons:chevron-down" />
</SelectScrollDownButton>
</SelectContent>
</SelectPortal>
</SelectRoot>
</template>
<script setup lang="ts">
const { lang } = defineProps<{
lang: string;
}>();
const langProxy = ref(lang);
const updateLang = defineEmits(['update:lang']);
watch(langProxy, (newVal) => {
updateLang('update:lang', newVal);
});
const langs = [
{
value: 'de',
name: 'Deutsch',
},
{
value: 'en',
name: 'English',
},
{
value: 'fr',
name: 'Français',
},
];
</script>

0
src/app/components/step/Progress.vue → src/app/components/ui/StepProgress.vue

39
src/app/pages/setup.vue

@ -9,17 +9,9 @@
<div v-if="step === 1"> <div v-if="step === 1">
<p class="text-lg p-8">{{ $t('setup.msgStepOne') }}</p> <p class="text-lg p-8">{{ $t('setup.msgStepOne') }}</p>
<select id="lang" form="form-step-one" name="lang"> <div class="flex justify-center mb-8">
<option <UiChooseLang :lang="lang" @update:lang="updateLang" />
v-for="lang in langs" </div>
:key="lang.value"
:value="lang.value"
:selected="lang.value == 'en'"
>
{{ lang.name }}
</option>
</select>
<form id="form-step-one"></form>
</div> </div>
<div v-if="step === 2"> <div v-if="step === 2">
@ -86,7 +78,7 @@
]" ]"
@click="decreaseStep" @click="decreaseStep"
/> />
<StepProgress :step="step" /> <UiStepProgress :step="step" />
<IconsArrowRightCircle <IconsArrowRightCircle
:class="[ :class="[
'size-12', 'size-12',
@ -111,36 +103,23 @@
import { FetchError } from 'ofetch'; import { FetchError } from 'ofetch';
const { t } = useI18n(); const { t } = useI18n();
const authStore = useAuthStore();
type SetupError = { type SetupError = {
title: string; title: string;
message: string; message: string;
}; };
const lang = ref('');
const username = ref<null | string>(null); const username = ref<null | string>(null);
const password = ref<null | string>(null); const password = ref<null | string>(null);
const accept = ref<boolean>(true); const accept = ref<boolean>(true);
const authStore = useAuthStore();
const step = ref(1); const step = ref(1);
const stepInvalide = ref<number[]>([]); const stepInvalide = ref<number[]>([]);
const setupError = ref<null | SetupError>(null); const setupError = ref<null | SetupError>(null);
const langs = [
{
value: 'de',
name: 'Deutsch',
},
{
value: 'en',
name: 'English',
},
{
value: 'de',
name: 'Français',
},
];
// TODO: improve error handling // TODO: improve error handling
watch(setupError, (value) => { watch(setupError, (value) => {
if (value) { if (value) {
@ -150,6 +129,10 @@ watch(setupError, (value) => {
} }
}); });
function updateLang(value: string) {
lang.value = value;
}
async function increaseStep() { async function increaseStep() {
try { try {
if (step.value === 1) { if (step.value === 1) {

Loading…
Cancel
Save