Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Table style #193

Merged
merged 10 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [3.1.0-rc19] - 2018-11-01
### Changed
- Change default styles [#]() [#150](https://github.com/plotly/dash-table/issues/150)
- prop `content_style` defaults to 'grow' instead of 'fit'
- prop `style_table` width nested property defaults to '100%' if not provided

## [3.1.0-rc18] - 2018-10-31
### Changed
- Rename table component to DataTable [#187](https://github.com/plotly/dash-table/pull/187) [#154](https://github.com/plotly/dash-table/issues/154)
Expand Down Expand Up @@ -130,7 +136,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
dataframe_previous -> data_previous
dataframe_timestamp -> data_timestamp
derived_virtual_dataframe -> derived_virtual_data
derived_viewport_datafram -> derived_viewport_data
derived_viewport_dataframe -> derived_viewport_data

## [3.1.0-rc5]
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion dash_table/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dash_table/demo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_table/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"required": false,
"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.",
"defaultValue": {
"value": "'fit'",
"value": "'grow'",
"computed": false
}
},
Expand Down
1 change: 1 addition & 0 deletions demo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class App extends Component {
merge_duplicate_headers: false,
row_deletable: true,
row_selectable: 'single',
content_style: 'fit',
column_static_dropdown: [
{
id: 'bbb',
Expand Down
2 changes: 1 addition & 1 deletion src/dash-table/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const defaultProps = {
},
navigation: 'page',

content_style: 'fit',
content_style: 'grow',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is now 'grow' -- a lot of tests are updated below to conserve behavior

css: [],
filtering: false,
filtering_settings: '',
Expand Down
8 changes: 7 additions & 1 deletion src/dash-table/components/ControlledTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ interface IState {
forcedResizeOnly: boolean;
}

const DEFAULT_STYLE = {
width: '100%'
};

export default class ControlledTable extends PureComponent<ControlledTableProps, IState> {
private readonly stylesheet: Stylesheet;
private readonly tableFn: () => JSX.Element[][];
Expand Down Expand Up @@ -620,7 +624,9 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
const rawTable = this.tableFn();
const grid = derivedTableFragments(n_fixed_columns, n_fixed_rows, rawTable);

const tableStyle = this.tableStyle(style_table);
const tableStyle = R.mergeAll(
this.tableStyle(DEFAULT_STYLE, style_table)
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table style is now a combination of the prop and some default style


return (<div
id={id}
Expand Down
5 changes: 4 additions & 1 deletion src/dash-table/derived/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,8 @@ export const derivedRelevantHeaderStyles = memoizeOneFactory((
));

export const derivedTableStyle = memoizeOneFactory(
(table: Table) => convertStyle(table || {})
(defaultTable: Table, table: Table) => [
convertStyle(defaultTable),
convertStyle(table)
]
);
1 change: 1 addition & 0 deletions tests/dash/app_sizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ def layout():
"rule": "white-space: normal",
}
],
content_style="fit",
style_data_conditional=[
{ "width": "100px", "min_width": "100px", "max_width": "100px" }
]
Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/Width.all.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const baseProps = {
setProps,
id: 'table',
data,
content_style: 'fit',
style_data_conditional: [
{ width: '20px', min_width: '20px', max_width: '20px' }
]
Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/Width.defaults.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const data = (() => {
const baseProps = {
setProps,
id: 'table',
content_style: 'fit',
data
};

Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/Width.max.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const data = (() => {
const baseProps = {
setProps,
id: 'table',
content_style: 'fit',
data,
style_data_conditional: [{ max_width: 10 }]
};
Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/Width.min.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const data = (() => {
const baseProps = {
setProps,
id: 'table',
content_style: 'fit',
data
};

Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/Width.percentages.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const data = (() => {
const baseProps = {
setProps,
id: 'table',
content_style: 'fit',
data
};

Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/Width.width.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const data = (() => {
const baseProps = {
setProps,
id: 'table',
content_style: 'fit',
data
};

Expand Down
2 changes: 2 additions & 0 deletions tests/visual/percy-storybook/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default [
{
name: 'dropdown with column widths',
props: {
content_style: 'fit',
style_data_conditional: [
{ if: { column_id: 'column-2' }, width: 400 },
{ if: { column_id: 'column-3' }, width: 80 }
Expand Down Expand Up @@ -288,6 +289,7 @@ export default [
name: 'mixed percentage and pixel column widths',
props: {
id: 'table',
content_style: 'fit',
style_data_conditional: [
{ if: { column_id: 'column-2' }, width: 400 },
{ if: { column_id: 'column-3' }, width: '30%' }
Expand Down