Logo和主题色变换
This commit is contained in:
parent
d0202bcca6
commit
a886f64efa
|
|
@ -1,26 +1,62 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type {NavigationMenuItem} from '@nuxt/ui'
|
import type {NavigationMenuItem} from '@nuxt/ui'
|
||||||
|
|
||||||
defineProps<{
|
const route = useRoute()
|
||||||
links: NavigationMenuItem[]
|
|
||||||
}>()
|
const items = computed<NavigationMenuItem[]>(() => [
|
||||||
|
{
|
||||||
|
label: 'Docs',
|
||||||
|
to: '/docs/getting-started',
|
||||||
|
active: route.path.startsWith('/docs/getting-started')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Components',
|
||||||
|
to: '/docs/components',
|
||||||
|
active: route.path.startsWith('/docs/components')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Figma',
|
||||||
|
to: 'https://go.nuxt.com/figma-ui',
|
||||||
|
target: '_blank'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Releases',
|
||||||
|
to: 'https://github.com/nuxt/ui/releases',
|
||||||
|
target: '_blank'
|
||||||
|
}
|
||||||
|
])
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="fixed top-2 sm:top-4 mx-auto left-1/2 transform -translate-x-1/2 z-10">
|
<UHeader>
|
||||||
<UNavigationMenu
|
<template #title>
|
||||||
:items="links"
|
<Logo class="h-6 w-auto"/>
|
||||||
:ui="{
|
</template>
|
||||||
link: 'px-2 py-1',
|
|
||||||
linkLeadingIcon: 'hidden'
|
<UNavigationMenu :items="items"/>
|
||||||
}"
|
|
||||||
class="bg-muted/80 backdrop-blur-sm rounded-full px-2 sm:px-4 border border-muted/50 shadow-lg shadow-neutral-950/5"
|
<template #right>
|
||||||
color="neutral"
|
<ColorModeButton/>
|
||||||
variant="link"
|
|
||||||
>
|
<!-- <UTooltip :kbds="['meta', 'G']" text="Open on GitHub">-->
|
||||||
<template #list-trailing>
|
<!-- <UButton-->
|
||||||
<ColorModeButton/>
|
<!-- aria-label="GitHub"-->
|
||||||
</template>
|
<!-- color="neutral"-->
|
||||||
</UNavigationMenu>
|
<!-- icon="i-simple-icons-github"-->
|
||||||
</div>
|
<!-- target="_blank"-->
|
||||||
|
<!-- to="https://github.com/nuxt/ui"-->
|
||||||
|
<!-- variant="ghost"-->
|
||||||
|
<!-- />-->
|
||||||
|
<!-- </UTooltip>-->
|
||||||
|
</template>
|
||||||
|
<template #body>
|
||||||
|
<div class="px-4 py-2">
|
||||||
|
<UNavigationMenu
|
||||||
|
:items="items"
|
||||||
|
class="-mx-2.5"
|
||||||
|
orientation="vertical"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</UHeader>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script lang="ts" setup>
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
|
|
||||||
const nextTheme = computed(() => (colorMode.value === 'dark' ? 'light' : 'dark'))
|
const nextTheme = computed(() => (colorMode.value === 'dark' ? 'light' : 'dark'))
|
||||||
|
|
@ -16,8 +16,8 @@ const startViewTransition = (event: MouseEvent) => {
|
||||||
const x = event.clientX
|
const x = event.clientX
|
||||||
const y = event.clientY
|
const y = event.clientY
|
||||||
const endRadius = Math.hypot(
|
const endRadius = Math.hypot(
|
||||||
Math.max(x, window.innerWidth - x),
|
Math.max(x, window.innerWidth - x),
|
||||||
Math.max(y, window.innerHeight - y)
|
Math.max(y, window.innerHeight - y)
|
||||||
)
|
)
|
||||||
|
|
||||||
const transition = document.startViewTransition(() => {
|
const transition = document.startViewTransition(() => {
|
||||||
|
|
@ -25,19 +25,19 @@ const startViewTransition = (event: MouseEvent) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
transition.ready.then(() => {
|
transition.ready.then(() => {
|
||||||
const duration = 600
|
const duration = 1000
|
||||||
document.documentElement.animate(
|
document.documentElement.animate(
|
||||||
{
|
{
|
||||||
clipPath: [
|
clipPath: [
|
||||||
`circle(0px at ${x}px ${y}px)`,
|
`circle(0px at ${x}px ${y}px)`,
|
||||||
`circle(${endRadius}px at ${x}px ${y}px)`
|
`circle(${endRadius}px at ${x}px ${y}px)`
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
duration: duration,
|
duration: duration,
|
||||||
easing: 'cubic-bezier(.76,.32,.29,.99)',
|
easing: 'cubic-bezier(.76,.32,.29,.99)',
|
||||||
pseudoElement: '::view-transition-new(root)'
|
pseudoElement: '::view-transition-new(root)'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -46,16 +46,16 @@ const startViewTransition = (event: MouseEvent) => {
|
||||||
<template>
|
<template>
|
||||||
<ClientOnly>
|
<ClientOnly>
|
||||||
<UButton
|
<UButton
|
||||||
:aria-label="`Switch to ${nextTheme} mode`"
|
:aria-label="`Switch to ${nextTheme} mode`"
|
||||||
:icon="`i-lucide-${nextTheme === 'dark' ? 'sun' : 'moon'}`"
|
:icon="`i-lucide-${nextTheme === 'dark' ? 'sun' : 'moon'}`"
|
||||||
color="neutral"
|
class="rounded-full"
|
||||||
variant="ghost"
|
color="neutral"
|
||||||
size="sm"
|
size="sm"
|
||||||
class="rounded-full"
|
variant="ghost"
|
||||||
@click="startViewTransition"
|
@click="startViewTransition"
|
||||||
/>
|
/>
|
||||||
<template #fallback>
|
<template #fallback>
|
||||||
<div class="size-4" />
|
<div class="size-4"/>
|
||||||
</template>
|
</template>
|
||||||
</ClientOnly>
|
</ClientOnly>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -70,6 +70,7 @@ const startViewTransition = (event: MouseEvent) => {
|
||||||
::view-transition-new(root) {
|
::view-transition-new(root) {
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
::view-transition-old(root) {
|
::view-transition-old(root) {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
app/components/Logo.vue
Normal file
13
app/components/Logo.vue
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<template>
|
||||||
|
<NuxtLink class="flex items-center" to="/">
|
||||||
|
<NuxtImg
|
||||||
|
alt="创特物联"
|
||||||
|
class="h-12 w-auto dark:invert"
|
||||||
|
loading="eager"
|
||||||
|
src="https://cbu01.alicdn.com/img/ibank/O1CN01uZ3fTP1Bs31lE2Mlf_!!0-0-cib.jpg"
|
||||||
|
/>
|
||||||
|
创特物联
|
||||||
|
</NuxtLink>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
</script>
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<UContainer class="sm:border-x border-default pt-10">
|
|
||||||
<AppHeader :links="navLinks"/>
|
<AppHeader :links="navLinks"/>
|
||||||
<slot/>
|
<slot/>
|
||||||
<AppFooter/>
|
<AppFooter/>
|
||||||
</UContainer>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user