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

ApproachTabs.tsx

47 lines1.3 KB

1import { Show, createSignal } from 'solid-js'
2import TodoListCache from './TodoListCache'
3import TodoListUI from './TodoListUI'
4import type { JSX } from 'solid-js'
5​
6type Tab = 'ui-variables' | 'cache'
7​
8export default function ApproachTabs() {
9 const [activeTab, setActiveTab] = createSignal<Tab>('ui-variables')
10​
11 const tabStyle = (tab: Tab): JSX.CSSProperties => ({
12 padding: '0.5rem 1rem',
13 border: 'none',
14 'border-bottom':
15 activeTab() === tab ? '2px solid #0070f3' : '2px solid transparent',
16 background: 'none',
17 cursor: 'pointer',
18 'font-weight': activeTab() === tab ? 600 : 400,
19 color: activeTab() === tab ? '#0070f3' : '#555',
20 })
21​
22 return (
23 <div>
24 <div
25 style={{
26 display: 'flex',
27 'border-bottom': '1px solid #ddd',
28 'margin-bottom': '1.5rem',
29 }}
30 >
31 <button
32 style={tabStyle('ui-variables')}
33 onClick={() => setActiveTab('ui-variables')}
34 >
35 Via UI Variables
36 </button>
37 <button style={tabStyle('cache')} onClick={() => setActiveTab('cache')}>
38 Via Cache Manipulation
39 </button>
40 </div>
41​
42 <Show when={activeTab() === 'ui-variables'} fallback={<TodoListCache />}>
43 <TodoListUI />
44 </Show>
45 </div>
46 )