Skip to content

Commit fee01db

Browse files
committed
fix(json-render-ui): align catalog component styling
1 parent 4fcf5dc commit fee01db

9 files changed

Lines changed: 37 additions & 14 deletions

File tree

packages/json-render-ui/src/JsonRender.stories.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export const Gallery = story({
2525
elements: {
2626
root: { type: 'Stack', props: { gap: 12 }, children: ['title', 'row', 'card', 'progress', 'table', 'tree'] },
2727
title: { type: 'Text', props: { text: 'JSON-render gallery', variant: 'heading' }, children: [] },
28-
row: { type: 'Stack', props: { direction: 'row', gap: 8 }, children: ['b1', 'b2', 'badge'] },
28+
row: { type: 'Stack', props: { direction: 'row', gap: 8, wrap: true }, children: ['b1', 'b2', 'b3', 'b4', 'badge'] },
2929
b1: { type: 'Button', props: { label: 'Primary', variant: 'primary' }, children: [] },
30-
b2: { type: 'Button', props: { label: 'Ghost', variant: 'ghost', icon: 'plus' }, children: [] },
30+
b2: { type: 'Button', props: { label: 'Secondary', variant: 'secondary' }, children: [] },
31+
b3: { type: 'Button', props: { label: 'Ghost', variant: 'ghost', icon: 'ph:plus' }, children: [] },
32+
b4: { type: 'Button', props: { label: 'Danger', variant: 'danger' }, children: [] },
3133
badge: { type: 'Badge', props: { text: 'success', variant: 'success' }, children: [] },
3234
card: { type: 'Card', props: { title: 'Details', collapsible: true }, children: ['kv'] },
3335
kv: { type: 'KeyValueTable', props: { data: { name: 'devframe', version: '0.7.5' } }, children: [] },
@@ -49,6 +51,20 @@ export const Controls = story({
4951
state: { name: '', enabled: true },
5052
})
5153

54+
export const ComponentSurfaces = story({
55+
root: 'root',
56+
elements: {
57+
root: { type: 'Stack', props: { gap: 12 }, children: ['openCard', 'collapsedCard', 'table'] },
58+
openCard: { type: 'Card', props: { title: 'Raised panel', collapsible: true }, children: ['input', 'code', 'inlineCode'] },
59+
input: { type: 'TextInput', props: { label: 'Sunken input', value: 'devframe' }, children: [] },
60+
code: { type: 'CodeBlock', props: { filename: 'panel.ts', language: 'ts', code: 'export const material = "sunken"' }, children: [] },
61+
inlineCode: { type: 'Text', props: { text: 'bg-panel-sunken', variant: 'code' }, children: [] },
62+
collapsedCard: { type: 'Card', props: { title: 'Collapsed panel', collapsible: true, defaultCollapsed: true }, children: ['collapsedText'] },
63+
collapsedText: { type: 'Text', props: { text: 'Hidden until expanded.' }, children: [] },
64+
table: { type: 'DataTable', props: { rows: [{ layer: 'raised', alpha: '13%' }, { layer: 'sunken', alpha: '5%' }] }, children: [] },
65+
},
66+
})
67+
5268
export const Loading: StoryObj = story({ root: 'a', elements: { a: { type: 'Text', props: {}, children: [] } } }, { loading: true })
5369

5470
export const ConnectionError: StoryObj = story(

packages/json-render-ui/src/components/Button.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ export const Button: JrComponent<ButtonProps> = ({ props, on }) => {
2727
ActionButton,
2828
{
2929
variant: buttonVariant[variant] ?? 'action',
30+
size: 'sm',
3031
disabled: props.disabled,
3132
loading: props.loading,
3233
// `danger` isn't an ActionButton variant — override the primary tint.
33-
class: variant === 'danger' ? 'bg-red! color-white! border-red! hover:bg-red/90!' : undefined,
34+
class: [
35+
'h-8 px-2.5!',
36+
variant === 'danger' ? 'bg-red! color-white! border-red! hover:bg-red/90!' : undefined,
37+
],
3438
onClick: () => on('press').emit(),
3539
},
3640
// Render the dynamic Icon in the slot (ActionButton's own `icon` prop is a

packages/json-render-ui/src/components/Card.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ export const Card: JrComponent<CardProps> = ({ props, children, loading }) => {
2121
: (children as any)
2222

2323
if (props.collapsible) {
24-
return h(LayoutCard, { padding: false }, () => h('details', { open: !props.defaultCollapsed }, [
25-
h('summary', { class: `${headerClass} cursor-pointer select-none list-none` }, [
24+
return h(LayoutCard, { padding: false, class: 'bg-panel-raised!' }, () => h('details', { class: 'group', open: !props.defaultCollapsed }, [
25+
h('summary', { class: `${headerClass} cursor-pointer select-none list-none [&::-webkit-details-marker]:hidden` }, [
2626
h('span', props.title ?? ''),
27-
h('span', { class: 'color-faint text-xs' }, '▾'),
27+
h('span', { 'class': 'i-ph:caret-right size-4 shrink-0 color-muted transition-transform group-open:rotate-90', 'aria-hidden': 'true' }),
2828
]),
2929
h('div', { class: 'p4' }, [body]),
3030
]))
3131
}
3232

33-
return h(LayoutCard, { padding: false }, () => [
33+
return h(LayoutCard, { padding: false, class: 'bg-panel-raised!' }, () => [
3434
props.title ? h('div', { class: headerClass }, props.title) : null,
3535
h('div', { class: 'p4' }, [body]),
3636
])

packages/json-render-ui/src/components/CodeBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ interface CodeBlockProps {
1010

1111
export const CodeBlock: JrComponent<CodeBlockProps> = ({ props }) => {
1212
const header = props.filename || props.language
13-
? h('div', { class: 'flex items-center justify-between px2 py1 border-b border-base bg-secondary text-xs color-faint' }, [
13+
? h('div', { class: 'flex items-center justify-between px2 py1 border-b border-base bg-panel-raised text-xs color-faint' }, [
1414
h('span', props.filename ?? ''),
1515
props.language ? h('span', { class: 'font-mono uppercase' }, props.language) : null,
1616
])
1717
: null
1818
const preStyle = props.height != null ? { maxHeight: `${props.height}px` } : undefined
19-
return h('div', { 'class': 'rounded border border-base overflow-hidden bg-base', 'data-language': props.language }, [
19+
return h('div', { 'class': 'rounded border border-base overflow-hidden bg-panel-sunken', 'data-language': props.language }, [
2020
header,
2121
h(
2222
'pre',

packages/json-render-ui/src/components/DataTable.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ export const DataTable: JrComponent<DataTableProps> = ({ props, on, bindings, lo
2929
const [, setSelected] = useBoundProp<unknown>(undefined, bindings?.value)
3030
const wrapperStyle = props.height != null ? { maxHeight: `${props.height}px` } : undefined
3131

32-
return h('div', { class: 'rounded border border-base overflow-auto', style: wrapperStyle }, [
32+
return h('div', { class: 'rounded border border-base overflow-auto bg-panel-sunken', style: wrapperStyle }, [
3333
h('table', { class: 'w-full text-sm border-collapse' }, [
34-
h('thead', { class: 'sticky top-0 bg-secondary' }, [
34+
h('thead', { class: 'sticky top-0 bg-panel-raised' }, [
3535
h('tr', columns.map(col =>
3636
h('th', { class: 'text-left px2 py1.5 color-muted font-medium border-b border-base' }, col.label ?? col.key))),
3737
]),
3838
h('tbody', rows.map((row, index) =>
3939
h('tr', {
40-
class: 'border-b border-base hover:bg-secondary cursor-pointer',
40+
class: 'border-b border-base hover:bg-panel-raised cursor-pointer',
4141
onClick: () => {
4242
// Deliver row + index into bound state, then fire the action.
4343
setSelected({ row, index })

packages/json-render-ui/src/components/Text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const textVariant: Record<string, { tag: string, class: string }> = {
1313
subheading: { tag: 'h3', class: 'text-base font-medium' },
1414
body: { tag: 'p', class: 'text-sm' },
1515
caption: { tag: 'span', class: 'text-xs color-faint' },
16-
code: { tag: 'code', class: 'text-sm font-mono bg-secondary rounded px1 py0.5' },
16+
code: { tag: 'code', class: 'text-sm font-mono bg-panel-sunken rounded px1 py0.5' },
1717
}
1818

1919
const colorClass: Record<string, string> = {

packages/json-render-ui/src/components/TextInput.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const TextInput: JrComponent<TextInputProps> = ({ props, on, bindings })
2424
'placeholder': props.placeholder,
2525
'type': props.type ?? 'text',
2626
'disabled': props.disabled || props.loading,
27+
'class': 'bg-panel-sunken!',
2728
})
2829
if (props.label) {
2930
return h('label', { class: 'flex flex-col gap-1 text-sm color-muted' }, [

packages/json-render-ui/src/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const JsonRenderView = defineComponent({
103103

104104
const staticNote = !props.interactive
105105
? h('div', {
106-
class: 'rounded border border-base bg-secondary color-faint text-xs px2 py1 mb2',
106+
class: 'rounded border border-base bg-panel-raised color-faint text-xs px2 py1 mb2',
107107
}, 'Interactive actions are unavailable in static output.')
108108
: null
109109

packages/json-render-ui/uno.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export default defineConfig({
3737
// shadow-root surface/text tokens.
3838
safelist: [...shadowSurfaceSafelist, 'badge-color-green', 'badge-color-amber', 'badge-color-red', 'badge-color-blue'],
3939
shortcuts: {
40+
'bg-panel-raised': 'bg-hover',
41+
'bg-panel-sunken': 'bg-code',
4042
'z-nav': 'z-[30]',
4143
'z-dropdown': 'z-[40]',
4244
'z-tooltip': 'z-[45]',

0 commit comments

Comments
 (0)