Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

ApproachTabs.vue

46 lines1.1 KB

1<script setup lang="ts">
2import { ref } from 'vue'
3import TodoListUI from './TodoListUI.vue'
4import TodoListCache from './TodoListCache.vue'
5import type { CSSProperties } from 'vue'
6​
7type Tab = 'ui-variables' | 'cache'
8​
9const activeTab = ref<Tab>('ui-variables')
10​
11const tabStyle = (tab: Tab): CSSProperties => ({
12 padding: '0.5rem 1rem',
13 border: 'none',
14 borderBottom:
15 activeTab.value === tab ? '2px solid #0070f3' : '2px solid transparent',
16 background: 'none',
17 cursor: 'pointer',
18 fontWeight: activeTab.value === tab ? 600 : 400,
19 color: activeTab.value === tab ? '#0070f3' : '#555',
20})
21</script>
22​
23<template>
24 <div>
25 <div
26 style="
27 display: flex;
28 border-bottom: 1px solid #ddd;
29 margin-bottom: 1.5rem;
30 "
31 >
32 <button
33 :style="tabStyle('ui-variables')"
34 @click="activeTab = 'ui-variables'"
35 >
36 Via UI Variables
37 </button>
38 <button :style="tabStyle('cache')" @click="activeTab = 'cache'">
39 Via Cache Manipulation
40 </button>
41 </div>
42​
43 <TodoListUI v-if="activeTab === 'ui-variables'" />
44 <TodoListCache v-else />
45 </div>
46</template>