Skip to content

Commit

Permalink
docs: animation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Jun 3, 2024
1 parent 44d71c0 commit 34f4b8d
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 21 deletions.
6 changes: 4 additions & 2 deletions docs/components/content/ProseA.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<Motion
:initial="{ y: '1em', opacity: 0 }"
:visible-once="{ y: '0em', opacity: 1 }"
:initial="{ y: '0em', opacity: 1, scaleY: 1.15, scaleX: 0.95, transition: {damping:5,mass:1 } }"

Check failure on line 3 in docs/components/content/ProseA.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

A space is required after '{'

Check failure on line 3 in docs/components/content/ProseA.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Missing space before value for key 'damping'

Check failure on line 3 in docs/components/content/ProseA.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

A space is required after ','

Check failure on line 3 in docs/components/content/ProseA.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Missing space before value for key 'mass'
:visible-once="{ y: '0em', opacity: 1,rotate: 0, scaleY: 1, scaleX: 1, transition: {damping:5,mass:1 } }"

Check failure on line 4 in docs/components/content/ProseA.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

A space is required after ','

Check failure on line 4 in docs/components/content/ProseA.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

A space is required after '{'
:hovered="{scaleY: 1.05, scaleX: 1.05, rotate: -0.25, transition: {damping:5,mass:1 }}"
:tapped="{scaleY: 0.95, scaleX:0.95, rotate: 0.25, transition: {damping:5,mass:1 }}"
is="span"

Check warning on line 7 in docs/components/content/ProseA.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Attribute "is" should go before ":tapped"
style="display: inline-block"
>
Expand Down
4 changes: 2 additions & 2 deletions docs/components/content/ProseCode.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="code"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .1, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .1, damping: 10 } }"
><slot

Check warning on line 6 in docs/components/content/ProseCode.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected 1 line break after opening tag (`<Motion>`), but no line breaks found

Check warning on line 6 in docs/components/content/ProseCode.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected no line breaks before closing bracket, but 1 line break found
/></Motion>

Check warning on line 7 in docs/components/content/ProseCode.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected 1 line break before closing tag (`</motion>`), but no line breaks found
</template>
4 changes: 2 additions & 2 deletions docs/components/content/ProseH1.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="h1"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .85, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .85, damping: 10 } }"
><slot

Check warning on line 6 in docs/components/content/ProseH1.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected 1 line break after opening tag (`<Motion>`), but no line breaks found

Check warning on line 6 in docs/components/content/ProseH1.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected no line breaks before closing bracket, but 1 line break found
/></Motion>

Check warning on line 7 in docs/components/content/ProseH1.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected 1 line break before closing tag (`</motion>`), but no line breaks found
</template>
4 changes: 2 additions & 2 deletions docs/components/content/ProseH2.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="h2"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .75, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .75, damping: 10 } }"
><slot

Check warning on line 6 in docs/components/content/ProseH2.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected 1 line break after opening tag (`<Motion>`), but no line breaks found

Check warning on line 6 in docs/components/content/ProseH2.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected no line breaks before closing bracket, but 1 line break found
/></Motion>

Check warning on line 7 in docs/components/content/ProseH2.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 18)

Expected 1 line break before closing tag (`</motion>`), but no line breaks found
</template>
4 changes: 2 additions & 2 deletions docs/components/content/ProseH3.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="h3"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .25, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .25, damping: 10 } }"
><slot
/></Motion>
</template>
4 changes: 2 additions & 2 deletions docs/components/content/ProseH4.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="h4"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .25, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .25, damping: 10 } }"
><slot
/></Motion>
</template>
4 changes: 2 additions & 2 deletions docs/components/content/ProseH5.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="h5"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .25, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .25, damping: 10 } }"
><slot
/></Motion>
</template>
4 changes: 2 additions & 2 deletions docs/components/content/ProseP.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="p"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .5, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .5, damping: 10 } }"
><slot
/></Motion>
</template>
4 changes: 2 additions & 2 deletions docs/components/content/ProsePre.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<Motion
is="pre"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .1, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .1, damping: 10 } }"
:class="$props.class"
><slot
/></Motion>
Expand Down
2 changes: 1 addition & 1 deletion docs/components/content/ProseUl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineComponent({
node.props['visible-once'] ??= {
x: 0,
opacity: 1,
transition: { delay: 100 * i },
transition: { delay: 50 * i },
}

// @ts-expect-error type conflict but seems to work fine
Expand Down
74 changes: 74 additions & 0 deletions docs/components/global/CodeGroup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<div :class="ui.wrapper" v-bind="attrs">
<div :class="ui.header">
<Motion
is="button"
:initial="{scaleY: 1, scaleX: 1, transition: {damping:5,mass:.25 }}"
:hovered="{scaleY: 1.15, scaleX: .9, transition: {damping:5,mass:.25 }}"
:tapped="{scaleY: .5, scaleX:1.15, transition: {damping:5,mass:.25 }}"
v-for="(tab, index) in tabs"
:key="index"
tabindex="-1"
:class="[ui.tab.base, selectedIndex === index ? ui.tab.active : ui.tab.inactive]"
@click="selectedIndex = index"
>
<ProseCodeIcon :icon="tab.icon" :filename="tab.label" :class="ui.tab.icon.base" />
<span>{{ tab.label }}</span>
</Motion>
</div>

<component :is="selectedTab?.component" :key="selectedIndex" hide-header />
</div>
</template>

<script setup lang="ts">
import type { PropType } from 'vue'
const config = {
wrapper: 'relative [&>div:last-child]:!my-0 [&>div:last-child]:!static my-5',
header: 'flex items-center gap-1 border border-gray-200 dark:border-gray-700 border-b-0 rounded-t-md overflow-hidden p-2',
tab: {
base: 'px-2 py-1.5 focus:outline-none text-gray-700 dark:text-gray-200 text-sm rounded-md flex items-center gap-1.5',
active: 'bg-gray-100 dark:bg-gray-800',
inactive: 'hover:bg-gray-50 dark:hover:bg-gray-800/50',
icon: {
base: ''
}
}
}
defineOptions({
inheritAttrs: false
})
const props = defineProps({
class: {
type: [String, Object, Array] as PropType<any>,
default: undefined
}
})
const slots = useSlots()
const { ui, attrs } = useUI('content.codeGroup', undefined, config, toRef(props, 'class'), true)
const selectedIndex = ref(0)
defineExpose({ selectedIndex })
function transformSlot (slot: any, index: number) {
if (typeof slot.type === 'symbol') {
return slot.children?.map(transformSlot)
}
return {
label: slot.props?.filename || slot.props?.label || `${index}`,
icon: slot.props?.icon,
component: slot
}
}
// Computed
const tabs = computed(() => slots.default?.()?.flatMap(transformSlot).filter(Boolean) || [])
const selectedTab = computed(() => tabs.value.find((_, index) => index === selectedIndex.value))
</script>
4 changes: 2 additions & 2 deletions docs/pages/docs/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const UPageHeaderComponent = resolveComponent('UPageHeader')
<UPage>
<Motion
:is="UPageHeaderComponent"
:initial="{ y: 100, opacity: 0 }"
:visible-once="{ y: 0, opacity: 1 }"
:initial="{ y: 100, opacity: 0, transition: { mass: .25, damping: 10 } }"
:visible-once="{ y: 0, opacity: 1, transition: { mass: .25, damping: 10 } }"
:title="page.title"
:description="page.description"
:links="page.links"
Expand Down

0 comments on commit 34f4b8d

Please sign in to comment.