import { define } from '../src'
import { ExampleSection, theme } from './ssr/helpers'
const TabSwitcher = define('TabSwitcher', {
parts: {
Input: {
base: 'input[type=radio]',
display: 'none',
},
TabBar: {
display: 'flex',
gap: 0,
borderBottom: `1px solid ${theme.colors.border}`,
marginBottom: theme.spacing.lg,
},
TabLabel: {
base: 'label',
padding: `${theme.spacing.sm}px ${theme.spacing.lg}px`,
position: 'relative',
marginBottom: -1,
background: 'transparent',
borderBottom: '1px solid transparent',
color: theme.colors.fgMuted,
fontSize: 14,
cursor: 'pointer',
transition: 'all 0.2s ease',
states: {
':hover': {
color: theme.colors.fg,
}
},
selectors: {
'@Input:checked + &': {
color: theme.colors.accent,
borderBottom: `1px solid ${theme.colors.accent}`
}
}
},
Content: {
display: 'none',
padding: theme.spacing.lg,
background: theme.colors.bgElevated,
border: `1px solid ${theme.colors.border}`,
borderRadius: theme.radius.sm,
selectors: {
'@Input:checked ~ &': {
display: 'block'
}
}
}
},
render({ props, parts: { Root, Input, TabBar, TabLabel, Content } }) {
return (
{props.tabs?.map((tab: any, index: number) => (
<>
{tab.label}
>
))}
{props.tabs?.map((tab: any) => (
{tab.content}
))}
)
}
})
const Pills = define('Pills', {
parts: {
Input: {
base: 'input[type=radio]',
display: 'none',
},
PillBar: {
display: 'flex',
gap: theme.spacing.xs,
flexWrap: 'wrap',
},
PillLabel: {
base: 'label',
padding: `${theme.spacing.xs}px ${theme.spacing.md}px`,
background: theme.colors.bgElevated,
border: `1px solid ${theme.colors.border}`,
borderRadius: 20,
color: theme.colors.fgMuted,
fontSize: 14,
cursor: 'pointer',
transition: 'all 0.2s ease',
states: {
':hover': {
borderColor: theme.colors.borderActive,
color: theme.colors.fg,
}
},
selectors: {
'@Input:checked + &': {
background: theme.colors.accent,
borderColor: theme.colors.accent,
color: theme.colors.bg
},
'@Input:checked + &:hover': {
background: theme.colors.accentDim,
borderColor: theme.colors.accentDim,
}
}
}
},
render({ props, parts: { Root, Input, PillBar, PillLabel } }) {
return (
{props.items?.map((item: any, index: number) => (
<>
{item.label}
>
))}
)
}
})
const VerticalNav = define('VerticalNav', {
parts: {
Input: {
base: 'input[type=radio]',
display: 'none',
},
NavBar: {
display: 'flex',
flexDirection: 'column',
gap: 4,
width: 240,
},
NavLabel: {
base: 'label',
padding: `${theme.spacing.sm}px ${theme.spacing.md}px`,
display: 'flex',
alignItems: 'center',
gap: theme.spacing.sm,
background: 'transparent',
border: `1px solid transparent`,
borderRadius: theme.radius.sm,
color: theme.colors.fgMuted,
fontSize: 14,
cursor: 'pointer',
transition: 'all 0.2s ease',
states: {
':hover': {
background: theme.colors.bgElevated,
borderColor: theme.colors.border,
color: theme.colors.fg,
}
},
selectors: {
'@Input:checked + &': {
background: theme.colors.bgElevated,
borderColor: theme.colors.accent,
color: theme.colors.accent,
},
'@Input:checked + &:hover': {
borderColor: theme.colors.accentDim,
color: theme.colors.accentDim
}
}
},
Icon: {
width: 20,
height: 20,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: 16,
}
},
render({ props, parts: { Root, Input, NavBar, NavLabel, Icon } }) {
return (
{props.items?.map((item: any, index: number) => (
<>
{item.icon && {item.icon}}
{item.label}
>
))}
)
}
})
const Breadcrumbs = define('Breadcrumbs', {
display: 'flex',
alignItems: 'center',
gap: theme.spacing.xs,
flexWrap: 'wrap',
parts: {
Item: {
base: 'a',
color: theme.colors.fgMuted,
fontSize: 14,
textDecoration: 'none',
transition: 'color 0.2s ease',
states: {
':hover': {
color: theme.colors.accent,
}
}
},
Separator: {
color: theme.colors.fgDim,
fontSize: 14,
userSelect: 'none',
},
Current: {
color: theme.colors.fg,
fontSize: 14,
}
},
render({ props, parts: { Root, Item, Separator, Current } }) {
return (
{props.items?.map((item: any, index: number) => (
<>
{index === props.items.length - 1 ? (
{item.label}
) : (
<>
-
{item.label}
/
>
)}
>
))}
)
}
})
const Tabs = define('Tabs', {
display: 'flex',
gap: 0,
borderBottom: `1px solid ${theme.colors.border}`,
parts: {
Tab: {
base: 'button',
padding: `${theme.spacing.sm}px ${theme.spacing.lg}px`,
position: 'relative',
marginBottom: -1,
background: 'transparent',
border: 'none',
borderBottom: '1px solid transparent',
color: theme.colors.fgMuted,
fontSize: 14,
cursor: 'pointer',
transition: 'all 0.2s ease',
states: {
':hover': {
color: theme.colors.fg,
}
}
}
},
variants: {
active: {
parts: {
Tab: {
color: theme.colors.accent,
borderBottom: `1px solid ${theme.colors.accent}`,
}
}
}
},
render({ props, parts: { Root, Tab } }) {
return (
{props.items?.map((item: any) => (
{item.label}
))}
)
}
})
const SimplePills = define('SimplePills', {
display: 'flex',
gap: theme.spacing.xs,
flexWrap: 'wrap',
parts: {
Pill: {
base: 'button',
padding: `${theme.spacing.xs}px ${theme.spacing.md}px`,
background: theme.colors.bgElevated,
border: `1px solid ${theme.colors.border}`,
borderRadius: 20,
color: theme.colors.fgMuted,
fontSize: 14,
cursor: 'pointer',
transition: 'all 0.2s ease',
states: {
':hover': {
borderColor: theme.colors.borderActive,
color: theme.colors.fg,
}
}
}
},
variants: {
active: {
parts: {
Pill: {
background: theme.colors.accent,
borderColor: theme.colors.accent,
color: theme.colors.bg,
states: {
':hover': {
background: theme.colors.accentDim,
borderColor: theme.colors.accentDim,
}
}
}
}
}
},
render({ props, parts: { Root, Pill } }) {
return (
{props.items?.map((item: any) => (
{item.label}
))}
)
}
})
const SimpleVerticalNav = define('SimpleVerticalNav', {
display: 'flex',
flexDirection: 'column',
gap: 4,
width: 240,
parts: {
NavItem: {
base: 'button',
padding: `${theme.spacing.sm}px ${theme.spacing.md}px`,
display: 'flex',
alignItems: 'center',
gap: theme.spacing.sm,
background: 'transparent',
border: `1px solid transparent`,
borderRadius: theme.radius.sm,
color: theme.colors.fgMuted,
fontSize: 14,
textAlign: 'left',
cursor: 'pointer',
transition: 'all 0.2s ease',
states: {
':hover': {
background: theme.colors.bgElevated,
borderColor: theme.colors.border,
color: theme.colors.fg,
}
}
},
Icon: {
width: 20,
height: 20,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
fontSize: 16,
}
},
variants: {
active: {
parts: {
NavItem: {
background: theme.colors.bgElevated,
borderColor: theme.colors.accent,
color: theme.colors.accent,
states: {
':hover': {
borderColor: theme.colors.accentDim,
color: theme.colors.accentDim,
}
}
}
}
}
},
render({ props, parts: { Root, NavItem, Icon } }) {
return (
{props.items?.map((item: any) => (
{item.icon && {item.icon}}
{item.label}
))}
)
}
})
export const NavigationExamplesContent = () => (
<>
Overview content
},
{ id: 'analytics', label: 'Analytics', content: Analytics content
},
{ id: 'reports', label: 'Reports', content: Reports content
},
{ id: 'settings', label: 'Settings', content: Settings content
},
]}
/>
>
)