Skip to content

Commit 50ea184

Browse files
authored
Merge pull request #195 from plotly/further-design-updates
Styles updates, Theming and other misc updates
2 parents 498dea8 + cfa1536 commit 50ea184

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2814
-13945
lines changed

README.md

+7-12
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ Install the module with `npm install` or `yarn install`.
1111

1212
## Quick Start
1313

14-
1. Create a quick project using `create-react-app`: `npm install -g
15-
create-react-app` | `create-react-app quick-start` | `cd quick-start` | `npm
16-
start`
17-
2. Install the needed modules: `npm install plotly.js react-plotly.js
18-
react-plotly.js-editor --save`
19-
3. Import css stylesheets: `import
20-
react-plotly.js-editor/lib/react-plotly.js-editor.css` and
21-
`react-select/dist/react-select.css`
14+
1. Create a quick project using `create-react-app`: `npm install -g create-react-app` | `create-react-app quick-start` | `cd quick-start` | `npm start`
15+
2. Install the needed modules: `npm install plotly.js react-plotly.js react-plotly.js-editor --save`
16+
3. Import css stylesheets: `import react-plotly.js-editor/lib/react-plotly.js-editor.min.css`.
17+
* Interested in [theming](https://github.com/plotly/react-plotly.js-editor/tree/master/THEMING.md)?
18+
* Need to support IE11? import the IE css instead: `import react-plotly.js-editor/lib/react-plotly.js-editor.ie.min.css`
2219
4. Decide how your application is going to manage state: higher level component
2320
(see
2421
[simple example](https://github.com/plotly/react-plotly.js-editor/tree/master/examples/simple))
@@ -29,10 +26,8 @@ Install the module with `npm install` or `yarn install`.
2926
and layout information,
3027
* the editorRevision number and plotRevision numbers, to prevent unneeded app
3128
rerenders
32-
* an object containing all dataSources (ex: `{col1: [1, 2, 3], col2: [4, 3,
33-
2], col3: [17, 13, 9]}`),
34-
* an array of all dataSourceOptions (ex: `[ {value: 'col1', label: 'CO2'},
35-
{value: 'col2', label: 'NO2'}, {value: 'col3', label: 'SiO2'} ]`)
29+
* an object containing all dataSources (ex: `{col1: [1, 2, 3], col2: [4, 3, 2], col3: [17, 13, 9]}`),
30+
* an array of all dataSourceOptions (ex: `[ {value: 'col1', label: 'CO2'}, {value: 'col2', label: 'NO2'}, {value: 'col3', label: 'SiO2'} ]`)
3631
6. Initialize your application's state with the elements above. For the
3732
`graphDiv`, we can pass in an initial object containing data and layout,
3833
plotly.js (via a callback), will then update our state with the `graphDiv`

THEMING.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# plotly-react-editor
2+
3+
> Standalone React-based editor panel for Plotly charts
4+
5+
## Theming
6+
7+
If you are interested in theming the editor to suit your needs, we've opted to use CSS custom properties (variables). CSS variables are newer and they run in the browser. Unlike variables in a css preprocessor like less/scss, these can easily be overridden with a simple `.css` file (imported after the main stylesheet).
8+
9+
[Learn more](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables) about CSS custom properties.
10+
11+
See if [you can use them](https://caniuse.com/#feat=css-variables).
12+
13+
### Sample
14+
15+
Here is a sample theme to change the UI from light to Dark.
16+
17+
![editor-theme-example](https://user-images.githubusercontent.com/11803153/34530258-2dc6fcc0-f074-11e7-969b-b54327416b30.png)
18+
19+
```
20+
@import url('https://fonts.googleapis.com/css?family=Noto+Sans:400,700|Roboto+Mono:400,500,700');
21+
22+
.theme--dark .plotly-editor {
23+
/* Global Colors */
24+
--color-accent: hsl(205, 100%, 53%);
25+
--color-accent-shade-mid: hsl(205, 87%, 47%);
26+
--color-accent-shade: hsl(205, 87%, 40%);
27+
--color-brand: hsl(269, 94%, 68%);
28+
29+
/* Background Colors */
30+
--color-background-base: hsl(216, 28%, 12%);
31+
--color-background-light: hsl(216, 30%, 16%);
32+
--color-background-medium: hsl(224, 14%, 18%);
33+
--color-background-dark: hsl(216, 30%, 20%);
34+
--color-background-top: hsl(216, 30%, 20%);
35+
--color-background-inputs: hsl(213, 25%, 12%);
36+
37+
/* Primary Button:fills */
38+
--color-button-primary-base-fill: hsl(269, 94%, 68%);
39+
--color-button-primary-hover-fill: hsl(269, 90%, 62%);
40+
--color-button-primary-active-fill: hsl(269, 85%, 58%);
41+
/* Primary Button:border */
42+
--color-button-primary-base-border: hsl(269, 94%, 75%);
43+
--color-button-primary-hover-border: hsl(269, 94%, 75%);
44+
--color-button-primary-active-border: hsl(269, 94%, 75%);
45+
46+
/* Border Colors */
47+
--color-border-default: hsl(213, 20%, 28%);
48+
--color-border-light: hsl(213, 25%, 26%);
49+
--color-border-dark: hsl(213, 25%, 20%);
50+
51+
/* Typographical Styles */
52+
--font-family-body: 'Noto Sans', sans-serif;
53+
--font-family-headings: 'Roboto Mono', sans-serif;
54+
--font-size-base: 14px;
55+
--font-size-heading-base: 20px;
56+
--font-letter-spacing-headings: 0px;
57+
--color-text-base: hsl(216, 60%, 80%);
58+
--color-text-dark: hsl(205, 100%, 92%);
59+
--color-text-light: hsl(205, 100%, 80%);
60+
--color-text-active: var(--color-white);
61+
--color-text-header: hsl(205, 100%, 65%);
62+
63+
/* Fold Component Styles */
64+
--fold-header-text-color-base: var(--color-white);
65+
--fold-header-text-color-closed: var(--color-text-dark);
66+
--fold-header-background-closed: var(--color-background-dark);
67+
--fold-header-background-base: var(--color-background-light);
68+
--fold-header-border-color-base: var(--color-border-default);
69+
--fold-header-border-color-closed: var(--color-border-default);
70+
71+
/* Effects */
72+
--box-shadow-base-color: hsla(216, 32%, 15%, 0.5);
73+
--text-shadow-dark-ui-inactive: 0;
74+
}
75+
```
76+
77+
You can inspect the editor and see a full listing of all variables that you can override:
78+
79+
![see-css-variables-inspector](https://user-images.githubusercontent.com/11803153/34531018-7e24bbba-f076-11e7-90cd-a35fe5eae84d.png)
80+
81+
## Caveats
82+
83+
CSS custom properties are not supported in IE11. However, you can use a [PostCSS](https://github.com/postcss/postcss) plugin to convert the css properties to their true value when they are used. We are using [PostCSS Custom Properties](https://github.com/postcss/postcss-custom-properties).
84+
85+
The PostCSS plugin we are using only applies to variables that are in the `:root{}` scope. If you'd like to both theme and use your styles to support IE11, you would need to import the unminified IE styles we ship with the editor:
86+
`import react-plotly.js-editor/lib/react-plotly.js-editor.ie.css` (this stylesheet has the variables attached to the `:root{}` scope).
87+
88+
Then, rather than applying your custom properties to `.theme--dark .plotly-editor`, you would apply your overrides to `:root`.
89+
90+
Finally, you would pipe in the PostCSS plugin(s) to your project and produce a css file with the properties applied as their true value. It's reccomended to use the [PostCSS Remove Root](https://github.com/cbracco/postcss-remove-root) plugin after you have converted all of the properties.
91+
92+
You can see our PostCSS scripts [here](https://github.com/plotly/react-plotly.js-editor/tree/master/scripts/postcss.js).

0 commit comments

Comments
 (0)