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

Commit 5571f7a

Browse files
Issue 489 - content_style regression (#501)
1 parent dcd9016 commit 5571f7a

File tree

13 files changed

+39
-1
lines changed

13 files changed

+39
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
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+
## [Unreleased]
6+
### Fixed
7+
[#489](https://github.com/plotly/dash-table/issues/489)
8+
- Add `fill_width` prop to replace `content_style` prop removed in the [4.0 API rework](https://github.com/plotly/dash-table/pull/446)
9+
510
## [4.0.1] - 2019-07-09
611
### Changed
712
[#488](https://github.com/plotly/dash-table/pull/488)

demo/AppMode.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function getDefaultState(
8989
data: mock.data,
9090
editable: true,
9191
sort_action: TableAction.Native,
92+
fill_width: false,
9293
fixed_rows: { headers: true },
9394
fixed_columns: { headers: true },
9495
merge_duplicate_headers: false,
@@ -229,6 +230,7 @@ function getVirtualizedState() {
229230
tableProps: R.merge(getBaseTableProps(mock), {
230231
data: mock.data,
231232
editable: true,
233+
fill_width: false,
232234
sort_action: TableAction.Native,
233235
merge_duplicate_headers: false,
234236
row_deletable: true,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
684684
tooltip_conditional,
685685
tooltip,
686686
currentTooltip,
687+
fill_width,
687688
filter_action,
688689
fixed_columns,
689690
fixed_rows,
@@ -730,7 +731,8 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
730731
...(empty[1][1] ? ['dash-empty-11'] : []),
731732
...(columns.length ? [] : ['dash-no-columns']),
732733
...(virtualized.data.length ? [] : ['dash-no-data']),
733-
...(filter_action !== TableAction.None ? [] : ['dash-no-filter'])
734+
...(filter_action !== TableAction.None ? [] : ['dash-no-filter']),
735+
...(fill_width ? ['dash-fill-width'] : [])
734736
];
735737

736738
const containerClasses = ['dash-spreadsheet-container', ...classes];

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@
233233
}
234234
}
235235

236+
&.dash-fill-width {
237+
.cell-0-1,
238+
.cell-1-1 {
239+
flex: 1 0 auto;
240+
}
241+
242+
table {
243+
width: 100%;
244+
}
245+
}
246+
236247
tr {
237248
background-color: white;
238249
}

src/dash-table/components/Table/props.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ export interface IProps {
271271
css?: IStylesheetRule[];
272272
data?: Data;
273273
editable?: boolean;
274+
fill_width?: boolean;
274275
filter_query?: string;
275276
filter_action?: TableAction;
276277
locale_format: INumberLocale;
@@ -314,6 +315,7 @@ interface IDefaultProps {
314315
css: IStylesheetRule[];
315316
data: Data;
316317
editable: boolean;
318+
fill_width: boolean;
317319
filter_query: string;
318320
filter_action: TableAction;
319321
merge_duplicate_headers: boolean;

src/dash-table/dash/DataTable.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const defaultProps = {
6868
dropdown_conditional: [],
6969
dropdown_data: [],
7070

71+
fill_width: true,
7172
fixed_columns: {
7273
headers: false,
7374
data: 0
@@ -415,6 +416,13 @@ export const propTypes = {
415416
column_id: PropTypes.string
416417
}),
417418

419+
/**
420+
* `fill_width` toggles between a set of CSS for two common behaviors:
421+
* - True: The table container's width will grow to fill the available space
422+
* - False: The table container's width will equal the width of its content
423+
*/
424+
fill_width: PropTypes.bool,
425+
418426
/**
419427
* The ID of the table.
420428
*/

tests/visual/percy-storybook/Width.all.percy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const baseProps = {
2323
setProps,
2424
id: 'table',
2525
data,
26+
fill_width: false,
2627
style_data_conditional: [
2728
{ width: '20px', min_width: '20px', max_width: '20px' }
2829
]

tests/visual/percy-storybook/Width.defaults.percy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const data = (() => {
2121

2222
const baseProps = {
2323
setProps,
24+
fill_width: false,
2425
id: 'table',
2526
data
2627
};

tests/visual/percy-storybook/Width.empty.percy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const data = (() => {
2323

2424
const baseProps = {
2525
setProps,
26+
fill_width: false,
2627
id: 'table',
2728
data,
2829
filter_action: TableAction.Native,

tests/visual/percy-storybook/Width.max.percy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const data = (() => {
2121

2222
const baseProps = {
2323
setProps,
24+
fill_width: false,
2425
id: 'table',
2526
data,
2627
style_data_conditional: [{ max_width: 10 }]

tests/visual/percy-storybook/Width.min.percy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const data = (() => {
2121

2222
const baseProps = {
2323
setProps,
24+
fill_width: false,
2425
id: 'table',
2526
data
2627
};

tests/visual/percy-storybook/Width.width.percy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const data = (() => {
2121

2222
const baseProps = {
2323
setProps,
24+
fill_width: false,
2425
id: 'table',
2526
data
2627
};

tests/visual/percy-storybook/fixtures.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export default [
159159
{
160160
name: 'dropdown with column widths',
161161
props: {
162+
fill_width: false,
162163
style_data_conditional: [
163164
{ if: { column_id: 'column-2' }, width: 400 },
164165
{ if: { column_id: 'column-3' }, width: 80 }
@@ -280,6 +281,7 @@ export default [
280281
name: 'mixed percentage and pixel column widths',
281282
props: {
282283
id: 'table',
284+
fill_width: false,
283285
style_data_conditional: [
284286
{ if: { column_id: 'column-2' }, width: 400 },
285287
{ if: { column_id: 'column-3' }, width: '30%' }

0 commit comments

Comments
 (0)