Skip to content

Commit 49f7a9f

Browse files
Table style (#193)
1 parent e89fd9a commit 49f7a9f

20 files changed

+51
-40
lines changed

packages/dash-table/CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [3.1.0-rc19] - 2018-11-01
6+
### Changed
7+
- Change default styles [#193](https://github.com/plotly/dash-table/pull/193) [#150](https://github.com/plotly/dash-table/issues/150)
8+
- prop `content_style` defaults to 'grow' instead of 'fit'
9+
- prop `style_table` width nested property defaults to '100%' if not provided
10+
- update default font-family from 'monospace' to `'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace`
11+
512
## [3.1.0-rc18] - 2018-10-31
613
### Changed
714
- Rename table component to DataTable [#187](https://github.com/plotly/dash-table/pull/187) [#154](https://github.com/plotly/dash-table/issues/154)
@@ -130,7 +137,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
130137
dataframe_previous -> data_previous
131138
dataframe_timestamp -> data_timestamp
132139
derived_virtual_dataframe -> derived_virtual_data
133-
derived_viewport_datafram -> derived_viewport_data
140+
derived_viewport_dataframe -> derived_viewport_data
134141

135142
## [3.1.0-rc5]
136143
### Fixed

packages/dash-table/dash_table/bundle.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dash-table/dash_table/demo.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dash-table/dash_table/metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
"required": false,
164164
"description": "`content_style` toggles between a set of CSS styles for\ntwo common behaviors:\n- `fit`: The table container's width be equal to the width of its content.\n- `grow`: The table container's width will grow to be the size of the container.\n\nNOTE - This property will likely change in the future,\nsubscribe to [https://github.com/plotly/dash-table/issues/176](https://github.com/plotly/dash-table/issues/176)\nfor more details.",
165165
"defaultValue": {
166-
"value": "'fit'",
166+
"value": "'grow'",
167167
"computed": false
168168
}
169169
},

packages/dash-table/dash_table/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.1.0-rc18",
3+
"version": "3.1.0-rc19",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {

packages/dash-table/demo/App.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class App extends Component {
3333
merge_duplicate_headers: false,
3434
row_deletable: true,
3535
row_selectable: 'single',
36+
content_style: 'fit',
3637
column_static_dropdown: [
3738
{
3839
id: 'bbb',

packages/dash-table/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-table",
3-
"version": "3.1.0-rc18",
3+
"version": "3.1.0-rc19",
44
"description": "Dash table",
55
"main": "build/index.js",
66
"scripts": {

packages/dash-table/src/dash-table/DataTable.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33

44
import RealTable from 'dash-table/components/Table';
55

6-
import 'dash-table/style/component.less';
76
import Logger from 'core/Logger';
87

98
import genRandomId from './utils/generate';
@@ -52,7 +51,7 @@ export const defaultProps = {
5251
},
5352
navigation: 'page',
5453

55-
content_style: 'fit',
54+
content_style: 'grow',
5655
css: [],
5756
filtering: false,
5857
filtering_settings: '',

packages/dash-table/src/dash-table/components/ControlledTable/index.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ interface IState {
2828
forcedResizeOnly: boolean;
2929
}
3030

31+
const DEFAULT_STYLE = {
32+
width: '100%'
33+
};
34+
3135
export default class ControlledTable extends PureComponent<ControlledTableProps, IState> {
3236
private readonly stylesheet: Stylesheet;
3337
private readonly tableFn: () => JSX.Element[][];
@@ -620,7 +624,9 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
620624
const rawTable = this.tableFn();
621625
const grid = derivedTableFragments(n_fixed_columns, n_fixed_rows, rawTable);
622626

623-
const tableStyle = this.tableStyle(style_table);
627+
const tableStyle = R.mergeAll(
628+
this.tableStyle(DEFAULT_STYLE, style_table)
629+
);
624630

625631
return (<div
626632
id={id}

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import (reference) '~dash-table/style/reset.less';
2+
13
.inset-shadow(@color, @left, @top, @right, @bottom) {
24
box-shadow: inset @left 0px 0px 0px @color,
35
inset 0px @top 0px 0px @color,
@@ -167,12 +169,11 @@
167169
}
168170

169171
.dash-spreadsheet-container {
172+
.reset-css();
170173
display: flex;
171174
flex-direction: row;
172175
position: relative;
173-
}
174176

175-
.dash-spreadsheet-container {
176177
.dash-spreadsheet-inner {
177178
box-sizing: border-box;
178179
display: flex;
@@ -383,7 +384,7 @@
383384
.dash-spreadsheet-inner table {
384385
border-collapse: collapse;
385386

386-
font-family: monospace;
387+
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
387388
--accent: hotpink;
388389
--border: lightgrey;
389390
--text-color: rgb(60, 60, 60);
@@ -493,10 +494,6 @@
493494
outline: none;
494495
}
495496

496-
.numeric {
497-
font-family: monospace;
498-
}
499-
500497
.toggle-row {
501498
border: none;
502499
box-shadow: none;

packages/dash-table/src/dash-table/derived/style/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ export const derivedRelevantHeaderStyles = memoizeOneFactory((
111111
));
112112

113113
export const derivedTableStyle = memoizeOneFactory(
114-
(table: Table) => convertStyle(table || {})
114+
(defaultTable: Table, table: Table) => [
115+
convertStyle(defaultTable),
116+
convertStyle(table)
117+
]
115118
);

packages/dash-table/src/dash-table/style/component.less

-16
This file was deleted.

packages/dash-table/tests/dash/app_sizing.py

+1
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ def layout():
406406
"rule": "white-space: normal",
407407
}
408408
],
409+
content_style="fit",
409410
style_data_conditional=[
410411
{ "width": "100px", "min_width": "100px", "max_width": "100px" }
411412
]

packages/dash-table/tests/visual/percy-storybook/Width.all.percy.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const baseProps = {
2323
setProps,
2424
id: 'table',
2525
data,
26+
content_style: 'fit',
2627
style_data_conditional: [
2728
{ width: '20px', min_width: '20px', max_width: '20px' }
2829
]

packages/dash-table/tests/visual/percy-storybook/Width.defaults.percy.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const data = (() => {
2222
const baseProps = {
2323
setProps,
2424
id: 'table',
25+
content_style: 'fit',
2526
data
2627
};
2728

packages/dash-table/tests/visual/percy-storybook/Width.max.percy.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const data = (() => {
2222
const baseProps = {
2323
setProps,
2424
id: 'table',
25+
content_style: 'fit',
2526
data,
2627
style_data_conditional: [{ max_width: 10 }]
2728
};

packages/dash-table/tests/visual/percy-storybook/Width.min.percy.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const data = (() => {
2222
const baseProps = {
2323
setProps,
2424
id: 'table',
25+
content_style: 'fit',
2526
data
2627
};
2728

packages/dash-table/tests/visual/percy-storybook/Width.percentages.percy.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,22 @@ const data = (() => {
2121
const baseProps = {
2222
setProps,
2323
id: 'table',
24+
content_style: 'grow',
2425
data
2526
};
2627

2728
const props = Object.assign({}, baseProps, {
2829
content_style: 'grow',
29-
columns: columns.map((id => ({ id: id, name: id.toUpperCase(), width: '33%' }))),
30+
columns: columns.map((id => ({ id: id, name: id.toUpperCase() }))),
31+
style_cell: {
32+
width: '33%'
33+
},
34+
style_table: {
35+
width: '100%',
36+
min_width: '100%',
37+
max_width: '100%'
38+
},
3039
css: [{
31-
selector: '.dash-spreadsheet',
32-
rule: 'width: 1000px; max-width: 1000px; height: 1000px;'
33-
}, {
3440
selector: '.dash-fixed-column',
3541
rule: 'width: 33%;'
3642
}]

packages/dash-table/tests/visual/percy-storybook/Width.width.percy.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const data = (() => {
2222
const baseProps = {
2323
setProps,
2424
id: 'table',
25+
content_style: 'fit',
2526
data
2627
};
2728

packages/dash-table/tests/visual/percy-storybook/fixtures.ts

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export default [
159159
{
160160
name: 'dropdown with column widths',
161161
props: {
162+
content_style: 'fit',
162163
style_data_conditional: [
163164
{ if: { column_id: 'column-2' }, width: 400 },
164165
{ if: { column_id: 'column-3' }, width: 80 }
@@ -288,6 +289,7 @@ export default [
288289
name: 'mixed percentage and pixel column widths',
289290
props: {
290291
id: 'table',
292+
content_style: 'fit',
291293
style_data_conditional: [
292294
{ if: { column_id: 'column-2' }, width: 400 },
293295
{ if: { column_id: 'column-3' }, width: '30%' }

0 commit comments

Comments
 (0)