-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44d71c0
commit 34f4b8d
Showing
12 changed files
with
97 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / ci (ubuntu-latest, 18)
|
||
/></Motion> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / ci (ubuntu-latest, 18)
|
||
/></Motion> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / ci (ubuntu-latest, 18)
|
||
/></Motion> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters