|
8 | 8 |
|
9 | 9 | import NeoButton from '~/buttons/NeoButton.svelte'; |
10 | 10 | import NeoButtonGroup from '~/buttons/NeoButtonGroup.svelte'; |
| 11 | + import NeoCard from '~/cards/NeoCard.svelte'; |
11 | 12 | import IconAccount from '~/icons/IconAccount.svelte'; |
12 | 13 | import NeoTab from '~/nav/NeoTab.svelte'; |
13 | 14 | import NeoTabPane from '~/nav/NeoTabPane.svelte'; |
|
32 | 33 | }; |
33 | 34 |
|
34 | 35 | let loading = $state(false); |
35 | | - let skeleton = $state(false); |
36 | | - let vertical = $state(false); |
37 | | - const options = $state({ disabled: false, close: true, add: true, slide: true, shallow: false, toggle: true, position: 'after' }); |
38 | | -
|
39 | | - const togglePosition = () => { |
40 | | - options.position = options.position === 'after' ? 'before' : 'after'; |
41 | | - }; |
| 36 | + const options = $state<TabsProps>({ |
| 37 | + disabled: false, |
| 38 | + close: true, |
| 39 | + add: true, |
| 40 | + slide: true, |
| 41 | + shallow: false, |
| 42 | + toggle: true, |
| 43 | + before: false, |
| 44 | + skeleton: false, |
| 45 | + vertical: false, |
| 46 | + }); |
42 | 47 |
|
43 | 48 | const columns: { label: string; props?: TabsProps }[] = [{ label: 'Default' }]; |
44 | 49 | </script> |
|
48 | 53 | <NeoButtonGroup> |
49 | 54 | <NeoButton toggle bind:checked={options.disabled}>Disabled</NeoButton> |
50 | 55 | <NeoButton toggle bind:checked={options.shallow}>Shallow</NeoButton> |
51 | | - <NeoButton onclick={togglePosition}>Position</NeoButton> |
52 | | - <NeoButton toggle bind:checked={vertical}>Vertical</NeoButton> |
53 | | - <NeoButton toggle bind:checked={skeleton}>Skeleton</NeoButton> |
| 56 | + <NeoButton toggle bind:checked={options.before}>Before</NeoButton> |
| 57 | + <NeoButton toggle bind:checked={options.vertical}>Vertical</NeoButton> |
| 58 | + <NeoButton toggle bind:checked={options.skeleton}>Skeleton</NeoButton> |
54 | 59 | <NeoButton toggle bind:checked={loading}>Loading</NeoButton> |
55 | 60 | <NeoButton onclick={onClear}>Clear</NeoButton> |
56 | 61 | </NeoButtonGroup> |
|
70 | 75 | {/each} |
71 | 76 | {/snippet} |
72 | 77 |
|
| 78 | +{#snippet content(word)} |
| 79 | + <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
| 80 | + <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
| 81 | + <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
| 82 | + <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
| 83 | + <div>{Array.from({ length: 10 }, () => word).join(' ')}</div> |
| 84 | +{/snippet} |
| 85 | + |
73 | 86 | {#snippet panes()} |
74 | | - <NeoTabPane empty> |
75 | | - <div>Empty</div> |
76 | | - </NeoTabPane> |
77 | | - <NeoTabPane tabId="button"> |
78 | | - <div>Button</div> |
79 | | - </NeoTabPane> |
80 | | - <NeoTabPane tabId="icon" {loading} {icon}> |
81 | | - <div>Icon</div> |
82 | | - </NeoTabPane> |
83 | | - <NeoTabPane tabId="reversed" {icon}> |
84 | | - <div>Reversed</div> |
85 | | - </NeoTabPane> |
86 | | - |
87 | | - {#each added as { text, tabId } (tabId)} |
88 | | - <NeoTabPane {tabId}>{text}</NeoTabPane> |
89 | | - {/each} |
| 87 | + <NeoCard> |
| 88 | + <NeoTabPane empty> |
| 89 | + {@render content('Empty')} |
| 90 | + </NeoTabPane> |
| 91 | + <NeoTabPane tabId="button"> |
| 92 | + {@render content('Button')} |
| 93 | + </NeoTabPane> |
| 94 | + <NeoTabPane tabId="icon"> |
| 95 | + {@render content('Icon')} |
| 96 | + </NeoTabPane> |
| 97 | + <NeoTabPane tabId="reversed"> |
| 98 | + {@render content('Reversed')} |
| 99 | + </NeoTabPane> |
| 100 | + |
| 101 | + {#each added as { text, tabId } (tabId)} |
| 102 | + <NeoTabPane {tabId}> |
| 103 | + {@render content(text)} |
| 104 | + </NeoTabPane> |
| 105 | + {/each} |
| 106 | + </NeoCard> |
90 | 107 | {/snippet} |
91 | 108 |
|
92 | 109 | {#snippet group(props: TabsProps = {})} |
93 | 110 | <div class="column"> |
94 | | - <NeoTabs {panes} {active} {vertical} {skeleton} {onclose} {onadd} {...options} {...props}> |
| 111 | + <NeoTabs {panes} {active} {onclose} {onadd} {...options} {...props}> |
95 | 112 | {@render tabs()} |
96 | 113 | </NeoTabs> |
97 | 114 | </div> |
98 | 115 | {/snippet} |
99 | 116 |
|
100 | 117 | <div class="row"> |
101 | 118 | {#each columns as { label, props }} |
102 | | - <div class="column"> |
| 119 | + <div class="column content"> |
103 | 120 | <span class="label">{label}</span> |
104 | 121 |
|
105 | 122 | {#if props?.glass} |
|
114 | 131 | <style lang="scss"> |
115 | 132 | @use 'src/lib/styles/common/flex' as flex; |
116 | 133 |
|
| 134 | + .content { |
| 135 | + width: min-content; |
| 136 | + } |
| 137 | +
|
117 | 138 | .column { |
118 | | - @include flex.column($center: true, $gap: var(--gap-lg)); |
| 139 | + @include flex.column($center: true, $gap: var(--neo-gap-lg)); |
119 | 140 | } |
120 | 141 |
|
121 | 142 | .row { |
122 | | - @include flex.row($gap: var(--gap-xl)); |
| 143 | + @include flex.row($gap: var(--neo-gap-xl)); |
123 | 144 |
|
124 | 145 | align-items: center; |
125 | 146 | justify-content: center; |
|
0 commit comments