Skip to content

Morrow ​

A place to begin. Sign-in, signup, recovery and a welcome screen use the same Vue source on NativeScript and Web.

Open Morrow ↗

The forms own their drafts with MTabs keepAlive. Button demonstrates a brand mark made from Mavis primitives and a trailing badge. useToast({ scope: 'app' }) delivers the confirmation on the next Screen. Recovery demonstrates deferring feedback while a Sheet covers the page.

This is a local preview, without authentication, email delivery or password persistence. The APIs are included in Mavis 0.1.0-alpha.4.

Shared source ​

Auth.vue
vue
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { ref } from 'vue'
import type { ChoiceValue } from '@getcortexlabs/mavis-core'
import { useMavisTheme, useToast } from '@getcortexlabs/mavis-core/vue'
import { useCatalog } from '../context'
import ThemeSwitch from '../ThemeSwitch.vue'
import AuthForm from '../auth/AuthForm.vue'

const { t, choices } = useCatalogLocale()

const { theme } = useMavisTheme()
const { navigation, memberName } = useCatalog()
const toast = useToast({ scope: 'app' })
const tab = ref<ChoiceValue>('login'),
  recovery = ref(false),
  email = ref('')
const tabs = [
  { value: 'login', label: 'Sign in' },
  { value: 'signup', label: 'Create account' },
]
function complete(name: string) {
  memberName.value = name
  toast.show({
    title: `${t('Boas-vindas,')} ${name}.`,
    message: t('Your next chapter starts here.'),
    tone: 'success',
  })
  navigation.push('/showcase/morrow/home')
}
function recover() {
  toast.show({
    title: t('You’re all set.'),
    message: t('Recovery preview complete. No email was sent.'),
    tone: 'info',
  })
  recovery.value = false
}
</script>

<template>
  <m-screen scroll>
    <m-column padding="lg" gap="xl" class="morrow-container">
      <m-row justify="between" gap="sm">
        <m-button size="sm" variant="ghost" @click="navigation.back('/showcase')">{{
          t('← Showcase')
        }}</m-button>
        <ThemeSwitch />
      </m-row>
      <m-stack gap="lg" align="stretch" :responsive="{ at: 680, direction: 'row', gap: 'xl' }">
        <m-card :width="'auto'" :grow="1" padding="lg" gap="lg" elevation="sm">
          <m-column gap="sm">
            <m-text variant="overline" tone="primary">{{ t('YOU BELONG HERE') }}</m-text>
            <m-text variant="title">{{ t('Come on in.') }}</m-text>
            <m-text tone="muted">{{
              t('Pick up where you left off, or start something new.')
            }}</m-text>
          </m-column>
          <m-tabs v-model="tab" :tabs="choices(tabs)" :label="t('Your account')" keepAlive>
            <template #default="{ value }">
              <AuthForm
                :signup="value === 'signup'"
                @complete="complete"
                @recover="recovery = true"
              />
            </template>
          </m-tabs>
        </m-card>
        <m-column
          :width="'auto'"
          :grow="1"
          padding="lg"
          radius="lg"
          gap="xl"
          :backgroundColor="theme.colors.accentSoft"
        >
          <m-row gap="sm">
            <m-column
              :width="40"
              :height="40"
              radius="md"
              align="center"
              justify="center"
              :backgroundColor="theme.colors.accent"
            >
              <m-icon name="sunrise" :size="24" tone="onAccent" />
            </m-column>
            <m-text variant="heading" tone="accent">{{ t('morrow') }}</m-text>
          </m-row>
          <m-column gap="md" paddingY="lg">
            <m-text variant="overline" tone="accent">{{ t('MAKE ROOM FOR WHAT’S NEXT') }}</m-text>
            <m-text as="h1" variant="display">{{ t('A little space. A bigger tomorrow.') }}</m-text>
            <m-text tone="muted">{{
              t(
                'Your ideas, your people, your next good thing. All together, in a place that feels like you.',
              )
            }}</m-text>
          </m-column>
          <m-column gap="md" padding="lg" radius="lg" :backgroundColor="theme.colors.surface">
            <m-row justify="between" gap="md">
              <m-badge :text="t('A fresh start')" tone="primary" />
              <m-icon name="sparkles" tone="accent" />
            </m-row>
            <m-text variant="title">{{ t('Good things grow here.') }}</m-text>
            <m-row gap="xs" :accessibilityHidden="true">
              <m-box
                v-for="n in 12"
                :key="n"
                :width="0"
                :grow="1"
                :height="n % 3 === 0 ? 64 : n % 2 === 0 ? 48 : 32"
                radius="full"
                :backgroundColor="n % 2 ? theme.colors.primarySoft : theme.colors.accentSoft"
              />
            </m-row>
            <m-text variant="caption" tone="muted">{{
              t('One small step. Something worth starting.')
            }}</m-text>
          </m-column>
          <m-text variant="caption" tone="accent">{{ t('YOUR PACE. YOUR POSSIBILITIES.') }}</m-text>
        </m-column>
      </m-stack>
      <m-sheet
        v-model:open="recovery"
        :title="t('A way back in')"
        :closeLabel="t('Close recovery')"
      >
        <m-text tone="muted">{{ t('Try the recovery flow, then return to your space.') }}</m-text>
        <m-input
          v-model="email"
          :label="t('Recovery email')"
          type="email"
          :placeholder="t('you@example.com')"
          autocomplete="email"
        />
        <m-button @click="recover">{{ t('Preview recovery') }}</m-button>
      </m-sheet>
    </m-column>
  </m-screen>
