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

Conversation

aulneau
Copy link
Contributor

@aulneau aulneau commented Dec 31, 2017

Okay, I've gone through just about every style in this thing and updated / refactored them to be cleaner and use variables whenever possible.

I've also added a new step to our css, I've added postcss to process our generated css and do a few different things. It seemed like we weren't autoprefixing our css at all, so I've added autoprefixer. I've also opted to use cssnano with postcss to minify our css in that process, so we are no longer using the node-sass compress functionality. I've added a postcss plugin to combine duplicate selectors into one.

For IE11, I've added a couple postcss plugins to convert all of our custom css-props to their true values, so that if people need to support IE11 (eg: chart studio), you just include the ie11 stylesheet instead. This step can also be integrated into the users app, so that if they wanted to theme the editor first, and then run the postcss plugin themselves, they could. I've also added a plugin to remove :root{} from the stylesheet if you are generating styles for ie11.

I've also added an empty state for if there is no trace data, the message could/should be modified:

screen shot 2017-12-31 at 4 35 42 pm

I have added a delete component within the field component:

screen shot 2017-12-31 at 4 36 27 pm

I've also added a Button component.

I still need to go through and update some icons to what we have in plotly-icons, but I wanted to get this PR open :)

Regarding theming: I've opted to use scss maps and then parse through them to generate our scss variables.

The various scss maps:

screen shot 2018-01-02 at 10 53 06 am

are mapped through with scss functions:

screen shot 2018-01-02 at 10 53 18 am

which then are outputted as css variables:

screen shot 2018-01-02 at 10 52 00 am

which can be easily overridden by the end user in their app:

screen shot 2018-01-02 at 10 54 29 am

which allows for a themable app:

screen shot 2018-01-02 at 10 55 15 am

resolves: #184 #183 #76

@bpostlethwaite
Copy link
Member

Awesome work! I haven't looked in depth at this yet and maybe @VeraZab can do a review of the CSS?
As part of this PR could you add language to the README that tells people how they would customize this library? That and the build process are what I will focus on (the style and build API for developers).

Also AFAIK you are not restricted to NODE_ENV. You could, for example, use another env variable called PLOTLYJS_EDITOR_CSS_TARGET and then set that in the build command before running the javascript that does the building.

NODE_ENV is usually used to distinguish between 'dev' and 'production' builds.

@bpostlethwaite
Copy link
Member

bpostlethwaite commented Jan 1, 2018

Also this PR seems to address more than one existing issue. I see "empty state for no traces" as a commit message for example. Could you update your description to include a "resolves #x #y and #z" type declaration? Github will auto-close the issues and it will give me more context. Thanks!

Copy link
Contributor

@VeraZab VeraZab left a comment

Choose a reason for hiding this comment

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

💃 except for using icons from plotly-icons instead of mdi :)

package.json Outdated
"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?

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.

import {bem} from '../../lib';

import {bem} from 'lib';
import ChevronRightIcon from 'mdi-react/ChevronRightIcon';
import SidebarItem from './SidebarItem';
Copy link
Contributor

Choose a reason for hiding this comment

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

it's AngleDownIcon in plotly-icons

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I'll make sure to update all of the icons throughout with our plotly-icons and add any I use throughout :)

@return map-get($spacings,$name);
} @else {
@return var(--spacing-#{$name});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a sass thing: var(--spacing-#{$name}) how does it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, these are no longer used, I'll remove them.

I've added a lot of scss maps and parsers, to out put css custom properties (native css variables) from our scss.

@@ -34,7 +34,7 @@
}
}

@mixin scrollbar($width: 5px, $trackbg: $color-page-background, $thumb-color: $color-accent) {
@mixin scrollbar($width: 5px, $trackbg: var(--scrollbar-track-background), $thumb-color: var(--scrollbar-thumb-color)) {
-webkit-overflow-scrolling: touch;
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the difference here between $color-accent and var(--scrollbar-thumb-color)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So a lot of these variables are kind of passed around so that you can theme the application, the reason this is set this way is so that the end user can change the accent color, and the scollbar default thumb color would be the accent color, but if they wanted a different color for the scrollbar, they would change the value of --scrollbar-thumb-color.

@VeraZab
Copy link
Contributor

VeraZab commented Jan 2, 2018

haha, yeah..at some point we're going to have to clean up some of those scripts in the editor, there are soooo many, but yeah, not in this pr : )

@aulneau
Copy link
Contributor Author

aulneau commented Jan 2, 2018

Yeah I know :/ I felt so bad making like 6 more scripts in there... There has to be a way to abstract and make it more efficient.

message={
<p>
Looks like there aren't any traces defined yet. Go to the 'Create'
tab to define some traces.
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 _(). Ping me or @VeraZab with any questions

variant="primary"
onClick={this.addTrace}
icon={<PlusIcon />}
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

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

@@ -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?

@@ -0,0 +1,73 @@
// button default styles
Copy link
Member

Choose a reason for hiding this comment

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

this should be within a folder in components/? Seems like a widget to me.

@aulneau
Copy link
Contributor Author

aulneau commented Jan 3, 2018

Okay @bpostlethwaite and @VeraZab, I've updated the readme, added a theming document, and I believe I've fixed everything you two have requested. If you can review my latest changes, I'd say this is good to go! :) (barring any new changes requested)

VeraZab
VeraZab previously approved these changes Jan 3, 2018
@VeraZab
Copy link
Contributor

VeraZab commented Jan 3, 2018

yey 💃

package.json Outdated
"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

@bpostlethwaite
Copy link
Member

thanks for the heroic level of effort here! Can't wait to try out some new themes!

💃

@VeraZab
Copy link
Contributor

VeraZab commented Jan 3, 2018

new release after this merge! : )

@aulneau
Copy link
Contributor Author

aulneau commented Jan 3, 2018

@VeraZab okay I fixed the prepublishOnly task. should be good to go! (also I don't have permission to merge this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistent way to override CSS and styling
3 participants