fix: added slide animation to tab active indicator
This commit is contained in:
parent
b97e29acdd
commit
23e4e0d9a4
@ -54,26 +54,28 @@
|
|||||||
<Button icon="more-horizontal" />
|
<Button icon="more-horizontal" />
|
||||||
</template>
|
</template>
|
||||||
</LayoutHeader>
|
</LayoutHeader>
|
||||||
<TabGroup v-if="lead.doc">
|
<TabGroup v-if="lead.doc" @change="moveIndicator">
|
||||||
<TabList class="flex items-center gap-6 border-b pl-5">
|
<TabList class="flex items-center gap-6 border-b pl-5 relative">
|
||||||
<Tab
|
<Tab
|
||||||
|
ref="tabRef"
|
||||||
as="template"
|
as="template"
|
||||||
v-for="tab in tabs"
|
v-for="tab in tabs"
|
||||||
:key="tab.label"
|
:key="tab.label"
|
||||||
v-slot="{ selected }"
|
v-slot="{ selected }"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="flex items-center gap-2 py-2 border-b hover:text-gray-900 -mb-[1px]"
|
class="flex items-center gap-2 py-2 -mb-[1px] text-gray-600 border-b border-transparent hover:text-gray-900 hover:border-gray-400 transition-all duration-300 ease-in-out"
|
||||||
:class="
|
:class="{ 'text-gray-900': selected }"
|
||||||
selected
|
|
||||||
? 'border-blue-500 text-gray-900 hover:border-blue-500'
|
|
||||||
: 'border-transparent text-gray-700 hover:border-gray-400'
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
|
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
|
||||||
{{ tab.label }}
|
{{ tab.label }}
|
||||||
</button>
|
</button>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
<div
|
||||||
|
ref="indicator"
|
||||||
|
class="h-[1px] bg-blue-500 w-[82px] absolute -bottom-[1px]"
|
||||||
|
:style="{ left: `${indicatorLeftValue}px` }"
|
||||||
|
/>
|
||||||
</TabList>
|
</TabList>
|
||||||
<TabPanels class="flex h-full">
|
<TabPanels class="flex h-full">
|
||||||
<TabPanel class="flex-1 bg-gray-50" v-for="tab in tabs">
|
<TabPanel class="flex-1 bg-gray-50" v-for="tab in tabs">
|
||||||
@ -137,8 +139,9 @@ import {
|
|||||||
FeatherIcon,
|
FeatherIcon,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
|
import { TransitionPresets, useTransition } from '@vueuse/core'
|
||||||
import { usersStore } from '../stores/users'
|
import { usersStore } from '../stores/users'
|
||||||
import { computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
|
|
||||||
@ -177,6 +180,21 @@ const tabs = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const tabRef = ref([])
|
||||||
|
const indicator = ref(null)
|
||||||
|
|
||||||
|
let indicatorLeft = ref(20)
|
||||||
|
const indicatorLeftValue = useTransition(indicatorLeft, {
|
||||||
|
duration: 250,
|
||||||
|
ease: TransitionPresets.easeOutCubic,
|
||||||
|
})
|
||||||
|
|
||||||
|
const moveIndicator = (index) => {
|
||||||
|
const selectedTab = tabRef.value[index].el
|
||||||
|
indicator.value.style.width = `${selectedTab.offsetWidth}px`
|
||||||
|
indicatorLeft.value = selectedTab.offsetLeft
|
||||||
|
}
|
||||||
|
|
||||||
const statusDropdownOptions = [
|
const statusDropdownOptions = [
|
||||||
{
|
{
|
||||||
label: 'New',
|
label: 'New',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user