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 18 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.

46 changes: 27 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,21 @@
"url": "https://github.com/plotly/react-plotly.js-editor/issues"
},
"scripts": {
"make:combined-translation-keys":
"babel-node utils/findTranslationKeys.js && babel-node utils/combineTranslationKeys.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: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",
"make:lib": "mkdirp lib && babel src --out-dir lib --ignore=__tests__/* --source-maps && npm run make:lib:css",
Copy link
Member

Choose a reason for hiding this comment

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

@VeraZab I think you and @aulneau have squabbling .json formatting. I don't think we should use prettier on anything outside /src or at least not on anything other than *.js files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sometimes my muscle memory causes me to autoformat anything after I hit save. But it's strange, my current package.json is formatted correctly:

screen shot 2018-01-03 at 12 03 03 pm

"make:lib:css": "mkdirp lib && node-sass src/styles/main.scss > lib/react-plotly.js-editor.css",
"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 && yarn make:dist:css",
"make:dist:css": "mkdirp dist && node-sass src/styles/main.scss > dist/react-plotly.js-editor.css && yarn postcss",
"prepublishOnly": "npm run make:lib",
"lint": "prettier --write \"src/**/*.js\"",
"test:lint":
"eslint \"src/**/*.js\" && echo -e '\\033[0;32m'PASS'\\033[0m'",
"test:pretty":
"prettier -l \"src/**/*.js\" && echo -e '\\033[0;32m'PASS'\\033[0m'",
"postcss": "babel-node src/postcss.js",
"postcss:ie11": "NODE_ENV=ie babel-node src/postcss.js",
"test:lint": "eslint \"src/**/*.js\" && echo -e '\\033[0;32m'PASS'\\033[0m'",
"test:pretty": "prettier -l \"src/**/*.js\" && echo -e '\\033[0;32m'PASS'\\033[0m'",
"test:js": "jest --setupTestFrameworkScriptFile=raf/polyfill",
"test": "npm run test:lint && npm run test:pretty && npm run test:js",
"watch":
"babel src --watch --out-dir lib --source-maps | node-sass -w src/styles/main.scss lib/react-plotly.js-editor.css",
"watch": "babel src --watch --out-dir lib --source-maps | node-sass -w src/styles/main.scss lib/react-plotly.js-editor.css",
"watch-test": "jest --watch"
},
"keywords": [
Expand All @@ -48,10 +42,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 +62,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 +79,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 All @@ -99,7 +105,9 @@
"react": "React"
},
"jest": {
"roots": ["<rootDir>/src/"],
"roots": [
"<rootDir>/src/"
],
"moduleNameMapper": {
"^.+\\.css$": "<rootDir>/config/CSSStub.js"
}
Expand Down
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
30 changes: 29 additions & 1 deletion src/components/containers/Panel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {bem} from 'lib';

import ChartLineIcon from 'mdi-react/ChartLineIcon';
class Panel extends Component {
render() {
const {visible, children} = this.props;
Expand All @@ -28,6 +28,27 @@ export class PanelHeader extends Component {
}
}

export class PanelEmpty extends Component {
render() {
const {children, message, heading, icon} = this.props;

return (
<div className={bem('panel', 'empty')}>
<div className="panel__empty__message">
<div className="panel__empty__message__icon">
{icon ? icon : <ChartLineIcon />}
</div>
<div className="panel__empty__message__heading">{heading}</div>
<div className="panel__empty__message__content">
{message}
{children}
</div>
</div>
</div>
);
}
}

Panel.propTypes = {
children: PropTypes.node,
visible: PropTypes.bool,
Expand All @@ -38,6 +59,13 @@ PanelHeader.propTypes = {
action: PropTypes.any,
};

PanelEmpty.propTypes = {
heading: PropTypes.string,
message: PropTypes.any,
children: PropTypes.node,
icon: PropTypes.node,
};

Panel.defaultProps = {
visible: true,
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/containers/Section.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class Section extends Component {
return this.sectionVisible ? (
<div className="section">
<div className="section__heading">
{this.props.name}
<div className="section__heading__text">{this.props.name}</div>
{this.menuPanel}
</div>
{this.children}
Expand Down
29 changes: 25 additions & 4 deletions src/components/containers/TraceAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {EDITOR_ACTIONS} from 'lib/constants';
import {connectTraceToPlot, bem} from 'lib';
import {PanelHeader} from 'components/containers/Panel';
import {PanelHeader, PanelEmpty} from 'components/containers/Panel';
import Button from 'components/Button';
import PlusIcon from 'mdi-react/PlusIcon';

const TraceFold = connectTraceToPlot(Fold);

Expand All @@ -27,9 +29,13 @@ export default class TraceAccordion extends Component {
const {canAdd, children} = this.props;

const addButton = canAdd && (
<button className="panel__add-button" onClick={this.addTrace}>
+ Trace
</button>
<Button
className="js-add-trace-button"
variant="primary"
onClick={this.addTrace}
icon={<PlusIcon />}
Copy link
Contributor

Choose a reason for hiding this comment

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

or PlusIcon could be the default in the Button component?

Copy link
Contributor

Choose a reason for hiding this comment

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

or maybe not, if we're including modals to the editor (which I'm not sure we will be), maybe we want more flexibility on that button

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe... I think it might be better to leave no default icon, because there are buttons that don't have icons.

label="Trace"
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be wrapped in i18n

/>
);

const panelHeader = canAdd && <PanelHeader action={addButton} />;
Expand All @@ -40,8 +46,23 @@ export default class TraceAccordion extends Component {
</TraceFold>
));

const emptyState = data.length &&
!data[0].x &&
!canAdd && (
<PanelEmpty
heading="There aren't any traces."
message={
<p>
Looks like there are no traces selected yet, head back to the
Create section to adjust the data.
</p>
}
/>
);

return (
<div className={bem('panel', 'content')}>
{emptyState}
{panelHeader}
{content}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('<AnnotationAccordion>', () => {
</TestEditor>
);

editor.find('.panel__add-button').simulate('click');
editor.find('button.js-add-annotation-button').simulate('click');

const payload = onUpdateLayout.mock.calls[0][0];
expect(payload.update).toEqual({'annotations[0]': {text: 'new text'}});
Expand Down
Loading