-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
7 changed files
with
166 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,26 @@ | ||
<script setup> | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { HeroProvider } from 'hero-motion' | ||
import Cursor from './components/Cursor.vue' | ||
import { Tab, Tabs } from './components/Tabs' | ||
const activeKey = ref(5) | ||
const isActive = i => i === activeKey.value | ||
const activeTab = ref('A') | ||
function mapRange(from, to) { | ||
return (value) => { | ||
const [fromMin, fromMax] = from | ||
const [toMin, toMax] = to | ||
return (value - fromMin) * (toMax - toMin) / (fromMax - fromMin) + toMin | ||
} | ||
function onSelect(value) { | ||
activeTab.value = value | ||
} | ||
const fontSizeRange = mapRange([1, 9], [12, 12 * 9]) | ||
const BG_COLORS = [ | ||
'#ef4444', | ||
'#f97316', | ||
'#f59e0b', | ||
'#eab308', | ||
'#84cc16', | ||
'#22c55e', | ||
'#10b981', | ||
'#14b8a6', | ||
'#06b6d4', | ||
] | ||
</script> | ||
|
||
<template> | ||
<div class="flex"> | ||
<div class="p-5 grid grid-cols-3 gap-5 shadow-xl m-5 rounded-xl bg-slate-500"> | ||
<HeroProvider :transition="{ bounce: 0 }"> | ||
<div v-for="i in 9" :key="i" class="w-32 h-32 cursor-pointer rounded-xl bg-slate-700" @click="activeKey = i"> | ||
<Cursor v-if="isActive(i)" :style="{ background: BG_COLORS[i - 1], fontSize: `${fontSizeRange(i)}px` }" /> | ||
</div> | ||
</HeroProvider> | ||
<HeroProvider> | ||
<div class="p-6"> | ||
<Tabs> | ||
<Tab :is-active="activeTab === 'A'" @click="onSelect('A')"> | ||
TabA | ||
</Tab> | ||
<Tab :is-active="activeTab === 'B'" @click="onSelect('B')"> | ||
TabB | ||
</Tab> | ||
</Tabs> | ||
</div> | ||
</div> | ||
</HeroProvider> | ||
</template> |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
<script setup lang="ts"> | ||
import TabCursor from './TabCursor.vue' | ||
defineProps<{ | ||
isActive: boolean | ||
}>() | ||
const emit = defineEmits(['click']) | ||
</script> | ||
|
||
<template> | ||
<button class="z-0 w-full px-3 py-1 flex group relative justify-center items-center cursor-pointer transition-opacity tap-highlight-transparent data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-30 data-[hover-unselected=true]:opacity-disabled outline-none data-[focus-visible=true]:z-10 data-[focus-visible=true]:outline-2 data-[focus-visible=true]:outline-focus data-[focus-visible=true]:outline-offset-2 h-8 text-small rounded-small" @click="emit('click')"> | ||
<div class="relative z-10 whitespace-nowrap transition-colors text-black/75 text-sm group-data-[selected=true]:text-default-foreground"> | ||
<slot /> | ||
</div> | ||
|
||
<TabCursor v-if="isActive" /> | ||
</button> | ||
</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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import { Hero } from 'hero-motion' | ||
</script> | ||
|
||
<template> | ||
<Hero layout-id="tab-cursor" as="span" class="absolute z-0 inset-0 rounded-lg bg-white dark:bg-default shadow-small"> | ||
<slot /> | ||
</Hero> | ||
</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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template> | ||
<div class="inline-flex"> | ||
<div class="flex p-1 h-fit gap-2 items-center flex-nowrap overflow-x-scroll scrollbar-hide bg-gray-100 rounded-xl"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Tabs from './Tabs.vue' | ||
import Tab from './Tab.vue' | ||
|
||
export { Tabs, Tab } |
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