Modals
1 month ago
skeletons
5 months ago
ActionButton.vue
5 months ago
ActionButtonsSection.vue
5 months ago
Banner.vue
3 months ago
FAQ.vue
5 months ago
FormItem.vue
2 months ago
FormsSection.vue
11 months ago
Hero.vue
1 month ago
Integrations.vue
4 months ago
Pagination.vue
10 months ago
PluginEntriesTable.vue
4 months ago
PluginEntry.vue
5 months ago
PluginExpansion.vue
8 months ago
ReachContactsSummary.vue
2 weeks ago
SyncStatusLabel.vue
6 months ago
Tabs.vue
9 months ago
Toggle.vue
10 months ago
UsageCard.vue
10 months ago
UsageCardsRow.vue
1 year ago
UsageCardsSection.vue
1 year ago
WooCommerce.vue
2 weeks ago
WooCommerceEntriesTable.vue
4 months ago
Tabs.vue
66 lines
| 1 | <script setup lang="ts"> |
| 2 | import { computed } from 'vue'; |
| 3 | import { useRoute, useRouter } from 'vue-router'; |
| 4 | |
| 5 | import type { Tab } from '@/data/tabs'; |
| 6 | |
| 7 | type TabsProps = { |
| 8 | tabs: Tab[]; |
| 9 | defaultTab: string; |
| 10 | }; |
| 11 | |
| 12 | const props = defineProps<TabsProps>(); |
| 13 | |
| 14 | const route = useRoute(); |
| 15 | const router = useRouter(); |
| 16 | |
| 17 | const activeKey = computed(() => route.hash?.replace('#', '') || props.defaultTab); |
| 18 | |
| 19 | const isActive = (key: string): boolean => activeKey.value === key; |
| 20 | |
| 21 | const setTab = (key: string): void => { |
| 22 | router.push({ path: route.path, hash: `#${key}` }); |
| 23 | }; |
| 24 | </script> |
| 25 | |
| 26 | <template> |
| 27 | <div class="integration-tabs" role="tablist"> |
| 28 | <button |
| 29 | v-for="tab in props.tabs" |
| 30 | :key="tab.key" |
| 31 | class="integration-tabs__tab" |
| 32 | :class="{ 'is-active': isActive(tab.key) }" |
| 33 | role="tab" |
| 34 | @click="() => setTab(tab.key)" |
| 35 | > |
| 36 | {{ tab.label }} |
| 37 | </button> |
| 38 | </div> |
| 39 | </template> |
| 40 | |
| 41 | <style scoped lang="scss"> |
| 42 | .integration-tabs { |
| 43 | display: flex; |
| 44 | gap: 16px; |
| 45 | width: 100%; |
| 46 | } |
| 47 | |
| 48 | .integration-tabs__tab { |
| 49 | border: 1px solid var(--neutral--200); |
| 50 | background: var(--neutral--0); |
| 51 | color: var(--neutral--500); |
| 52 | border-radius: 24px; |
| 53 | padding: 4px 16px; |
| 54 | font-weight: bold; |
| 55 | font-size: 14px; |
| 56 | line-height: 20px; |
| 57 | cursor: pointer; |
| 58 | } |
| 59 | |
| 60 | .integration-tabs__tab.is-active { |
| 61 | background: var(--neutral--500); |
| 62 | color: var(--neutral--0); |
| 63 | font-weight: normal; |
| 64 | } |
| 65 | </style> |
| 66 |