Skip to content

Commit 1885d9d

Browse files
committed
add className and style to more components + style updates + percy integration (plotly#60)
* add `className` and `style` to parent containers where possible * reorder props so that `options` and `value` are among the first these are the most common options, so they should appear first * clean up passing props through to component this wasn’t causing any bugs but it was passing unnecessary props into the child components * style fixes * move marks and value to the first props as well * fresh metadata.json * Integrate Percy screenshot tests * add the other components to the integration screenshot test
1 parent 5607e87 commit 1885d9d

13 files changed

+495
-355
lines changed

packages/dash-core-components/dash_core_components/metadata.json

Lines changed: 212 additions & 174 deletions
Large diffs are not rendered by default.

packages/dash-core-components/dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dash_html_components
22
dash_renderer
33
dash
4-
percy
4+
git+git://github.com/chriddyp/python-percy-client.git@print-request
55
selenium
66
mock
77
tox

packages/dash-core-components/src/components/Checklist.react.js

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ export default class Checklist extends Component {
1919

2020
render() {
2121
const {
22+
className,
2223
fireEvent,
2324
id,
2425
inputClassName,
2526
inputStyle,
2627
labelClassName,
2728
labelStyle,
2829
options,
29-
setProps
30+
setProps,
31+
style
3032
} = this.props;
3133
const {values} = this.state;
3234

3335
return (
34-
<div id={id}>
36+
<div id={id} style={style} className={className}>
3537
{options.map(option => (
3638
<label
3739
key={option.value}
@@ -66,27 +68,6 @@ export default class Checklist extends Component {
6668

6769
Checklist.propTypes = {
6870
id: PropTypes.string,
69-
/**
70-
* The style of the <input> checkbox element
71-
*/
72-
inputStyle: PropTypes.object,
73-
74-
/**
75-
* The class of the <input> checkbox element
76-
*/
77-
inputClassName: PropTypes.string,
78-
79-
/**
80-
* The style of the <label> that wraps the checkbox input
81-
* and the option's label
82-
*/
83-
labelStyle: PropTypes.object,
84-
85-
/**
86-
* The class of the <label> that wraps the checkbox input
87-
* and the option's label
88-
*/
89-
labelClassName: PropTypes.string,
9071

9172
/**
9273
* An array of options
@@ -115,6 +96,39 @@ Checklist.propTypes = {
11596
*/
11697
values: PropTypes.arrayOf(PropTypes.string),
11798

99+
/**
100+
* The class of the container (div)
101+
*/
102+
className: PropTypes.string,
103+
104+
/**
105+
* The style of the container (div)
106+
*/
107+
style: PropTypes.object,
108+
109+
110+
/**
111+
* The style of the <input> checkbox element
112+
*/
113+
inputStyle: PropTypes.object,
114+
115+
/**
116+
* The class of the <input> checkbox element
117+
*/
118+
inputClassName: PropTypes.string,
119+
120+
/**
121+
* The style of the <label> that wraps the checkbox input
122+
* and the option's label
123+
*/
124+
labelStyle: PropTypes.object,
125+
126+
/**
127+
* The class of the <label> that wraps the checkbox input
128+
* and the option's label
129+
*/
130+
labelClassName: PropTypes.string,
131+
118132
/**
119133
* Dash-assigned callback that gets fired when the checkbox item gets selected.
120134
*/

packages/dash-core-components/src/components/Dropdown.react.js

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import R from 'ramda';
1+
import R, {omit} from 'ramda';
22
import React, {Component, PropTypes} from 'react';
33
import ReactDropdown from 'react-virtualized-select';
44
import createFilterOptions from 'react-select-fast-filter-options';
@@ -34,7 +34,9 @@ export default class Dropdown extends Component {
3434
}
3535

3636
render() {
37-
const {id, fireEvent, multi, options, setProps} = this.props;
37+
const {
38+
id, fireEvent, multi, options, setProps, style
39+
} = this.props;
3840
const {filterOptions, value} = this.state;
3941
let selectedValue;
4042
if (R.type(value) === 'array') {
@@ -43,7 +45,7 @@ export default class Dropdown extends Component {
4345
selectedValue = value;
4446
}
4547
return (
46-
<div id={id}>
48+
<div id={id} style={style}>
4749
<ReactDropdown
4850
filterOptions={filterOptions}
4951
options={options}
@@ -70,7 +72,7 @@ export default class Dropdown extends Component {
7072
}
7173
if (fireEvent) fireEvent('change');
7274
}}
73-
{...this.props}
75+
{...omit(['fireEvent', 'setProps', 'value'], this.props)}
7476
/>
7577
</div>
7678
);
@@ -80,8 +82,47 @@ export default class Dropdown extends Component {
8082
Dropdown.propTypes = {
8183
id: PropTypes.string,
8284

85+
/**
86+
* An array of options
87+
*/
88+
options: PropTypes.shape({
89+
/**
90+
* The checkbox's label
91+
*/
92+
label: PropTypes.string,
93+
94+
/**
95+
* The value of the checkbox. This value
96+
* corresponds to the items specified in the
97+
* `values` property.
98+
*/
99+
value: PropTypes.string,
100+
101+
/**
102+
* If true, this checkbox is disabled and can't be clicked on.
103+
*/
104+
disabled: PropTypes.bool
105+
}),
106+
107+
/**
108+
* The value of the input. If `multi` is false (the default)
109+
* then value is just a string that corresponds to the values
110+
* provided in the `options` property. If `multi` is true, then
111+
* multiple values can be selected at once, and `value` is an
112+
* array of items with values corresponding to those in the
113+
* `options` prop.
114+
*/
115+
value: PropTypes.oneOfType([
116+
PropTypes.string,
117+
PropTypes.arrayOf(PropTypes.string)
118+
]),
119+
120+
/**
121+
* className of the dropdown element
122+
*/
83123
className: PropTypes.string,
84124

125+
85126
/**
86127
* Whether or not the dropdown is "clearable", that is, whether or
87128
* not a small "x" appears on the right of the dropdown that removes
@@ -99,14 +140,6 @@ Dropdown.propTypes = {
99140
*/
100141
multi: PropTypes.bool,
101142

102-
options: PropTypes.arrayOf(
103-
PropTypes.shape({
104-
disabled: PropTypes.bool,
105-
label: PropTypes.string,
106-
value: PropTypes.string
107-
})
108-
),
109-
110143
/**
111144
* The grey, default text shown when no option is selected
112145
*/
@@ -117,19 +150,6 @@ Dropdown.propTypes = {
117150
*/
118151
searchable: PropTypes.bool,
119152

120-
/**
121-
* The value of the input. If `multi` is false (the default)
122-
* then value is just a string that corresponds to the values
123-
* provided in the `options` property. If `multi` is true, then
124-
* multiple values can be selected at once, and `value` is an
125-
* array of items with values corresponding to those in the
126-
* `options` prop.
127-
*/
128-
value: PropTypes.oneOfType([
129-
PropTypes.string,
130-
PropTypes.arrayOf(PropTypes.string)
131-
]),
132-
133153
/**
134154
* Dash-assigned callback that gets fired when the input changes
135155
*/

packages/dash-core-components/src/components/Graph.react.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,14 @@ export default class PlotlyGraph extends Component {
178178
}
179179

180180
render(){
181-
const {style, id} = this.props;
181+
const {className, id, style} = this.props;
182182

183183
return (
184184
<div
185185
key={id}
186186
id={id}
187187
style={style}
188+
className={className}
188189
/>
189190
);
190191

@@ -233,6 +234,12 @@ PlotlyGraph.propTypes = {
233234
*/
234235
style: PropTypes.object,
235236

237+
/**
238+
* className of the parent div
239+
*/
240+
className: PropTypes.string,
241+
242+
236243
/**
237244
* Beta: If true, animate between updates using
238245
* plotly.js's `animate` function

0 commit comments

Comments
 (0)