Skip to content

Commit e8b2b42

Browse files
committed
update README.md, added THEMING.md, clean up colors and added a couple more theme related variables
1 parent 41a7942 commit e8b2b42

File tree

14 files changed

+132
-145
lines changed

14 files changed

+132
-145
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).

src/components/containers/Fold.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export default class Fold extends Component {
2525
});
2626

2727
const headerClass = classnames('fold__top', {
28-
'fold__top--active': !folded,
28+
'fold__top--open': !folded,
2929
});
3030

3131
const arrowClass = classnames('fold__top__arrow', {
32-
'fold__top__arrow--active': !folded,
32+
'fold__top__arrow--open': !folded,
3333
});
3434

3535
const arrowIcon = (

src/styles/_helpers.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
cursor: pointer;
66
}
77
.\+hover-grey:hover {
8-
color: $color-active-text;
8+
color: var(--color-text-active);
99
}
1010

1111
@function spacing($name, $true-val:false) {

src/styles/_mixins.scss

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
color: var(--color-button-#{$variant}-base-text);
6464

6565
@if ($variant == primary or $variant == upgrade) {
66-
text-shadow: $text-shadow--dark-ui;
66+
text-shadow: var(--text-shadow-dark-ui);
6767
svg {
6868
@include drop-shadow--dark-ui;
6969
}
@@ -167,25 +167,25 @@
167167

168168
@mixin heading($type: 'base') {
169169
@if ($type == 'small') {
170-
color: var(--color-text-header);
170+
color: var(--color-text-headings);
171171
font-size: var(--font-size-heading-small);
172172
font-weight: var(--font-weight-normal);
173173
line-height: var(--font-leading-head);
174174
font-family: var(--font-family-headings);
175-
letter-spacing: 0.5px;
175+
letter-spacing: var(--font-letter-spacing-headings);
176176
} @else if ($type == 'medium') {
177-
color: var(--color-text-header);
177+
color: var(--color-text-headings);
178178
font-size: var(--font-size-heading-medium);
179179
font-weight: var(--font-weight-normal);
180180
line-height: var(--font-leading-head);
181181
font-family: var(--font-family-headings);
182-
letter-spacing: 0.5px;
182+
letter-spacing: var(--font-letter-spacing-headings);
183183
} @else {
184-
color: var(--color-text-header);
184+
color: var(--color-text-headings);
185185
font-size: var(--font-size-heading-base);
186186
font-weight: var(--font-weight-normal);
187187
line-height: var(--font-leading-head);
188188
font-family: var(--font-family-headings);
189-
letter-spacing: 0.5px;
189+
letter-spacing: var(--font-letter-spacing-headings);
190190
}
191191
}

src/styles/components/containers/_fold.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
justify-content: space-between;
77
clear: both;
88
padding: var(--spacing-quarter-unit) var(--spacing-half-unit);
9-
color: var(--color-white);
9+
color: var(--fold-header-text-color-closed);
1010
font-size: var(--font-size-base);
1111
border: 1px solid var(--fold-header-border-color-closed);
1212
background-color: var(--fold-header-background-closed);
@@ -31,8 +31,8 @@
3131
}
3232
}
3333

34-
&--active {
35-
color: var(--color-white);
34+
&--open {
35+
color: var(--fold-header-text-color-base);
3636
background-color: var(--fold-header-background-base);
3737
border: 1px solid var(--fold-header-border-color-base);
3838
border-radius: var(--border-radius) var(--border-radius) 0 0;
@@ -71,7 +71,7 @@
7171
&-title {
7272
display: flex;
7373
}
74-
&--active {
74+
&--open {
7575
svg{
7676
transform: rotate(-90deg);
7777
}

src/styles/components/containers/_section.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
position: relative;
44
display: flex;
55
font-size: var(--font-size-base);
6-
color: var(--color-text-header);
6+
color: var(--color-text-section-header);
77
font-weight: var(--font-weight-semibold);
88
cursor: default;
99
background-color: var(--color-background-light);

src/styles/components/sidebar/_main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
.sidebar__group__title {
6666
&__label {
6767
font-weight: var(--font-weight-semibold);
68+
color: var(--color-text-active);
6869
}
6970
&__icon {
7071
opacity: 1;

src/styles/components/widgets/_colorpicker.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,6 @@ $slider-picker-height: 10px;
127127
margin: var(--spacing-eighth-unit) var(--spacing-half-unit);
128128
font-size: var(--font-size-medium);
129129
font-weight: var(--font-weight-semibold);
130-
color: var(--color-text-header);
130+
color: var(--color-text-section-header);
131131
}
132132
}

src/styles/components/widgets/_multi-format-text-editor.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
}
136136

137137
.confirmation-panel__header {
138-
color: var(--color-text-header);
138+
color: var(--color-text-section-header);
139139
margin-top: 0;
140140
margin-bottom: 5px;
141141
font-weight: 600;

src/styles/variables/_colors.scss

-98
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
$color-black-dark: #000;
2-
$color-black-paleish: #333;
3-
$color-black-pale: #666;
4-
$color-black: #111;
5-
$color-navyblue: #284576;
6-
$color-blue: #119dff;
7-
$color-blue-dark: $color-blue; // darken
8-
$color-blue-pale: #45a9ff;
9-
$color-blue-paleish: #2391fe;
10-
$color-cyan-pale: #9bd1ff;
11-
$color-gold: #f7bd0c;
12-
$color-gray-blue: #69738a;
13-
$color-gray-blue-pale: #bec8d9;
14-
$color-gray-dark: #888;
15-
$color-gray-light: #ddd;
16-
$color-gray: #ccc;
17-
18-
$color-green-cyan: #53cf9d;
19-
$color-green-pale: #dff0d8;
20-
$color-green: #3c763d;
21-
$color-red-pale: #f2dede;
22-
$color-red: #a94442;
23-
$color-white-blue: #f4faff;
24-
$color-white-dark: #eee;
25-
$color-white-darkish: #f8f8f8;
261
$color-white: #ffffff;
272

283
// --
@@ -60,29 +35,6 @@ $color-sienna: #ef553b; // CTA's on blue backgrounds
6035

6136
// Color Map
6237
$colors: (
63-
black-dark: $color-black-dark,
64-
black-paleish: $color-black-paleish,
65-
black-pale: $color-black-pale,
66-
black: $color-black,
67-
navyblue: $color-navyblue,
68-
blue: $color-blue,
69-
blue-pale: $color-blue-pale,
70-
blue-paleish: $color-blue-paleish,
71-
cyan-pale: $color-cyan-pale,
72-
gold: $color-gold,
73-
gray-blue: $color-gray-blue,
74-
gray-blue-pale: $color-gray-blue-pale,
75-
gray-dark: $color-gray-dark,
76-
gray-light: $color-gray-light,
77-
gray: $color-gray,
78-
green-cyan: $color-green-cyan,
79-
green-pale: $color-green-pale,
80-
green: $color-green,
81-
red-pale: $color-red-pale,
82-
red: $color-red,
83-
white-blue: $color-white-blue,
84-
white-dark: $color-white-dark,
85-
white-darkish: $color-white-darkish,
8638
white: $color-white,
8739
rhino-core: $color-rhino-core,
8840
rhino-dark: $color-rhino-dark,
@@ -105,53 +57,3 @@ $colors: (
10557
emerald: $color-emerald,
10658
sienna: $color-sienna
10759
);
108-
109-
/*
110-
* COLORS
111-
*/
112-
113-
// Base Colors
114-
$color-brand: var(--color-navyblue);
115-
$color-highlight-darker: var(--color-gray-blue-pale);
116-
$color-accent: var(--color-dodger);
117-
$color-accent-shade: var(--color-dodger-shade);
118-
119-
// Theme related variables
120-
$color-border: var(--color-rhino-medium-2);
121-
$color-border-dark: var(--color-rhino-medium-1);
122-
$color-border-secondary: var(--color-rhino-light-1);
123-
$color-secondary-border: $color-border-secondary;
124-
125-
$color-button-primary: $color-accent;
126-
$color-button-primary--hover: var(--color-button-hover);
127-
$color-button-primary--active: var(--color-button-active);
128-
$color-button-secondary: var(--color-rhino-light-2);
129-
$color-button-hover: var(--color-button-hover);
130-
$color-page-background: var(--color-rhino-light-3);
131-
132-
// Text Colors
133-
$color-active-text: var(--color-active-text);
134-
$color-text-base: var(--color-text-base);
135-
$color-text: var(--color-text);
136-
$color-text-light: var(--color-text-light);
137-
$color-text-dark: var(--color-text-dark);
138-
139-
$color-secondary-text: var(--color-rhino-medium-1);
140-
$color-text-placeholder: var(--color-rhino-medium-1);
141-
$color-header-text: var(--color-rhino-core);
142-
$color-link-light: var(--color-blue-pale);
143-
144-
// Background Colors
145-
$color-background-color-inverse: var(--color-rhino-dark);
146-
$color-background-light: var(--color-rhino-light-3);
147-
$color-panel-background: var(--color-rhino-light-2);
148-
$color-section-header-background: var(--color-white-blue);
149-
$color-fold-header-background: var(--color-rhino-dark);
150-
$color-fold-header-background--closed: var(--color-rhino-medium-1);
151-
152-
// --
153-
// Buttons
154-
// --
155-
$color-button-default: $color-dodger;
156-
$color-button-hover: $color-dodger-shade;
157-
$color-button-active: $color-dodger-shade;

src/styles/variables/_main.scss

-8
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ $eighth-spacing-unit: var(--spacing-eighth-unit);
2626
* BORDERS
2727
*/
2828

29-
$border: 1px solid $color-border;
30-
$border-dark: 1px solid $color-border-dark;
31-
$border-secondary: 1px solid $color-border-secondary;
32-
$border-light: 1px solid var(--color-rhino-light-2);
33-
$border-accent: 1px solid $color-accent;
34-
$border-accent-shade: 1px solid $color-accent-shade;
35-
$border-radius: $default-border-radius;
36-
$border-radius-5: $default-border-radius-5;
3729

3830

3931
/*

0 commit comments

Comments
 (0)