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
51 changes: 13 additions & 38 deletions app/components/IconMenuToggle.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
<script setup lang="ts">
import { motion } from 'motion-v'
import type { VariantType } from 'motion-v'

const props = defineProps<{
open: boolean
}>()

const variants: { [k: string]: VariantType | ((custom: unknown) => VariantType) } = {
normal: {
rotate: 0,
y: 0,
opacity: 1,
transition: {
type: 'spring',
bounce: 0,
duration: 0.2,
},
},
close: (custom: unknown) => {
const c = custom as number
return {
rotate: c === 1 ? 45 : -45,
y: c === 1 ? 4 : -4,
transition: {
type: 'spring',
bounce: 0,
duration: 0.2,
},
}
},
}
// 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 and moves 4px to meet the other at the middle.
const line = 'outline-none origin-center [transform-box:fill-box] transition-[translate,rotate] duration-200 ease-out motion-reduce:transition-none'
</script>

<template>
Expand All @@ -51,25 +32,19 @@ const state = computed(() => (props.open ? 'close' : 'normal'))
stroke-width="2"
stroke-linecap="butt"
>
<motion.line
<line
x1="4"
y1="8"
x2="20"
y2="8"
:variants="variants"
:animate="state"
:custom="1"
class="outline-none"
:class="[line, crossed && 'translate-y-[4px] rotate-45']"
/>
<motion.line
<line
x1="4"
y1="16"
x2="20"
y2="16"
:variants="variants"
:animate="state"
:custom="2"
class="outline-none"
:class="[line, crossed && '-translate-y-[4px] -rotate-45']"
/>
</svg>
</UButton>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"forges": "^0.3.2",
"jiti": "^2.7.0",
"js-yaml": "^5.5.0",
"motion-v": "^2.12.0",
"nuxt-agent-discovery": "^0.8.2",
"nuxt-llms": "^0.3.2",
"nuxt-og-image": "^7.0.7",
Expand Down
16 changes: 0 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading