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
6 changes: 6 additions & 0 deletions 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/).

## [Unreleased]
### Fixed
[#567](https://github.com/plotly/dash-table/issues/567)
- Add support for missing `border-radius` in style_** props
- Fix table's inner vs. outer container styling

## [4.2.0] - 2019-08-27
### Added
[#317](https://github.com/plotly/dash-table/issues/317)
Expand Down
48 changes: 12 additions & 36 deletions generator/cssPropertiesGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const props = [
'borderLeftColor',
'borderLeftStyle',
'borderLeftWidth',
'borderRadius',
'borderRight',
'borderRightColor',
'borderRightStyle',
Expand Down Expand Up @@ -282,52 +283,27 @@ const props = [
'zoom'
];

function toSnakeCase(name) {
return name.replace(/[A-Z]/g, v => `_${v.toLowerCase()}`);
}

function toKebabCase(name) {
return name.replace(/[A-Z]/g, v => `-${v.toLowerCase()}`);
}

const snakes = props.map(prop => [toSnakeCase(prop), prop]);
const kebabs = props.map(prop => [toKebabCase(prop), prop]);
const camels = props.map(prop => [prop, prop]);

const map = new Map();

snakes.forEach(([snake, camel]) => map.set(snake, camel));
kebabs.forEach(([kebab, camel]) => map.set(kebab, camel));
camels.forEach(([camel]) => map.set(camel, camel));

const fs = require('fs');

var stream1 = fs.createWriteStream('src/dash-table/derived/style/py2jsCssProperties.ts');
stream1.once('open', () => {
stream1.write('export type StyleProperty = string | number;\n');
stream1.write('\n');
stream1.write('export default new Map<string, string>([\n');

let first = true;
map.forEach((value, key) => {
if (!first) {
stream1.write(',\n');
}
const propFragments = props.map(prop => {
let matches = prop.match(/[a-zA-Z][a-z]*/g);
matches = matches.map(m => `'${m.toLowerCase()}'`);

first = false;
stream1.write(` ['${key}', '${value}']`);
});
stream1.write('\n]);');
return `[${matches.join(', ')}]`;
});

var stream1 = fs.createWriteStream('src/dash-table/derived/style/cssProperties.ts');
stream1.once('open', () => {
stream1.write(`export default [\n ${propFragments.join(',\n ')}\n];`);
stream1.end();
});

var stream2 = fs.createWriteStream('src/dash-table/derived/style/IStyle.ts');
stream2.once('open', () => {
stream2.write(`import { StyleProperty } from './ py2jsCssProperties';\n`);
stream2.write(`import { StyleProperty } from './py2jsCssProperties';\n`);
stream2.write('\n');
stream2.write('export default interface IStyle {\n');
camels.forEach(([key]) => {
props.forEach(key => {
stream2.write(` ${key}: StyleProperty;\n`);
});
stream2.write('}');
Expand All @@ -338,7 +314,7 @@ stream2.once('open', () => {
var stream3 = fs.createWriteStream('proptypes.js');
stream3.once('open', () => {
let first = true;
map.forEach((value, key) => {
props.forEach(key => {
if (!first) {
stream3.write(',\n');
}
Expand Down
7 changes: 6 additions & 1 deletion src/dash-table/components/ControlledTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const DEFAULT_STYLE = {
width: '100%'
};

const INNER_STYLE = {
minHeight: '100%',
minWidth: '100%'
};

export default class ControlledTable extends PureComponent<ControlledTableProps> {
private readonly menuRef = React.createRef<HTMLDivElement>();
private readonly stylesheet: Stylesheet = new Stylesheet(`#${this.props.id}`);
Expand Down Expand Up @@ -817,7 +822,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
<div
ref='table'
className={innerClasses.join(' ')}
style={tableStyle}
style={INNER_STYLE}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah that's way better 🏆

>
{grid.map((row, rowIndex) => (<div
key={`r${rowIndex}`}
Expand Down
10 changes: 4 additions & 6 deletions src/dash-table/derived/edges/type.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 { OptionalMap, OptionalProp, PropOf } from 'core/type';
import py2jsCssProperties from '../style/py2jsCssProperties';
import { KnownCssProperties } from '../style/py2jsCssProperties';
import { shallowClone } from 'core/math/matrixZipMap';

export type Edge = any;
Expand All @@ -26,11 +26,9 @@ export const BORDER_PROPERTIES: BorderProp[] = [
'borderTop'
];

export const BORDER_PROPERTIES_AND_FRAGMENTS: string[] = R.uniq(
R.filter(
p => p.indexOf('border') === 0,
Array.from(py2jsCssProperties.values())
)
export const BORDER_PROPERTIES_AND_FRAGMENTS: string[] = R.filter(
p => p.indexOf('border') === 0,
KnownCssProperties
);

export interface IEdgesMatrix {
Expand Down
1 change: 1 addition & 0 deletions src/dash-table/derived/style/IStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default interface IStyle {
borderLeftColor: StyleProperty;
borderLeftStyle: StyleProperty;
borderLeftWidth: StyleProperty;
borderRadius: StyleProperty;
borderRight: StyleProperty;
borderRightColor: StyleProperty;
borderRightStyle: StyleProperty;
Expand Down
Loading