From 3c3ad712968bdd772b6ba81b60e5554f055c3179 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 28 Dec 2025 12:45:51 -0800 Subject: [PATCH] hooo boy --- examples/navigation.tsx | 210 ++++++++++++++++++++-------------------- src/index.tsx | 58 ++++++++++- src/types.ts | 3 + 3 files changed, 161 insertions(+), 110 deletions(-) diff --git a/examples/navigation.tsx b/examples/navigation.tsx index 1232ff8..2b9aac8 100644 --- a/examples/navigation.tsx +++ b/examples/navigation.tsx @@ -4,8 +4,8 @@ import { ExampleSection } from './ssr/helpers' const TabSwitcher = define('TabSwitcher', { parts: { Input: { - base: 'input', - display: 'none', // Hide radio inputs + base: 'input[type=radio]', + display: 'none', }, TabBar: { display: 'flex', @@ -31,6 +31,13 @@ const TabSwitcher = define('TabSwitcher', { ':hover': { color: '#111827', } + }, + + selectors: { + '.TabSwitcher_Input:checked + &': { + color: '#3b82f6', + borderBottom: '2px solid #3b82f6' + } } }, Content: { @@ -38,52 +45,39 @@ const TabSwitcher = define('TabSwitcher', { padding: 20, background: '#f9fafb', borderRadius: 8, + + selectors: { + '.TabSwitcher_Input:checked ~ &': { + display: 'block' + } + } } }, render({ props, parts: { Root, Input, TabBar, TabLabel, Content } }) { return ( - {/* Hidden radio inputs */} - {props.tabs?.map((tab: any, index: number) => ( - - ))} - - {/* Tab labels */} - {props.tabs?.map((tab: any) => ( - - {tab.label} - + {props.tabs?.map((tab: any, index: number) => ( + <> + + + {tab.label} + + ))} - {/* Tab content panels */} {props.tabs?.map((tab: any) => ( - + {tab.content} ))} - - {/* CSS to show active tab and content */} -