Skip to content

Commit ef8bf17

Browse files
committed
tweak header css and add a test
1 parent 514eb54 commit ef8bf17

File tree

2 files changed

+75
-28
lines changed

2 files changed

+75
-28
lines changed

components/dash-table/src/dash-table/components/Table/Table.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@
703703
}
704704
.column-actions {
705705
display: flex;
706-
flex-wrap: wrap;
707706
}
708707

709708
.column-header-name {

components/dash-table/tests/visual/percy-storybook/Header.percy.tsx

Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,78 @@ import DataTable from 'dash-table/dash/DataTable';
55

66
const setProps = () => {};
77

8-
storiesOf('DashTable/Headers', module).add('multi header', () => (
9-
<DataTable
10-
setProps={setProps}
11-
id='multi-header'
12-
data={R.map(
13-
i => ({
14-
year: i,
15-
montreal: i * 10,
16-
toronto: i * 100,
17-
ottawa: i * -1,
18-
vancouver: i * -10,
19-
temp: i * -100,
20-
humidity: i * 0.1
21-
}),
22-
R.range(0, 100)
23-
)}
24-
columns={[
25-
{name: ['Year', ''], id: 'year'},
26-
{name: ['City', 'Montreal'], id: 'montreal'},
27-
{name: ['City', 'Toronto'], id: 'toronto'},
28-
{name: ['City', 'Ottawa'], id: 'ottawa'},
29-
{name: ['City', 'Vancouver'], id: 'vancouver'},
30-
{name: ['Climate', 'Temperature'], id: 'temp'},
31-
{name: ['Climate', 'Humidity'], id: 'humidity'}
32-
]}
33-
/>
34-
));
8+
const data = [
9+
{
10+
a: 'A',
11+
b: 'BBBBB',
12+
c: 'CCCCCCCCCC',
13+
d: 'DDDDDDDDDDDDDDD',
14+
e: 'EEEEEEEEEEEEEEEEEEEE',
15+
f: 'FFFFFFFFFFFFFFFFFFFFFFFFF'
16+
}
17+
];
18+
const cols = ['a', 'b', 'c', 'd', 'e', 'f'].map(i => ({
19+
name: `Column ${i.toUpperCase()}`,
20+
id: i,
21+
selectable: true
22+
}));
23+
const colsEditable = cols.map(col => ({
24+
editable: true,
25+
renamable: true,
26+
deletable: true,
27+
...col
28+
}));
29+
const common = {style_table: {width: 'auto', marginBottom: '10px'}};
30+
const allActions = {
31+
sort_action: 'native',
32+
column_selectable: 'single',
33+
editable: true
34+
};
35+
36+
const alignments: [React.ReactNode?] = [];
37+
38+
[{}, {sort_action: 'native'}, allActions].forEach(actionProps => {
39+
['left', 'center', 'right'].forEach(alignment => {
40+
alignments.push(
41+
<DataTable
42+
data={data}
43+
columns={actionProps === allActions ? colsEditable : cols}
44+
style_header={{textAlign: alignment}}
45+
{...actionProps}
46+
{...common}
47+
/>
48+
);
49+
});
50+
});
51+
52+
storiesOf('DashTable/Headers', module)
53+
.add('multi header', () => (
54+
<DataTable
55+
setProps={setProps}
56+
id='multi-header'
57+
data={R.map(
58+
i => ({
59+
year: i,
60+
montreal: i * 10,
61+
toronto: i * 100,
62+
ottawa: i * -1,
63+
vancouver: i * -10,
64+
temp: i * -100,
65+
humidity: i * 0.1
66+
}),
67+
R.range(0, 100)
68+
)}
69+
columns={[
70+
{name: ['Year', ''], id: 'year'},
71+
{name: ['City', 'Montreal'], id: 'montreal'},
72+
{name: ['City', 'Toronto'], id: 'toronto'},
73+
{name: ['City', 'Ottawa'], id: 'ottawa'},
74+
{name: ['City', 'Vancouver'], id: 'vancouver'},
75+
{name: ['Climate', 'Temperature'], id: 'temp'},
76+
{name: ['Climate', 'Humidity'], id: 'humidity'}
77+
]}
78+
/>
79+
))
80+
.add('alignment and actions', () => (
81+
<div style={{width: '100px'}}>{alignments}</div>
82+
));

0 commit comments

Comments
 (0)