Skip to content

Styles updates, Theming and other misc updates #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4b4cebc
update styles for the sidebar, added chevron, more dynamic states
aulneau Dec 28, 2017
44dc991
minor update to modal info styles
aulneau Dec 28, 2017
8784cb4
start migrating over to custom-vars, added postcss step for ie11 that…
aulneau Dec 29, 2017
e3c8125
fixes to button styles when using standard html button
aulneau Dec 30, 2017
8f63761
update from master
aulneau Dec 30, 2017
5366cec
most variables now exist as css props
aulneau Dec 30, 2017
7a90ba2
massive change to variables, almost everything (hopefully) is connect…
aulneau Dec 31, 2017
f732a3b
fix buttons for tests
aulneau Dec 31, 2017
21b92d4
go through fold styles
aulneau Dec 31, 2017
99326af
go through info and menu panel styles
aulneau Dec 31, 2017
afc48ff
update modalbox, radioblock, menupanel, section and field styles
aulneau Dec 31, 2017
34d688c
update field styles, added FieldDelete element
aulneau Dec 31, 2017
877c2a0
update color picker styles
aulneau Dec 31, 2017
1274aa7
update sidebar styles, misc others
aulneau Dec 31, 2017
fcea940
update checkbox styles
aulneau Dec 31, 2017
083232c
updates for theming, updated postcss settings
aulneau Dec 31, 2017
9bce0eb
further theme tweaks
aulneau Dec 31, 2017
4f36879
add empty state for no traces
aulneau Dec 31, 2017
00f8ff6
add scripts, updated package.json with new scripts. IE css works.
aulneau Jan 2, 2018
0bf806d
update scripts location, remove outdated style
aulneau Jan 2, 2018
fd1f37d
move button into widgets, added font-family to .plotly-editor
aulneau Jan 2, 2018
0f5a991
remove relative 'lib', also small radiobutton css fix
aulneau Jan 2, 2018
135bbf0
localize annotation and trace accordians
aulneau Jan 2, 2018
67cf1da
fix changed path
aulneau Jan 2, 2018
02a655b
added plotly fonts, added header style mixin, applied heading styles …
aulneau Jan 2, 2018
9d91096
removed mdi-react dep, updated icons to plotly-icons
aulneau Jan 3, 2018
41a7942
update styles scripts to generate sep stylesheets for ie and modern
aulneau Jan 3, 2018
e8b2b42
update README.md, added THEMING.md, clean up colors and added a coupl…
aulneau Jan 3, 2018
4742c0d
fix prepublishOnly task, fixed DeprecationWarning in the styles scripts
aulneau Jan 3, 2018
cfa1536
Merge branch 'master' into further-design-updates
aulneau Jan 3, 2018
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
13,032 changes: 0 additions & 13,032 deletions package-lock.json

This file was deleted.

