Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/components/Feedback.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { AnimatePresence, motion, useReducedMotion } from 'motion-v'
import type { FormError } from '@nuxt/ui'

const props = defineProps<{
page: {
Expand All @@ -24,6 +25,13 @@ const FEEDBACK_MOODS: Record<FeedbackRating, { mood: NuxiMood, text: string, hov
'confusing': { mood: 'confused', text: 'text-warning', hover: 'hover:text-warning hover:border-warning/50', active: 'text-warning border-warning bg-warning/15' }
}

function validateFeedback(state: Partial<typeof formState>): FormError[] {
const length = state.feedback?.trim().length ?? 0
return length > 0 && length < 10
? [{ name: 'feedback', message: 'Please provide at least 10 characters or leave the field empty' }]
: []
}

const previewRating = ref<FeedbackRating | null>(null)
const reactiveRating = computed(() => previewRating.value ?? formState.rating)

Expand Down Expand Up @@ -135,7 +143,7 @@ const success = computed(() => ({
<div class="min-h-0 overflow-hidden -mx-1 px-1">
<UForm
:state="formState"
:schema="feedbackFormSchema"
:validate="validateFeedback"
class="max-w-md pt-3 pb-1 space-y-2"
@submit="submitFeedback"
>
Expand Down
53 changes: 15 additions & 38 deletions app/components/header/HeaderToggle.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { motion } from 'motion-v'
import type { VariantType } from 'motion-v'
import { useLocale } from '@nuxt/ui/composables/useLocale'

const props = defineProps<{
Expand All @@ -9,28 +7,16 @@ const props = defineProps<{

const { t } = useLocale()

const variants: { [k: string]: VariantType | ((custom: unknown) => VariantType) } = {
normal: {
rotate: 0,
y: 0,
opacity: 1
},
close: (custom: unknown) => {
const c = custom as number
return {
rotate: c === 1 ? 45 : c === 3 ? -45 : 0,
y: c === 1 ? 6 : c === 3 ? -6 : 0,
opacity: c === 2 ? 0 : 1,
transition: {
type: 'spring',
stiffness: 260,
damping: 20
}
}
}
}
// UHeader renders a second toggle in its menu overlay, mounted already open. Draw it closed for its
// first frame so the lines transition into the cross instead of appearing as one.
const ready = ref(false)
onMounted(() => requestAnimationFrame(() => requestAnimationFrame(() => {
ready.value = true
})))
const crossed = computed(() => props.open && ready.value)

const state = computed(() => props.open ? 'close' : 'normal')
// Each line turns around its own center; the overshoot approximates the spring the toggle used to have.
const line = 'outline-none origin-center [transform-box:fill-box] transition-[translate,rotate,opacity] duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] motion-reduce:transition-none'
</script>

<template>
Expand All @@ -53,35 +39,26 @@ const state = computed(() => props.open ? 'close' : 'normal')
stroke-linecap="round"
stroke-linejoin="round"
>
<motion.line
<line
x1="4"
y1="6"
x2="20"
y2="6"
:variants="variants"
:animate="state"
:custom="1"
class="outline-none"
:class="[line, crossed && 'translate-y-[6px] rotate-45']"
/>
<motion.line
<line
x1="4"
y1="12"
x2="20"
y2="12"
:variants="variants"
:animate="state"
:custom="2"
class="outline-none"
:class="[line, crossed && 'opacity-0']"
/>
<motion.line
<line
x1="4"
y1="18"
x2="20"
y2="18"
:variants="variants"
:animate="state"
:custom="3"
class="outline-none"
:class="[line, crossed && '-translate-y-[6px] -rotate-45']"
/>
</svg>
</UButton>
Expand Down
4 changes: 2 additions & 2 deletions app/components/module/ModuleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ const items = computed(() => [
</template>

<UBadge
v-show="showBadge && module.type === 'official'"
v-if="showBadge && module.type === 'official'"
class="shine absolute top-4 right-4 sm:top-6 sm:right-6"
variant="subtle"
color="primary"
label="Official"
/>

<UBadge
v-show="showBadge && module.sponsor"
v-if="showBadge && module.sponsor"
class="shine absolute top-4 right-4 sm:top-6 sm:right-6"
variant="subtle"
color="important"
Expand Down
18 changes: 8 additions & 10 deletions app/components/newsletter/NewsletterForm.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import * as v from 'valibot'
import type { FormSubmitEvent } from '#ui/types'
import type { FormError, FormSubmitEvent } from '#ui/types'

const {
label = 'Subscribe to our newsletter',
Expand All @@ -17,17 +16,16 @@ const { track } = useAnalytics()

const loading = ref(false)

const schema = v.object({
email: v.pipe(v.string(), v.email('Please enter a valid email'))
})

type Schema = v.InferOutput<typeof schema>

const state = reactive({
email: ''
})

async function onSubmit(event: FormSubmitEvent<Schema>) {
// The server validates the address too; this only catches typos before the request.
function validate(data: Partial<typeof state>): FormError[] {
return /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/.test(data.email ?? '') ? [] : [{ name: 'email', message: 'Please enter a valid email' }]
}

async function onSubmit(event: FormSubmitEvent<typeof state>) {
loading.value = true

await $fetch('/api/newsletter/subscribe', {
Expand All @@ -49,7 +47,7 @@ async function onSubmit(event: FormSubmitEvent<Schema>) {
</script>

<template>
<UForm :schema="schema" :state="state" :validate-on="[]" class="block" @submit="onSubmit">
<UForm :validate="validate" :state="state" :validate-on="[]" class="block" @submit="onSubmit">
<UFormField name="email" :label="label" :size="size" :description="description" :ui="{ label: 'font-semibold', container: label ? 'mt-3' : '' }">
<UFieldGroup :size="size" class="max-w-sm w-full">
<UInput
Expand Down
3 changes: 1 addition & 2 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,13 @@ useNuxtBirthday()
>
<UTabs
:items="tabs"
:unmount-on-hide="false"
color="neutral"
:ui="{
list: 'px-0 bg-transparent lg:pr-4 overflow-x-auto',
trigger: 'group data-[state=active]:text-highlighted shrink-0 in-[[data-slot=list]:not(:has([data-slot=indicator]))]:data-[state=active]:before:bg-default',
indicator: 'bg-default',
leadingIcon: 'group-data-[state=active]:text-primary size-4 hidden sm:inline-flex',
content: 'lg:h-[450px] bg-default [@media(min-width:2400px)]:border-e [@media(min-width:2400px)]:border-default [@media(min-width:2400px)]:rounded-l-[calc(var(--ui-radius)*1.5)] transition-opacity duration-500 data-[state=inactive]:opacity-0 opacity-100'
content: 'lg:h-[450px] bg-default [@media(min-width:2400px)]:border-e [@media(min-width:2400px)]:border-default [@media(min-width:2400px)]:rounded-l-[calc(var(--ui-radius)*1.5)]'
}"
>
<template #content="{ item, index }">
Expand Down
16 changes: 7 additions & 9 deletions layers/nuxi/app/components/agent/AgentChatButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { AnimatePresence, motion } from 'motion-v'

const { toggle, isOpen } = useNuxtAgent()
const { track } = useAnalytics()

Expand All @@ -11,13 +9,13 @@ function handleToggle() {
</script>

<template>
<AnimatePresence :initial="false">
<motion.div
<Transition
enter-active-class="transition-[opacity,scale,filter] duration-250 ease-out motion-reduce:transition-none"
enter-from-class="opacity-0 scale-80 blur-xs"
>
<div
v-if="!isOpen"
class="inline-flex items-center"
:initial="{ opacity: 0, scale: 0.8, filter: 'blur(4px)' }"
:animate="{ opacity: 1, scale: 1, filter: 'blur(0px)' }"
:transition="{ duration: 0.25, ease: 'easeOut' }"
>
<UButton
color="neutral"
Expand All @@ -37,6 +35,6 @@ function handleToggle() {
</span>
</template>
</UButton>
</motion.div>
</AnimatePresence>
</div>
</Transition>
</template>
28 changes: 10 additions & 18 deletions layers/nuxi/app/components/agent/AgentChatSwitcher.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { motion } from 'motion-v'

const { isOpen, nuxiMood } = useNuxtAgent()
const { chatList } = useChats()

Expand Down Expand Up @@ -44,14 +42,11 @@ watch(popoverOpen, (open) => {
v-if="!hasChatHistory"
class="inline-flex items-center gap-2 min-w-0"
>
<motion.span
:initial="{ opacity: 0, scale: 0.5, filter: 'blur(4px)' }"
:animate="{ opacity: 1, scale: 1, filter: 'blur(0px)' }"
:transition="{ duration: 0.3, ease: 'easeOut', delay: 0.1 }"
class="inline-flex"
>
<AgentNuxiIcon class="size-5 shrink-0" :mood="nuxiMood" />
</motion.span>
<Transition appear enter-from-class="opacity-0 scale-50 blur-xs" enter-active-class="transition-[opacity,scale,filter] duration-300 delay-100 ease-out motion-reduce:transition-none">
<span class="inline-flex">
<AgentNuxiIcon class="size-5 shrink-0" :mood="nuxiMood" />
</span>
</Transition>
<span class="truncate">Nuxi</span>
<UBadge variant="subtle" size="sm" class="shrink-0">
Beta
Expand All @@ -73,14 +68,11 @@ watch(popoverOpen, (open) => {
:ui="{ label: 'truncate min-w-0' }"
>
<template #leading>
<motion.span
:initial="{ opacity: 0, scale: 0.5, filter: 'blur(4px)' }"
:animate="{ opacity: 1, scale: 1, filter: 'blur(0px)' }"
:transition="{ duration: 0.3, ease: 'easeOut', delay: 0.1 }"
class="inline-flex"
>
<AgentNuxiIcon class="size-5 shrink-0" :mood="nuxiMood" />
</motion.span>
<Transition appear enter-from-class="opacity-0 scale-50 blur-xs" enter-active-class="transition-[opacity,scale,filter] duration-300 delay-100 ease-out motion-reduce:transition-none">
<span class="inline-flex">
<AgentNuxiIcon class="size-5 shrink-0" :mood="nuxiMood" />
</span>
</Transition>
</template>
</UButton>

Expand Down
21 changes: 10 additions & 11 deletions layers/nuxi/app/components/agent/AgentFloatingInput.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { AnimatePresence, motion } from 'motion-v'

const route = useRoute()
const { open, isOpen } = useNuxtAgent()
const { track } = useAnalytics()
Expand Down Expand Up @@ -50,14 +48,15 @@ function onEscape() {
</script>

<template>
<AnimatePresence>
<motion.div
<Transition
appear
enter-active-class="transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none"
enter-from-class="translate-y-5 opacity-0"
leave-active-class="transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none"
leave-to-class="translate-y-25 opacity-0"
>
<div
v-if="isDocsRoute && isVisible && !isOpen"
key="floating-input"
:initial="{ y: 20, opacity: 0 }"
:animate="{ y: 0, opacity: 1 }"
:exit="{ y: 100, opacity: 0 }"
:transition="{ duration: 0.2, ease: 'easeOut' }"
class="pointer-events-none fixed inset-x-0 z-10 bottom-[max(1.5rem,env(safe-area-inset-bottom))] px-4 lg:px-80"
style="will-change: transform"
>
Expand Down Expand Up @@ -99,6 +98,6 @@ function onEscape() {
</UInput>
</div>
</form>
</motion.div>
</AnimatePresence>
</div>
</Transition>
</template>
14 changes: 5 additions & 9 deletions layers/nuxi/app/components/agent/AgentPanel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { UIMessage } from 'ai'
import { motion } from 'motion-v'

const {
isOpen,
Expand Down Expand Up @@ -104,14 +103,11 @@ defineShortcuts(computed(() => ({
<template #title>
<AgentChatSwitcher v-if="loggedIn" class="min-w-0" />
<span v-else class="inline-flex items-center gap-2 min-w-0">
<motion.span
:initial="{ opacity: 0, scale: 0.5, filter: 'blur(4px)' }"
:animate="{ opacity: 1, scale: 1, filter: 'blur(0px)' }"
:transition="{ duration: 0.3, ease: 'easeOut', delay: 0.1 }"
class="inline-flex"
>
<AgentNuxiIcon class="size-5 shrink-0" :mood="nuxiMood" />
</motion.span>
<Transition appear enter-from-class="opacity-0 scale-50 blur-xs" enter-active-class="transition-[opacity,scale,filter] duration-300 delay-100 ease-out motion-reduce:transition-none">
<span class="inline-flex">
<AgentNuxiIcon class="size-5 shrink-0" :mood="nuxiMood" />
</span>
</Transition>
<span class="truncate">Nuxi</span>
<UBadge variant="subtle" size="sm" class="shrink-0">
Beta
Expand Down
Loading
Loading