11import {
2- Accessor ,
32 For ,
43 Match ,
54 type ParentProps ,
6- Show ,
75 Switch ,
86 children ,
97 createMemo ,
10- createSignal ,
118 splitProps ,
129} from "solid-js" ;
1310import { isServer } from "solid-js/web" ;
@@ -16,7 +13,6 @@ import { A } from "~/ui/i18n-anchor";
1613import { clientOnly } from "@solidjs/start" ;
1714import { Callout } from "~/ui/callout" ;
1815import { Tabs , TabList , TabPanel , Tab } from "~/ui/tabs" ;
19- import { makePersisted , messageSync } from "@solid-primitives/storage" ;
2016
2117export { EditPageLink } from "../ui/edit-page-link" ;
2218export { PageIssueLink } from "../ui/page-issue-link" ;
@@ -37,43 +33,8 @@ export const DirectiveContainer = (
3733 } & ParentProps
3834) => {
3935 const _children = children ( ( ) => props . children ) . toArray ( ) ;
40-
4136 const tabNames = createMemo ( ( ) => props . tabNames ?. split ( "\0" ) ?? [ ] ) ;
4237
43- const tabs = ( value ?: Accessor < string > , onChange ?: ( s : string ) => void ) => (
44- < Tabs value = { value ?.( ) } onChange = { onChange } >
45- < TabList >
46- < For each = { tabNames ( ) } >
47- { ( title ) => (
48- < Tab
49- value = { title }
50- class = "px-5 py-1 relative top-0.5 transition-colors duration-300 aria-selected:font-bold aria-selected:dark:text-slate-300 aria-selected:text-blue-500 aria-selected:border-b-2 aria-selected:border-blue-400"
51- >
52- { title }
53- </ Tab >
54- ) }
55- </ For >
56- </ TabList >
57- < For each = { tabNames ( ) } >
58- { ( title , idx ) => (
59- < TabPanel value = { title } forceMount = { true } >
60- { _children [ idx ( ) ] }
61- </ TabPanel >
62- ) }
63- </ For >
64- </ Tabs >
65- ) ;
66-
67- const tabsWithPersistence = ( ) => {
68- // eslint-disable-next-line solid/reactivity
69- const [ openTab , setOpenTab ] = makePersisted ( createSignal ( tabNames ( ) [ 0 ] ) , {
70- name : `tab-group:${ props . title } ` ,
71- sync : messageSync ( new BroadcastChannel ( "tab-group" ) ) ,
72- } ) ;
73-
74- return tabs ( openTab , setOpenTab ) ;
75- } ;
76-
7738 return (
7839 < Switch
7940 fallback = {
@@ -82,9 +43,20 @@ export const DirectiveContainer = (
8243 >
8344 < Match when = { props . type === "tab" } > { _children } </ Match >
8445 < Match when = { props . type === "tab-group" } >
85- < Show when = { props . title } fallback = { tabs ( ) } >
86- { tabsWithPersistence ( ) }
87- </ Show >
46+ < Tabs >
47+ < TabList >
48+ < For each = { tabNames ( ) } >
49+ { ( title ) => < Tab value = { title } > { title } </ Tab > }
50+ </ For >
51+ </ TabList >
52+ < For each = { tabNames ( ) } >
53+ { ( title , idx ) => (
54+ < TabPanel value = { title } forceMount = { true } >
55+ { _children [ idx ( ) ] }
56+ </ TabPanel >
57+ ) }
58+ </ For >
59+ </ Tabs >
8860 </ Match >
8961 </ Switch >
9062 ) ;
0 commit comments