|
1 | 1 | <script lang="ts"> |
2 | 2 | import { randomHex } from '@dvcol/common-utils/common/crypto'; |
3 | 3 |
|
4 | | - import { fade } from 'svelte/transition'; |
5 | | -
|
6 | 4 | import SphereBackdrop from '../utils/SphereBackdrop.svelte'; |
7 | 5 |
|
8 | 6 | import type { TabId } from '~/nav/neo-tab.model.js'; |
9 | 7 | import type { NeoTabsProps } from '~/nav/neo-tabs.model.js'; |
10 | 8 |
|
11 | 9 | import NeoButton from '~/buttons/NeoButton.svelte'; |
12 | 10 | import NeoButtonGroup from '~/buttons/NeoButtonGroup.svelte'; |
13 | | - import NeoCard from '~/cards/NeoCard.svelte'; |
14 | | - import TransitionContainer from '~/container/TransitionContainer.svelte'; |
15 | 11 | import IconAccount from '~/icons/IconAccount.svelte'; |
16 | 12 | import NeoTab from '~/nav/NeoTab.svelte'; |
17 | 13 | import NeoTabPane from '~/nav/NeoTabPane.svelte'; |
18 | 14 | import NeoTabs from '~/nav/NeoTabs.svelte'; |
| 15 | + import NeoTabsCard from '~/nav/NeoTabsCard.svelte'; |
19 | 16 |
|
20 | 17 | const added = $state([ |
21 | 18 | { text: `Added ${randomHex(1)}-0`, tabId: crypto.randomUUID() }, |
|
26 | 23 | if (index === -1) return; |
27 | 24 | added.splice(index, 1); |
28 | 25 | }; |
| 26 | +
|
29 | 27 | const onadd = () => { |
30 | 28 | added.push({ text: `Added ${randomHex(1)}-${added.length + 1}`, tabId: crypto.randomUUID() }); |
31 | 29 | }; |
|
40 | 38 | close: true, |
41 | 39 | add: true, |
42 | 40 | slide: true, |
| 41 | + inset: false, |
43 | 42 | shallow: false, |
44 | 43 | toggle: true, |
45 | 44 | before: false, |
|
55 | 54 | <div class="column"> |
56 | 55 | <NeoButtonGroup> |
57 | 56 | <NeoButton toggle bind:checked={options.disabled}>Disabled</NeoButton> |
| 57 | + <NeoButton toggle bind:checked={options.inset}>Inset</NeoButton> |
58 | 58 | <NeoButton toggle bind:checked={options.shallow}>Shallow</NeoButton> |
59 | 59 | <NeoButton toggle bind:checked={options.before}>Before</NeoButton> |
60 | 60 | <NeoButton toggle bind:checked={options.vertical}>Vertical</NeoButton> |
|
79 | 79 | {/snippet} |
80 | 80 |
|
81 | 81 | {#snippet content(word)} |
82 | | - <div class="panel" in:fade={{ delay: 400 }} out:fade> |
83 | | - <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
84 | | - <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
85 | | - <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
86 | | - <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
87 | | - <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
88 | | - </div> |
| 82 | + <p>{Array.from({ length: 50 }, () => word).join(' ')}</p> |
89 | 83 | {/snippet} |
90 | 84 |
|
91 | 85 | {#snippet panes()} |
92 | | - <NeoCard> |
93 | | - <TransitionContainer> |
94 | | - <NeoTabPane empty> |
95 | | - {@render content('Empty')} |
96 | | - </NeoTabPane> |
97 | | - <NeoTabPane tabId="button"> |
98 | | - {@render content('Button')} |
99 | | - </NeoTabPane> |
100 | | - <NeoTabPane tabId="icon"> |
101 | | - {@render content('Icon')} |
102 | | - </NeoTabPane> |
103 | | - <NeoTabPane tabId="reversed"> |
104 | | - {@render content('Reversed')} |
| 86 | + <NeoTabsCard class="panel"> |
| 87 | + <NeoTabPane empty> |
| 88 | + {@render content('Empty')} |
| 89 | + </NeoTabPane> |
| 90 | + <NeoTabPane tabId="button"> |
| 91 | + {@render content('Button')} |
| 92 | + </NeoTabPane> |
| 93 | + <NeoTabPane tabId="icon"> |
| 94 | + {@render content('Icon')} |
| 95 | + </NeoTabPane> |
| 96 | + <NeoTabPane tabId="reversed"> |
| 97 | + {@render content('Reversed')} |
| 98 | + </NeoTabPane> |
| 99 | + |
| 100 | + {#each added as { text, tabId } (tabId)} |
| 101 | + <NeoTabPane {tabId}> |
| 102 | + {@render content(text)} |
105 | 103 | </NeoTabPane> |
106 | | - |
107 | | - {#each added as { text, tabId } (tabId)} |
108 | | - <NeoTabPane {tabId}> |
109 | | - {@render content(text)} |
110 | | - </NeoTabPane> |
111 | | - {/each} |
112 | | - </TransitionContainer> |
113 | | - </NeoCard> |
| 104 | + {/each} |
| 105 | + </NeoTabsCard> |
114 | 106 | {/snippet} |
115 | 107 |
|
116 | 108 | {#snippet group(props: NeoTabsProps = {})} |
117 | | - <div class="column"> |
118 | | - <NeoTabs {panes} {active} {onclose} {onadd} {...options} {...props}> |
| 109 | + <div class="column" class:vertical={options.vertical}> |
| 110 | + <NeoTabs {panes} {active} {onclose} {onadd} {onchange} {...options} {...props}> |
119 | 111 | {@render tabs()} |
120 | 112 | </NeoTabs> |
121 | 113 | </div> |
|
138 | 130 | <style lang="scss"> |
139 | 131 | @use 'src/lib/styles/common/flex' as flex; |
140 | 132 |
|
| 133 | + .content { |
| 134 | + flex: 0 1 37.5rem; |
| 135 | + max-width: 37.5rem; |
| 136 | + } |
| 137 | +
|
| 138 | + :global(.panel) { |
| 139 | + min-width: 34rem; |
| 140 | + min-height: 20rem; |
| 141 | + } |
| 142 | +
|
141 | 143 | .column { |
142 | 144 | @include flex.column($center: true, $gap: var(--neo-gap-lg)); |
| 145 | +
|
| 146 | + &.vertical { |
| 147 | + flex-direction: row; |
| 148 | +
|
| 149 | + :global(.panel) { |
| 150 | + min-width: 28.5rem; |
| 151 | + min-height: 24rem; |
| 152 | + } |
| 153 | + } |
143 | 154 | } |
144 | 155 |
|
145 | 156 | .row { |
|
149 | 160 | justify-content: center; |
150 | 161 | margin: 2rem 0; |
151 | 162 | } |
152 | | -
|
153 | | - .content { |
154 | | - flex: 0 1 37.5rem; |
155 | | - max-width: 37.5rem; |
156 | | - } |
157 | | -
|
158 | | - .panel { |
159 | | - min-width: 37.5rem; |
160 | | - min-height: 15rem; |
161 | | - } |
162 | 163 | </style> |
0 commit comments