-
-
Notifications
You must be signed in to change notification settings - Fork 73
- fix table border #102
- fix table border #102
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "dash-table", | ||
"version": "3.0.0rc19", | ||
"version": "3.0.0rc20", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bump version |
||
"description": "Dash table", | ||
"main": "build/index.js", | ||
"scripts": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ class App extends Component { | |
} | ||
], | ||
table_style: [ | ||
{ selector: '.dash-spreadsheet.freeze-left', rule: 'width: 1000px' } | ||
{ selector: '.dash-spreadsheet.freeze-left', rule: 'width: 1000px; max-width: 1000px;' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure the tests run against a same-styled table after the default styling update |
||
] | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,35 @@ | |
0px @bottom 0px 0px @color; | ||
} | ||
|
||
.top-left-cells() { | ||
.left-cells(); | ||
.top-cells(); | ||
|
||
tr:first-of-type { | ||
td:first-of-type, | ||
th:first-of-type { | ||
.inset-shadow(var(--border), 1px, 1px, -1px, -1px); | ||
} | ||
} | ||
} | ||
|
||
.top-cells() { | ||
tr:first-of-type { | ||
td, th { | ||
.inset-shadow(var(--border), 0px, 1px, -1px, -1px); | ||
} | ||
} | ||
} | ||
|
||
.left-cells() { | ||
tr { | ||
td:first-of-type, | ||
th:first-of-type { | ||
.inset-shadow(var(--border), 1px, 0px, -1px, -1px); | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depending on whether rows and/or columns are frozen, sub-tables may need to provide extra borders on the outer left and top cells.. these mixins just make it easier to reuse below |
||
|
||
.not-selectable() { | ||
-webkit-touch-callout: none; | ||
-webkit-user-select: none; | ||
|
@@ -24,11 +53,13 @@ | |
|
||
.dash-spreadsheet { | ||
&.freeze-left { | ||
width: 500px; | ||
width: fit-content; | ||
max-width: 500px; | ||
} | ||
|
||
&.freeze-top { | ||
height: 500px; | ||
height: fit-content; | ||
max-height: 500px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default the table will now match its content size up to a given maximum size if frozen |
||
} | ||
} | ||
|
||
|
@@ -40,8 +71,6 @@ | |
|
||
.dash-spreadsheet-inner { | ||
box-sizing: border-box; | ||
border-left: lightgrey 1px solid; | ||
border-top: lightgrey 1px solid; | ||
display: flex; | ||
flex-direction: column; | ||
|
||
|
@@ -105,6 +134,46 @@ | |
z-index: 400; | ||
} | ||
|
||
&:not(.freeze-top):not(.freeze-left) { | ||
.cell-1-1 { | ||
.top-left-cells(); | ||
} | ||
} | ||
|
||
&:not(.freeze-top).freeze-left { | ||
.cell-1-0 { | ||
.top-left-cells(); | ||
} | ||
|
||
.cell-1-1 { | ||
.top-cells(); | ||
} | ||
} | ||
|
||
&.freeze-top:not(.freeze-left) { | ||
.cell-0-1 { | ||
.top-left-cells(); | ||
} | ||
|
||
.cell-1-1 { | ||
.left-cells(); | ||
} | ||
} | ||
|
||
&.freeze-top.freeze-left { | ||
.cell-0-0 { | ||
.top-left-cells(); | ||
} | ||
|
||
.cell-0-1 { | ||
.top-cells(); | ||
} | ||
|
||
.cell-1-0 { | ||
.left-cells(); | ||
} | ||
} | ||
|
||
.cell-0-1 { | ||
z-index: 300; | ||
flex: 0 0 auto; | ||
|
@@ -121,10 +190,6 @@ | |
&:focus { | ||
outline: none; | ||
} | ||
|
||
&.focused + td { | ||
.inset-shadow(var(--border), 0px, 0px, -1px, -1px); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This selector was now useless -- it applied to the standard style as a special case! |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import * as R from 'ramda'; | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import random from 'core/math/random'; | ||
import DashTable from 'dash-table/Table'; | ||
|
||
const setProps = () => { }; | ||
|
||
const columns = ['a', 'b', 'c'] | ||
.map(id => ({ id: id, name: id.toUpperCase(), width: '100px' })); | ||
|
||
const dataframe = (() => { | ||
const r = random(1); | ||
|
||
return R.range(0, 5).map(() => ( | ||
['a', 'b', 'c'].reduce((obj: any, key) => { | ||
obj[key] = Math.floor(r() * 1000); | ||
return obj; | ||
}, {}) | ||
)); | ||
})(); | ||
|
||
const columns2 = ['a', 'b', 'c', 'd', 'e', 'f'] | ||
.map(id => ({ id: id, name: id.toUpperCase(), width: '100px' })); | ||
|
||
const dataframe2 = (() => { | ||
const r = random(1); | ||
|
||
return R.range(0, 50).map(() => ( | ||
['a', 'b', 'c', 'd', 'e', 'f'].reduce((obj: any, key) => { | ||
obj[key] = Math.floor(r() * 1000); | ||
return obj; | ||
}, {}) | ||
)); | ||
})(); | ||
|
||
let props = { | ||
setProps, | ||
id: 'table', | ||
dataframe, | ||
columns, | ||
table_style: [{ | ||
selector: '.dash-spreadsheet', rule: 'width: 500px; height: 500px;' | ||
}] | ||
}; | ||
|
||
let props2 = { | ||
setProps, | ||
id: 'table', | ||
dataframe: dataframe2, | ||
columns: columns2, | ||
table_style: [{ | ||
selector: '.dash-spreadsheet', rule: 'width: 500px; height: 500px;' | ||
}] | ||
}; | ||
|
||
storiesOf('DashTable/Border (available space not filled)', module) | ||
.add('with no frozen rows and no frozen columns', () => (<DashTable | ||
{...props} | ||
/>)) | ||
.add('with frozen rows and no frozen columns', () => (<DashTable | ||
{...props} | ||
n_fixed_rows={1} | ||
/>)) | ||
.add('with no frozen rows and frozen columns', () => (<DashTable | ||
{...props} | ||
n_fixed_columns={1} | ||
/>)) | ||
.add('with frozen rows and frozen columns', () => (<DashTable | ||
{...props} | ||
n_fixed_columns={1} | ||
n_fixed_rows={1} | ||
/>)); | ||
|
||
storiesOf('DashTable/Border (available space filled)', module) | ||
.add('with no frozen rows and no frozen columns', () => (<DashTable | ||
{...props2} | ||
/>)) | ||
.add('with frozen rows and no frozen columns', () => (<DashTable | ||
{...props2} | ||
n_fixed_rows={1} | ||
/>)) | ||
.add('with no frozen rows and frozen columns', () => (<DashTable | ||
{...props2} | ||
n_fixed_columns={1} | ||
/>)) | ||
.add('with frozen rows and frozen columns', () => (<DashTable | ||
{...props2} | ||
n_fixed_columns={1} | ||
n_fixed_rows={1} | ||
/>)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two sets of identical tests for all permutations of frozen/not frozen columns and rows, with a table that fills its allocated space and one that does not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invert max-width / max-height