Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
[#434](https://github.com/plotly/dash-table/issues/434)
- Fix CSS borders propeties overwrite style_* borders properties.

[#435](https://github.com/plotly/dash-table/issues/434)
- selected_cells background color is set through styling pipeline / derivations.

## [3.7.0] - 2019-05-15
### Added
[#397](https://github.com/plotly/dash-table/pull/397), [#410](https://github.com/plotly/dash-table/pull/410)
Expand Down
3 changes: 0 additions & 3 deletions generator/cssPropertiesGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,6 @@ snakes.forEach(([snake, camel]) => map.set(snake, camel));
kebabs.forEach(([kebab, camel]) => map.set(kebab, camel));
camels.forEach(([camel]) => map.set(camel, camel));

map.forEach((value, key) => console.log(value, key));
console.log(map.size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔪 🕳️ 👍

const fs = require('fs');

var stream1 = fs.createWriteStream("src/dash-table/derived/style/py2jsCssProperties.ts");
Expand Down
3 changes: 2 additions & 1 deletion src/dash-table/components/CellFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default class CellFactory {
columns,
relevantStyles,
virtualized.data,
virtualized.offset
virtualized.offset,
selected_cells
);

const dataOpStyles = this.dataOpStyles(
Expand Down
5 changes: 0 additions & 5 deletions src/dash-table/components/Table/Dropdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,3 @@
.dash-spreadsheet .Select-control {
padding-left: 2px;
}

.dash-spreadsheet .cell--selected .Select-control {
background-color: var(--selected-background);
border-radius: 0;
}
11 changes: 0 additions & 11 deletions src/dash-table/components/Table/Table.less
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,13 @@
}
}

.selected-row {
td, th {
background-color: var(--selected-row);
}
}

tr {
background-color: white;
}

td {
background-color: inherit;

&.cell--selected {
background-color: var(--selected-background);
}

&.focused {
margin: -1px;
z-index: 200;
Expand Down Expand Up @@ -367,7 +357,6 @@
--faded-text-header: rgb(180, 180, 180);
--selected-background: rgba(255, 65, 54, 0.2);
--faded-dropdown: rgb(240, 240, 240);
--selected-row: #fff0ff;
--muted: rgb(200, 200, 200);
}

Expand Down
13 changes: 9 additions & 4 deletions src/dash-table/derived/cell/wrapperStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as R from 'ramda';
import { CSSProperties } from 'react';

import { memoizeOneFactory } from 'core/memoizer';
import { Data, VisibleColumns, IViewportOffset } from 'dash-table/components/Table/props';
import { Data, VisibleColumns, IViewportOffset, SelectedCells, ICellCoordinates } from 'dash-table/components/Table/props';
import { IConvertedStyle } from '../style';
import { BORDER_PROPERTIES_AND_FRAGMENTS } from '../edges/type';

Expand All @@ -12,9 +12,10 @@ function getter(
columns: VisibleColumns,
columnStyles: IConvertedStyle[],
data: Data,
offset: IViewportOffset
offset: IViewportOffset,
selectedCells: SelectedCells
): Style[][] {
return R.addIndex<any, Style[]>(R.map)((datum, index) => R.map(column => {
return R.addIndex<any, Style[]>(R.map)((datum, index) => R.addIndex<any, Style>(R.map)((column, columnIndex) => {
const relevantStyles = R.map(
s => s.style,
R.filter<IConvertedStyle>(
Expand All @@ -25,7 +26,11 @@ function getter(
columnStyles
)
);

const matchCell = (cell: ICellCoordinates) => cell.row === index && cell.column === columnIndex;
const isSelectedCell: boolean = R.any(matchCell)(selectedCells);
if (isSelectedCell) {
relevantStyles.push({backgroundColor: 'var(--selected-background)'});
Comment thread
alinastarkov marked this conversation as resolved.
}
return relevantStyles.length ?
R.omit(
BORDER_PROPERTIES_AND_FRAGMENTS,
Expand Down
2 changes: 0 additions & 2 deletions src/dash-table/derived/cell/wrappers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class Wrappers {
(column, columnIndex) => {
const active = isActiveCell(activeCell, rowIndex + offset.rows, columnIndex + offset.columns);
const selected = isSelectedCell(selectedCells, rowIndex + offset.rows, columnIndex + offset.columns);

const isDropdown = column.presentation === Presentation.Dropdown;

const classes =
'dash-cell' +
` column-${columnIndex}` +
Expand Down
1 change: 1 addition & 0 deletions tests/visual/percy-storybook/DashTable.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ storiesOf('DashTable/Hidden Columns', module)
id='table'
data={dataA2J}
columns={hiddenColumns}
active_cell={makeCell(1, 1, dataA2J, hiddenColumns)}
selected_cells={makeSelection([[1, 1], [1, 2], [2, 1], [2, 2]], dataA2J, hiddenColumns)}
style_data_conditional={style_data_conditional}
/>));
Expand Down
39 changes: 38 additions & 1 deletion tests/visual/percy-storybook/Style.percy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,42 @@ storiesOf('DashTable/Style type condition', module)
if: { column_id: 'Humidity', filter: '{Humidity} eq 20' },
background_color: 'yellow'
}]}

/>))
.add('single selected cells on dark themes', () => (<DataTable
id='styling-11'
data={data}
selected_cells={[{row: 1, column: 1, column_id: 'Region'}]}
active_cell={{row: 1, column: 1}}
columns={R.map(
i => ({ name: i, id: i }),
R.keysIn(data[0]))
}
content_style='grow'
style_table={{
width: '100%'
}}
style_data_conditional={[{
background_color: 'rgb(50, 50, 50)',
color: 'white',
font_family: 'arial'
}]}
/>))
.add('multiple selected cells on dark themes', () => (<DataTable
id='styling-12'
data={data}
selected_cells={[{row: 1, column: 1, column_id: 'Region'}, {row: 1, column: 2, column_id: 'Temperature'}, {row: 2, column: 1, column_id: 'Region'}, {row: 2, column: 2, column_id: 'Temperature'}]}
active_cell={{row: 1, column: 1}}
columns={R.map(
i => ({ name: i, id: i }),
R.keysIn(data[0]))
}
content_style='grow'
style_table={{
width: '100%'
}}
style_data_conditional={[{
background_color: 'rgb(50, 50, 50)',
color: 'white',
font_family: 'arial'
}]}
/>));
2 changes: 2 additions & 0 deletions tests/visual/percy-storybook/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ export default [
id: 'table',
editable: true,
selected_cells: [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],
active_cell: [1, 1],
columns: [
{
name: 'Column 1',
Expand Down Expand Up @@ -444,6 +445,7 @@ export default [
id: 'table',
editable: true,
selected_cells: [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],
active_cell: [1, 1],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hum.. one has to wonder why these still work 🤔

merge_duplicate_headers: true,
columns: [
{
Expand Down