39 changes: 31 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,30 @@
"url": "https://github.com/plotly/react-plotly.js-editor/issues"
},
"scripts": {
"lint": "prettier --write \"src/**/*.js\"",
"make:combined-translation-keys":
"babel-node utils/findTranslationKeys.js && babel-node utils/combineTranslationKeys.js",
"make:translation-keys": "babel-node utils/findTranslationKeys.js",
"make:lib":
"mkdirp lib && babel src --out-dir lib --ignore=__tests__/* --source-maps && npm run make:lib:css",
"make:lib:css":
"mkdirp lib && node-sass src/styles/main.scss > lib/react-plotly.js-editor.css",
"make:lib:css": "mkdirp lib && yarn styles:lib && yarn postcss:lib",
"make:lib:css:ie":
"mkdirp lib && yarn styles:lib:ie && yarn postcss:lib:ie",
"make:dist":
"mkdirp dist && browserify src/PlotlyEditor.js -o ./dist/PlotlyEditor.js -t [ babelify --presets [ es2015 react ] ] -t browserify-global-shim --standalone createPlotlyComponent && uglifyjs ./dist/PlotlyEditor.js --compress --mangle --output ./dist/PlotlyEditor.min.js --source-map filename=dist/PlotlyEditor.min.js.map && make:dist:css",
"make:dist:css":
"mkdirp dist && node-sass --output-style compressed src/styles/main.scss > dist/react-plotly.js-editor.css",
"mkdirp dist && browserify src/PlotlyEditor.js -o ./dist/PlotlyEditor.js -t [ babelify --presets [ es2015 react ] ] -t browserify-global-shim --standalone createPlotlyComponent && uglifyjs ./dist/PlotlyEditor.js --compress --mangle --output ./dist/PlotlyEditor.min.js --source-map filename=dist/PlotlyEditor.min.js.map && yarn make:dist:css",
"make:dist:css": "mkdirp dist && yarn styles:dist && yarn postcss:dist",
"make:dist:css:ie":
"mkdirp dist && yarn styles:dist:ie && yarn postcss:dist:ie",
"prepublishOnly": "npm run make:lib",
"lint": "prettier --write \"src/**/*.js\"",
"styles:dist": "BUILD_ENV=dist babel-node scripts/styles.js",
"styles:dist:ie": "BUILD_ENV=dist SASS_ENV=ie babel-node scripts/styles.js",
"styles:lib": "BUILD_ENV=lib babel-node scripts/styles.js",
"styles:lib:ie": "BUILD_ENV=lib SASS_ENV=ie babel-node scripts/styles.js",
"postcss:dist": "BUILD_ENV=dist babel-node scripts/postcss.js",
"postcss:dist:ie":
"BUILD_ENV=dist SASS_ENV=ie babel-node scripts/postcss.js",
"postcss:lib": "BUILD_ENV=lib babel-node scripts/postcss.js",
"postcss:lib:ie": "BUILD_ENV=lib SASS_ENV=ie babel-node scripts/postcss.js",
"test:lint":
"eslint \"src/**/*.js\" && echo -e '\\033[0;32m'PASS'\\033[0m'",
"test:pretty":
Expand All @@ -48,10 +59,13 @@
"widgets"
],
"devDependencies": {
"autoprefixer": "^7.2.3",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.2",
"babel-plugin-module-resolver": "^3.0.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
Expand All @@ -65,11 +79,14 @@
"eslint-config-prettier": "^2.7.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-react": "^7.4.0",
"fs": "^0.0.1-security",
"gl": "^4.0.4",
"glob": "^7.1.2",
"jest": "^21.2.1",
"mkdirp": "^0.5.1",
"node-sass": "^4.7.1",
"node-sass": "^4.7.2",
"postcss": "^6.0.14",
"postcss-custom-properties": "^6.2.0",
"prettier": "^1.9.2",
"react-test-renderer": "^16.2.0",
"uglify-js": "^3.0.26"
Expand All @@ -79,14 +96,20 @@
"react-dom": "^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0"
},
"dependencies": {
"babel-plugin-module-resolver": "^3.0.0",
"browserify-global-shim": "^1.0.3",
"cssnano": "^3.10.0",
"draft-js": "^0.10.4",
"draft-js-export-html": "github:plotly/draft-js-export-html",
"draft-js-import-html": "^1.2.1",
"draft-js-utils": "^1.2.0",
"es6-shim": "^0.35.3",
"fast-isnumeric": "^1.1.1",
"mdi-react": "^2.1.19",
"plotly-icons": "^1.0.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

@aulneau you're going to add the additional mdi-react icons we need to plotly-icons?

"plotly.js": "^1.31.2",
"postcss-combine-duplicated-selectors": "^3.1.4",
"postcss-cssnext": "^3.0.2",
"postcss-remove-root": "^0.0.2",
"prop-types": "^15.5.10",
"raf": "^3.4.0",
"react": "^16.2.0",
Expand Down
75 changes: 75 additions & 0 deletions scripts/postcss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const fs = require('fs');
const postcss = require('postcss');
const customProperties = require('postcss-custom-properties');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const combineSelectors = require('postcss-combine-duplicated-selectors');
const removeRoot = require('postcss-remove-root');

/* eslint-disable no-process-env */
const SASS_ENV = process.env.SASS_ENV || 'default';
const BUILD_ENV = process.env.BUILD_ENV || 'lib';

const fileName = `react-plotly.js-editor`;
const dist = `${BUILD_ENV}/${fileName}.css`;

const internetExplorerPostCSS = () => {
/**
* IE11 specific post-processing
* This will:
* - combine duplicate selectors into one,
* - convert all css variables into their true value
* - remove unneeded `:root{}` after converting vars into their value
* - autoprefix for IE11
* - minify the css with cssnano
*/
const ie11_plugins = [
combineSelectors,
customProperties,
removeRoot,
autoprefixer({browsers: ['ie 11']}),
cssnano,
];
fs.readFile(`${BUILD_ENV}/react-plotly.js-editor.css`, (err, css) => {
postcss([...ie11_plugins])
.process(css, {
from: dist,
to: `${BUILD_ENV}/${fileName}.ie.min.css`,
})
.then(result => {
fs.writeFile(`${BUILD_ENV}/${fileName}.ie.min.css`, result.css);
});
});
};

const defaultPostCSS = () => {
/**
* Default post-processing
* This will:
* - combine duplicate selectors into one,
* - convert all css variables into their true value
* - remove unneeded `:root{}` after converting vars into their value
* - autoprefix for IE11
* - minify the css with cssnano
*/
const default_plugins = [combineSelectors, autoprefixer, cssnano];
fs.readFile(`${BUILD_ENV}/${fileName}.css`, (err, css) => {
postcss([...default_plugins])
.process(css, {
from: `${BUILD_ENV}/${fileName}.css`,
to: `${BUILD_ENV}/${fileName}.min.css`,
})
.then(result => {
fs.writeFile(`${BUILD_ENV}/${fileName}.min.css`, result.css);
});
});
};

/**
* Run our PostCSS scripts based off of SASS_ENV passed through
*/
if (SASS_ENV === 'ie') {
internetExplorerPostCSS();
} else {
defaultPostCSS();
}
38 changes: 38 additions & 0 deletions scripts/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const fs = require('fs');
const path = require('path');
const sass = require('node-sass');

/* eslint-disable no-process-env */
const SASS_ENV = process.env.SASS_ENV || 'default';
const BUILD_ENV = process.env.BUILD_ENV || 'lib';

const src = 'src/styles/main.scss';
const fileName = `react-plotly.js-editor`;
const dist = `${BUILD_ENV}/${fileName}.css`;

/**
* Compile our scss to css!
* --
* the `data:...` line will inject our SASS_ENV value into our scss,
* so we are able to do conditionals in scss for our env (default|ie)
*/
fs.readFile(src, function(err, data) {
sass.render(
{
data: '$ENV: "' + SASS_ENV + '";\n' + data,
includePaths: [path.dirname(src)],
outFile: dist,
},
(error, result) => {
if (error) {
/* eslint-disable no-console */
console.log(error.status);
console.log(error.column);
console.log(error.message);
console.log(error.line);
} else {
fs.writeFile(dist, result.css);
}
}
);
});
8 changes: 7 additions & 1 deletion src/PlotlyEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ class PlotlyEditor extends Component {

render() {
return (
<div className={bem()}>
<div
className={
bem('plotly-editor') +
`${this.props.className ? ` ${this.props.className}` : ''}`
}
>
{this.props.graphDiv &&
this.props.graphDiv._fullLayout &&
(this.props.children ? this.props.children : <DefaultEditor />)}
Expand All @@ -141,6 +146,7 @@ class PlotlyEditor extends Component {

PlotlyEditor.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
dataSources: PropTypes.object,
dataSourceOptions: PropTypes.array,
graphDiv: PropTypes.object,
Expand Down
44 changes: 44 additions & 0 deletions src/components/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import PropTypes from 'prop-types';
Copy link
Member

Choose a reason for hiding this comment

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

Button should go in components/widgets?

import React, {Component} from 'react';
import {bem} from 'lib';

class Button extends Component {
constructor(props) {
super(props);
}

render() {
const {variant, className, icon, label, children, ...rest} = this.props;

let classes = `button`;

if (variant) {
classes += ` button--${variant}`;
} else {
classes += ` button--default`;
}

classes += ` ${className}`;

const Icon = icon && <div className={bem('button', 'icon')}>{icon}</div>;

return (
<button className={classes} {...rest}>
<div className={bem('button', 'wrapper')}>
{Icon}
<div className="button__label">{label ? label : children}</div>
</div>
</button>
);
}
}

Button.propTypes = {
variant: PropTypes.string,
label: PropTypes.any,
className: PropTypes.any,
children: PropTypes.node,
icon: PropTypes.any,
};

export default Button;
15 changes: 10 additions & 5 deletions src/components/containers/AnnotationAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {connectAnnotationToLayout, bem} from 'lib';
import {PanelHeader} from './Panel';

import Button from 'components/Button';
import PlusIcon from 'mdi-react/PlusIcon';
const AnnotationFold = connectAnnotationToLayout(Fold);

export default class AnnotationAccordion extends Component {
Expand All @@ -30,14 +31,18 @@ export default class AnnotationAccordion extends Component {
}

render() {
const annotations = this.context.layout.annotations || [];
const {layout: {annotations = []}} = this.context;

const {canAdd, children} = this.props;

const addButton = canAdd && (
<button className="panel__add-button" onClick={this.addAnnotation}>
+ Annotation
</button>
<Button
variant="primary"
className="js-add-annotation-button"
onClick={this.addAnnotation}
icon={<PlusIcon />}
label="Annotation"
Copy link
Member

Choose a reason for hiding this comment

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

i18n

/>
);

const panelHeader = canAdd && <PanelHeader action={addButton} />;
Expand Down
4 changes: 3 additions & 1 deletion src/components/containers/Fold.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default class Fold extends Component {

const arrowIcon = (
<div className={arrowClass}>
<AngleDownIcon />
<div className="fold__top__arrow__wrapper">
<AngleDownIcon />
</div>
</div>
);

Expand Down
22 changes: 12 additions & 10 deletions src/components/containers/MenuPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default class MenuPanel extends Component {
}

getIcon() {
if (this.props.question) {
const {question} = this.props;
if (question) {
return {
icon: <QuestionIcon className="menupanel__icon" />,
spanClass: `menupanel__icon-span menupanel__icon-span--question`,
Expand All @@ -30,22 +31,23 @@ export default class MenuPanel extends Component {
}

render() {
const isOpen = this.props.show || this.state.isOpen;
const {show, ownline, label, children} = this.props;
const isOpen = show || this.state.isOpen;
const containerClass = classnames('menupanel', {
'menupanel--ownline': this.props.ownline,
'menupanel--ownline': ownline,
});

const {icon, spanClass} = this.getIcon();

return (
<div className={containerClass}>
<span className={spanClass}>
<span>{this.props.label}</span>
<span onClick={this.togglePanel}>{icon}</span>
</span>
{isOpen ? (
<ModalBox onClose={this.togglePanel}>{this.props.children}</ModalBox>
) : null}
<div className={spanClass}>
<div className="menupanel__label">{label}</div>
<div className="menupanel__icon__wrapper" onClick={this.togglePanel}>
{icon}
</div>
</div>
{isOpen && <ModalBox onClose={this.togglePanel}>{children}</ModalBox>}
</div>
);
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/containers/ModalBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import classnames from 'classnames';

export default class ModalBox extends Component {
render() {
const {backgroundDark, children, onClose} = this.props;
const modalboxClass = classnames('modalbox', {
'modalbox--dark': this.props.backgroundDark,
'modalbox--dark': backgroundDark,
});
return (
<div className={modalboxClass}>
<div className="modalbox__cover" onClick={this.props.onClose} />
<div>{this.props.children}</div>
<div className="modalbox__cover" onClick={onClose} />
<div className="modalbox__content">{children}</div>
</div>
);
}
Expand Down
Loading