</template>
AuthForm.vue
vue
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { computed, onBeforeUnmount, onDeactivated, ref } from 'vue'
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'

const { t } = useCatalogLocale()

const props = defineProps<{ signup: boolean }>()
const emit = defineEmits<{ complete: [name: string]; recover: [] }>()
const { theme } = useMavisTheme()
const name = ref(''),
  email = ref(''),
  password = ref(''),
  reveal = ref(false)
const error = ref(''),
  busy = ref(false)
let timer: ReturnType<typeof setTimeout> | undefined
const action = computed(() => ({
  icon: reveal.value ? ('eye-off' as const) : ('eye' as const),
  label: t(reveal.value ? 'Hide password' : 'Show password'),
}))
const resetWork = () => {
  clearTimeout(timer)
  busy.value = false
}
onDeactivated(resetWork)
onBeforeUnmount(resetWork)
function submit() {
  if (!email.value.trim() || !password.value) {
    error.value = 'Enter an email and a password to try the preview.'
    return
  }
  error.value = ''
  busy.value = true
  timer = setTimeout(() => {
    busy.value = false
    emit('complete', name.value.trim() || 'Alex')
  }, 550)
}
</script>

<template>
  <m-column gap="lg">
    <m-column gap="md">
      <m-input
        v-if="signup"
        v-model="name"
        :label="t('Your name')"
        :placeholder="t('Alex Morgan')"
        name="name"
        autocomplete="name"
      />
      <m-input
        v-model="email"
        :label="t('Email')"
        :placeholder="t('you@example.com')"
        type="email"
        name="email"
        autocomplete="email"
      />
      <m-input
        v-model="password"
        :label="t('Password')"
        :type="reveal ? 'text' : 'password'"
        name="password"
        :autocomplete="signup ? 'new-password' : 'current-password'"
        :trailingAction="action"
        @action="reveal = !reveal"
        @submit="submit"
      />
      <m-text v-if="error" tone="danger" variant="caption">{{ t(error) }}</m-text>
    </m-column>
    <m-button :loading="busy" :loadingText="t('Opening your space…')" @click="submit">
      {{ t(signup ? 'Create your space' : 'Welcome back') }}
      <template #trailing><m-icon name="arrow-right" tone="onPrimary" :size="18" /></template>
    </m-button>
    <m-button v-if="!signup" variant="ghost" size="sm" @click="emit('recover')">{{
      t('Forgot your password?')
    }}</m-button>
    <m-row gap="md" align="center">
      <m-box :grow="1" :width="0" :accessibilityHidden="true"><m-separator /></m-box>
      <m-text variant="caption" tone="muted">{{ t('or continue with') }}</m-text>
      <m-box :grow="1" :width="0" :accessibilityHidden="true"><m-separator /></m-box>
    </m-row>
    <m-button variant="secondary" @click="emit('complete', 'Alex')"
      >{{ t(' Continue with Studio ')
      }}<template #leading>
        <m-column
          :width="24"
          :height="24"
          radius="sm"
          align="center"
          justify="center"
          :backgroundColor="theme.colors.accent"
        >
          <m-icon name="sparkles" :size="16" tone="onAccent" />
        </m-column>
      </template>
      <template #trailing><m-badge :text="t('Demo')" tone="accent" size="sm" /></template>
    </m-button>
    <m-text variant="caption" tone="muted" align="center">{{
      t('Interactive preview. No account is created.')
    }}</m-text>
  </m-column>
</template>

Components for NativeScript and Web. Starting with Vue.