Files
api/web/components/WelcomeModal.ce.vue
Zack Spear d8a5b1711a feat(web): activation modal steps, updated copy (#1079)
* feat(stepper): add shadcn stepper components

* chore(serverState): remove partnerLogo property from server state configuration

* refactor(web): modal add subfooter slot

- adds ability to display content below the modal's content box

* feat(modal): add ActivationSteps component to subFooter slot in WelcomeModal and ActivationModal

* refactor: improve activation modal buttons responsiveness

* refactor: update activation flow messaging and UI

* feat: web/deploy-dev.sh add dynamic web component JS file whitelisting in auth-request.php

* fix: remove test UTM parameters from Unraid docs links in activation modal

* refactor: improve konami code handling and add type safety to activation steps

* chore: remove extra semicolon in serverState.ts

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-01-29 11:08:23 -08:00

164 lines
4.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import 'tailwindcss/tailwind.css';
import '~/assets/main.css';
import ActivationSteps from '~/components/Activation/Steps.vue';
import { useActivationCodeStore } from '~/store/activationCode';
import { useServerStore } from '~/store/server';
import type { Server } from '~/types/server';
const { t } = useI18n();
export interface Props {
server?: Server | string;
}
const props = defineProps<Props>();
const activationCodeStore = useActivationCodeStore();
const serverStore = useServerStore();
const { partnerLogo, partnerName } = storeToRefs(activationCodeStore);
const title = computed<string>(() =>
partnerName.value
? t(`Welcome to your new {0} system, powered by Unraid!`, [partnerName.value])
: t('Welcome to Unraid!')
);
const description = computed<string>(() =>
t(`First, youll create your devices login credentials, then youll activate your Unraid license—your devices operating system (OS).`)
);
const showModal = ref<boolean>(true);
const dropdownHide = () => { showModal.value = false; };
watchEffect(() => {
/**
* A necessary workaround for how the webgui handles font-size.
* There's not a shared CSS file between /login and any of the authenticated webgui pages.
* Which has lead to font-size differences.
* The authed webgui pages have CSS of `html { font-size: 62.5%; }` which makes REMs act as if the base font-size is 10px.
* The /login page doesn't do this.
* So we'll target the HTML element and toggle the font-size to be 62.5% when the modal is open and 100% when it's closed.
* */
const $confirmPasswordField = window.document.querySelector('#confirmPassword');
if ($confirmPasswordField) {
if (showModal.value) {
window.document.documentElement.style.setProperty('font-size', '62.5%');
} else {
window.document.documentElement.style.setProperty('font-size', '100%');
}
}
});
onBeforeMount(() => {
if (!props.server) {
throw new Error('Server data not present');
}
if (typeof props.server === 'object') { // Handles the testing dev Vue component
serverStore.setServer(props.server);
} else if (typeof props.server === 'string') { // Handle web component
const parsedServerProp = JSON.parse(props.server);
serverStore.setServer(parsedServerProp);
}
});
</script>
<template>
<div id="modals" ref="modals" class="relative z-[99999]">
<Modal
v-if="showModal"
:t="t"
:open="showModal"
:show-close-x="false"
:title="title"
:title-in-main="!!partnerLogo"
:description="description"
overlay-color="bg-background"
overlay-opacity="bg-opacity-100"
max-width="max-w-800px"
:disable-shadow="true"
:modal-vertical-center="false"
:disable-overlay-close="true"
@close="dropdownHide"
>
<template v-if="partnerLogo" #header>
<ActivationPartnerLogo />
</template>
<template #footer>
<div class="w-full flex gap-8px justify-center mx-auto">
<BrandButton
:text="t('Create a password')"
@click="dropdownHide"
/>
</div>
</template>
<template #subFooter>
<ActivationSteps :active-step="1" class="hidden sm:flex mt-6" />
</template>
</Modal>
</div>
</template>
<style lang="postcss">
@tailwind base;
@tailwind components;
.unraid_mark_2,
.unraid_mark_4 {
animation: mark_2 1.5s ease infinite;
}
.unraid_mark_3 {
animation: mark_3 1.5s ease infinite;
}
.unraid_mark_6,
.unraid_mark_8 {
animation: mark_6 1.5s ease infinite;
}
.unraid_mark_7 {
animation: mark_7 1.5s ease infinite;
}
@keyframes mark_2 {
50% {
transform: translateY(-40px);
}
100% {
transform: translateY(0);
}
}
@keyframes mark_3 {
50% {
transform: translateY(-62px);
}
100% {
transform: translateY(0);
}
}
@keyframes mark_6 {
50% {
transform: translateY(40px);
}
100% {
transform: translateY(0);
}
}
@keyframes mark_7 {
50% {
transform: translateY(62px);
}
100% {
transform: translateY(0);
}
}
@tailwind utilities;
</style>