Skip to content

Commit 6ae98b2

Browse files
committed
Overhaul storybook
1 parent 316f24d commit 6ae98b2

22 files changed

Lines changed: 163 additions & 164 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ gitignore
44

55
# tsup
66
tsup.config.bundled_*.{m,c,}s
7+
8+
*storybook.log
9+
storybook-static

.storybook/main.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
import type { StorybookConfig } from 'storybook-solidjs-vite'
2-
import { mergeConfig } from 'vite'
3-
import path from 'path'
42

53
const config: StorybookConfig = {
6-
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
7-
addons: ['@storybook/addon-docs'],
8-
framework: {
9-
name: 'storybook-solidjs-vite',
10-
options: {},
11-
},
12-
async viteFinal(config) {
13-
return mergeConfig(config, {
14-
resolve: {
15-
alias: {
16-
src: path.resolve(__dirname, '../src'),
17-
},
18-
},
19-
})
20-
},
4+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5+
addons: ['@storybook/addon-a11y', '@storybook/addon-docs'],
6+
framework: 'storybook-solidjs-vite',
217
}
228
export default config

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"lint:types": "tsc --noEmit",
5353
"update-deps": "pnpm up -Li",
5454
"storybook": "storybook dev -p 6006",
55-
"build:storybook": "storybook build"
55+
"build-storybook": "storybook build"
5656
},
5757
"peerDependencies": {
5858
"solid-js": "^1.6.0"
@@ -81,7 +81,8 @@
8181
"vite": "^7.3.1",
8282
"vite-plugin-solid": "^2.11.10",
8383
"vite-tsconfig-paths": "^6.0.5",
84-
"vitest": "^4.0.18"
84+
"vitest": "^4.0.18",
85+
"@storybook/addon-a11y": "^10.2.7"
8586
},
8687
"keywords": [
8788
"solid"

pnpm-lock.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/CellContent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const textContentInput = (format: CellFormat) => (props: CellContentProps
9797
value={value()}
9898
onChange={ev => props.setValue(ev.currentTarget.value)}
9999
onKeyDown={handleInputKeyDown}
100-
readOnly={props.readonly}
100+
// readOnly={props.readonly}
101101
onClick={() => (quickMode = false)}
102102
onDblClick={ev => ev.stopPropagation()}
103103
onPaste={ev => ev.stopPropagation()}
@@ -120,13 +120,13 @@ export const checkboxContent = () => (props: CellContentProps) => {
120120
class="solid-tabular/sr-only"
121121
checked={!!props.value}
122122
onChange={ev => props.setValue(ev.target.checked)}
123-
disabled={props.readonly}
123+
// disabled={props.readonly}
124124
/>
125125
<div
126126
class={cn(
127127
'solid-tabular/checkbox-box',
128128
props.value ? 'solid-tabular/checked' : 'solid-tabular/unchecked',
129-
props.readonly ? 'solid-tabular/readonly' : 'solid-tabular/editable',
129+
// props.readonly ? 'solid-tabular/readonly' : 'solid-tabular/editable',
130130
)}
131131
>
132132
{!!props.value && (

src/stories/Table.stories.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { Meta, StoryObj } from 'storybook-solidjs-vite'
2+
import { ActiveRange, Table } from 'src'
3+
import { createSignal } from 'solid-js'
4+
import { fn } from 'storybook/test'
5+
6+
const meta = {
7+
args: {
8+
columns: ['A', 'B', 'C', 'D', 'E'],
9+
numRows: 10,
10+
accentColor: '#de3b84',
11+
setCellValue: fn(),
12+
},
13+
render: props => {
14+
const [activeRange, setActiveRange] = createSignal<ActiveRange>()
15+
const [widths, setWidths] = createSignal(new Map<string, number>())
16+
17+
return (
18+
<div
19+
style={{
20+
height: '100%',
21+
'border-radius': '6px',
22+
overflow: 'hidden',
23+
'--solid-tabular-accent-color': props.accentColor,
24+
}}
25+
>
26+
<Table
27+
{...props}
28+
getCellValue={(row, col) => `${col}${row}`}
29+
activeRange={activeRange()}
30+
setActiveRange={setActiveRange}
31+
getColumnSize={col => widths().get(col)}
32+
setColumnSize={(col, size) => setWidths(w => new Map([...w, [col, size]]))}
33+
resetColumnSize={col => setWidths(w => new Map([...w].filter(e => e[0] !== col)))}
34+
columnsResizeable
35+
getCellEditable={() => true}
36+
/>
37+
</div>
38+
)
39+
},
40+
} satisfies Meta<{
41+
columns: string[]
42+
numRows: number
43+
accentColor: string
44+
setCellValue: (row: number, column: string, value: string) => void
45+
}>
46+
47+
export default meta
48+
49+
type Story = StoryObj<typeof meta>
50+
51+
export const BasicUsage = {
52+
args: {},
53+
} satisfies Story

src/table/AddColumnButton.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
justify-content: center;
1111
border: 1px solid var(--solid-tabular-border-color);
1212
border-top: none;
13-
background-color: var(--solid-tabular-cell-color);
13+
background-color: var(--solid-tabular-header-color);
1414
padding: 0.25rem 0;
1515
box-sizing: border-box;
1616

src/table/AddRowButton.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
margin: -6px 0 6px 0;
44
cursor: pointer;
55
border-top: 1px solid var(--solid-tabular-border-color);
6-
background-color: var(--solid-tabular-cell-color);
6+
background-color: var(--solid-tabular-header-color);
77
z-index: 40;
88
box-sizing: border-box;
99

src/table/Cell.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import './Cell.css'
66

77
export interface CellProps<T> {
88
component: Component<CellContentProps<T>>
9-
readonly: boolean
109
value: T
1110
setValue(value: T): void
1211
onEdit(pos: number): void
@@ -15,7 +14,6 @@ export interface CellProps<T> {
1514
export interface CellInputProps<T> {
1615
component: Component<CellContentProps<T>>
1716
rect: Rect
18-
readonly: boolean
1917
value: T
2018
setValue(value: T): void
2119
onFinishedEditing(): void
@@ -25,7 +23,6 @@ export interface CellInputProps<T> {
2523

2624
export type CellContentProps<T = unknown> = {
2725
value: T
28-
readonly: boolean
2926
editing: boolean
3027
setValue(value: T): void
3128
onEdit(pos: number): void
@@ -46,7 +43,6 @@ export function Cell<T>(props: CellProps<T>) {
4643
<Dynamic
4744
component={props.component}
4845
value={value()}
49-
readonly={props.readonly}
5046
editing={false}
5147
setValue={props.setValue}
5248
onEdit={props.onEdit}
@@ -72,7 +68,6 @@ export function CellInputContainer<T>(props: CellInputProps<T>) {
7268
<Dynamic
7369
component={props.component}
7470
value={props.value}
75-
readonly={props.readonly}
7671
editing={true}
7772
setValue={value => props.setValue(value)}
7873
onEdit={() => {}}

src/table/ColumnHeader.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
top: 0;
44
border-left: 1px solid var(--solid-tabular-border-color);
55
border-bottom: 1px solid var(--solid-tabular-border-color);
6-
background-color: var(--solid-tabular-cell-color);
6+
background-color: var(--solid-tabular-header-color);
77
box-sizing: border-box;
88
cursor: cell;
99

0 commit comments

Comments
 (0)