Skip to content

Commit eb0bbb0

Browse files
committed
fix(baseline): make the theme more datagrid like
1 parent 5ba860a commit eb0bbb0

File tree

10 files changed

+53
-41
lines changed

10 files changed

+53
-41
lines changed

.storybook/preview.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ export const parameters = {
4242
['Installation', 'FAQ'],
4343
'First Steps',
4444
['Compact Table', 'Composed Table'],
45-
'Types',
46-
['Data', 'Compact Table', 'Composed Table', ...Features, 'Virtualized'],
4745
'Compact Table',
4846
['Base', ...Features],
4947
'Theming',
@@ -57,12 +55,12 @@ export const parameters = {
5755
'Bootstrap (WIP)',
5856
'Ant Design (WIP)',
5957
],
60-
'Product Themes',
61-
['Google Drive (WIP)', 'Stripe (WIP)'],
6258
'Features',
6359
Features,
6460
'Composites',
6561
['Sort & Select', 'Tree & Select', 'Tree & Sort'],
62+
'Types',
63+
['Data', 'Compact Table', 'Composed Table', ...Features, 'Virtualized'],
6664
'CRUD',
6765
['Create', 'Update', 'Delete'],
6866
'Misc',

.storybook/stories/FirstSteps/compact-table.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as React from 'react';
22

33
import { CompactTable } from '@table-library/react-table-library/compact';
4+
import { useTheme } from '@table-library/react-table-library/theme';
5+
import { getTheme } from '@table-library/react-table-library/baseline';
46

57
import { nodes } from '../data';
68

@@ -9,6 +11,8 @@ const key = 'Compact Table';
911
const Component = () => {
1012
const data = { nodes };
1113

14+
const theme = useTheme(getTheme());
15+
1216
const COLUMNS = [
1317
{ label: 'Task', renderCell: (item) => item.name },
1418
{
@@ -28,21 +32,25 @@ const Component = () => {
2832
{ label: 'Tasks', renderCell: (item) => item.nodes?.length },
2933
];
3034

31-
return <CompactTable columns={COLUMNS} data={data} layout={{ isDiv: true }} />;
35+
return <CompactTable columns={COLUMNS} data={data} theme={theme} />;
3236
};
3337

3438
const code = `
3539
import * as React from 'react';
3640
3741
import { CompactTable } from '@table-library/react-table-library/compact';
42+
import { useTheme } from '@table-library/react-table-library/theme';
43+
import { getTheme } from '@table-library/react-table-library/baseline';
3844
3945
import { nodes } from '../data';
4046
41-
const key = 'CompactTable';
47+
const key = 'Compact Table';
4248
4349
const Component = () => {
4450
const data = { nodes };
4551
52+
const theme = useTheme(getTheme());
53+
4654
const COLUMNS = [
4755
{ label: 'Task', renderCell: (item) => item.name },
4856
{
@@ -62,7 +70,7 @@ const Component = () => {
6270
{ label: 'Tasks', renderCell: (item) => item.nodes?.length },
6371
];
6472
65-
return <CompactTable columns={COLUMNS} data={data} />;
73+
return <CompactTable columns={COLUMNS} data={data} theme={theme} />;
6674
};
6775
`;
6876

.storybook/stories/FirstSteps/composed-table.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
HeaderCell,
1010
Cell,
1111
} from '@table-library/react-table-library/table';
12+
import { useTheme } from '@table-library/react-table-library/theme';
13+
import { getTheme } from '@table-library/react-table-library/baseline';
1214

1315
import { nodes } from '../data';
1416

@@ -17,8 +19,10 @@ const key = 'Composed Table';
1719
const Component = () => {
1820
const data = { nodes };
1921

22+
const theme = useTheme(getTheme());
23+
2024
return (
21-
<Table data={data}>
25+
<Table data={data} theme={theme}>
2226
{(tableList) => (
2327
<>
2428
<Header>
@@ -66,6 +70,8 @@ import {
6670
HeaderCell,
6771
Cell,
6872
} from '@table-library/react-table-library/table';
73+
import { useTheme } from '@table-library/react-table-library/theme';
74+
import { getTheme } from '@table-library/react-table-library/baseline';
6975
7076
import { nodes } from '../data';
7177
@@ -74,8 +80,10 @@ const key = 'Composed Table';
7480
const Component = () => {
7581
const data = { nodes };
7682
83+
const theme = useTheme(getTheme());
84+
7785
return (
78-
<Table data={data}>
86+
<Table data={data} theme={theme}>
7987
{(tableList) => (
8088
<>
8189
<Header>

.storybook/stories/Themes/Products/google-drive.story.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

.storybook/stories/Themes/Products/stripe.story.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

.storybook/stories/Theming/class.story.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If you want to give a component a specific CSS class, do it this way:
1010
<Row className="foo" ... >
1111
```
1212

13-
Then if you want to style all Row components with this CSS class, specify it in the `THEME` that is passed to `const = useTheme(THEME)`:
13+
Then if you want to style all Row components with this CSS class, specify it in the `THEME` that is passed to `const = useTheme(THEME);` (see Features/Theme):
1414

1515
```
1616
const THEME = {

.storybook/stories/Theming/taliwind.story.mdx renamed to .storybook/stories/Theming/tailwind.story.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import { Meta } from '@storybook/addon-docs';
44

55
# Utility First/Atomic CSS (e.g. Tailwind CSS)
66

7-
See: https://github.com/table-library/react-table-library/discussions/40
7+
See Theming/Imperative Style and https://github.com/table-library/react-table-library/discussions/40

.storybook/stories/Theming/themes.story.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Meta } from '@storybook/addon-docs';
44

55
# Themes
66

7-
This is a opt-in theme. You can use this theme as **baseline theme** (see next code snippet), use a **third-party theme** (see Library Themes), create your **custom theme** (see Features/Theme), or **stitch themes** (see Featues/Theme/stitch themes) by merging baseline theme, custom theme, and/or library theme.
7+
Theming is opt-in. You can use the following theme as **baseline theme** (see next code snippet), use a **third-party theme** (see Library Themes), create your **custom theme** (see Features/Theme), or **stitch themes** (see Featues/Theme/stitch themes) by merging baseline theme, custom theme, and/or library theme.
88

99
```javascript
1010
// compact table
@@ -50,7 +50,7 @@ const BASELINE_THEME = {
5050
Header: '',
5151
Body: '',
5252
BaseRow: `
53-
font-size: 18px;
53+
font-size: 16px;
5454
`,
5555
HeaderRow: `
5656
color: ${COLORS.FONT_PRIMARY};
@@ -65,22 +65,29 @@ const BASELINE_THEME = {
6565
&:hover {
6666
color: ${COLORS.FONT_PRIMARY};
6767
}
68+
69+
&:not(:last-of-type) > .td {
70+
border-bottom: 1px solid ${COLORS.BORDER};
71+
}
6872
`,
6973
BaseCell: `
7074
padding: 6px 12px;
71-
72-
&:not(:last-of-type) {
73-
border-right: 1px solid ${COLORS.BORDER};
74-
}
7575
`,
7676
HeaderCell: `
77+
font-weight: bold;
7778
border-bottom: 1px solid ${COLORS.BORDER};
7879
7980
svg,
8081
path {
8182
fill: currentColor;
8283
}
8384
`,
84-
Cell: '',
85+
Cell: `
86+
&:focus {
87+
outline: dotted;
88+
outline-width: 1px;
89+
outline-offset: -1px;
90+
}
91+
`,
8592
};
8693
```

src/baseline/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const BASELINE_THEME = {
88
Header: '',
99
Body: '',
1010
BaseRow: `
11-
font-size: 18px;
11+
font-size: 16px;
1212
`,
1313
HeaderRow: `
1414
color: ${COLORS.FONT_PRIMARY};
@@ -23,23 +23,30 @@ const BASELINE_THEME = {
2323
&:hover {
2424
color: ${COLORS.FONT_PRIMARY};
2525
}
26+
27+
&:not(:last-of-type) > .td {
28+
border-bottom: 1px solid ${COLORS.BORDER};
29+
}
2630
`,
2731
BaseCell: `
2832
padding: 6px 12px;
29-
30-
&:not(:last-of-type) {
31-
border-right: 1px solid ${COLORS.BORDER};
32-
}
3333
`,
3434
HeaderCell: `
35+
font-weight: bold;
3536
border-bottom: 1px solid ${COLORS.BORDER};
3637
3738
svg,
3839
path {
3940
fill: currentColor;
4041
}
4142
`,
42-
Cell: '',
43+
Cell: `
44+
&:focus {
45+
outline: dotted;
46+
outline-width: 1px;
47+
outline-offset: -1px;
48+
}
49+
`,
4350
};
4451

4552
export const getTheme = (): Theme => {

src/common/colors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export const FONT_SECONDARY = '#757575';
33
export const FONT_DISABLED = '#9e9e9e';
44
export const BACKGROUND = '#ffffff';
55
export const ROW_SELECTED = '#e0e0e0';
6-
export const BORDER = '#a0a8ae';
6+
export const BORDER = '#dde2eb';

0 commit comments

Comments
 (0)