Skip to content

Consistent way to override CSS and styling #184

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

Closed
bpostlethwaite opened this issue Dec 26, 2017 · 6 comments · Fixed by #195
Closed

Consistent way to override CSS and styling #184

bpostlethwaite opened this issue Dec 26, 2017 · 6 comments · Fixed by #195
Assignees

Comments

@bpostlethwaite
Copy link
Member

We have style/variables/main.scss which exposes variables users can override to configure the style of the editor. However these styles are consistently applied within the editor. They are not really consistent themselves.

We need to push more variables into "themable" component scss and expose a more consistent style "API"

I'll have to discuss what is actually required for theming but I think we can go pretty far until I find that info out.

@aulneau
Copy link
Contributor

aulneau commented Dec 27, 2017

I'm thinking about this... some other components / ui libraries that I've used in the past allow for you to import something like a ThemeProvider and then you can pass an obj of style overrides to the component. I think that might work well, I'll have to think about it some more. I also need to refactor a lot of the scss to allow for things to be consistent and abstract enough for everything to work out. Will continue to update this thread as I progress.

@aulneau
Copy link
Contributor

aulneau commented Dec 28, 2017

So there are a couple options I am thinking about.

If the editor will be mostly used in a sandboxed chromium environment, then I think css variables would be a great way to allow for theming.

For example:

:root {
--brand-color: #bababa;
--button-primary-fill: #another
}

and then the user could override the styles by including a new definition after they have included the components styles

import react-plotly.js-editor/lib/react-plotly.js-editor.css
import styles/plotly.js-editor-custom-theme.css

and the plotly.js-editor-custom-theme.css could contain one or many new variable definitions that would be applied throughout the application.

The only issue with using css custom props is that they are not super supported:

screen shot 2017-12-28 at 12 07 20 pm

Another option would be to use something like this, which could also be used if we ever move to styled-components

@bpostlethwaite
Copy link
Member Author

The editor will be mostly used in Plotly's Chart Studio. Next will be random installs and apps that depend on the open source lib. But working in a chrome embedded environment is of course a hard requirement.

@bpostlethwaite
Copy link
Member Author

bpostlethwaite commented Dec 28, 2017

The only concerning item in that support document table is IE 11 which we support in the Chart Studio. If we can work around that by having the editor defaults === Chart Studio defaults then that shouldn't be an issue?

@aulneau
Copy link
Contributor

aulneau commented Dec 28, 2017

Yeah we'd be able to support editor defaults in a way that would just fall back to standard sass variables, and for the embedded / os lib we can do a @supports query in css and use css variables. There are also some potential polyfills for it -> https://github.com/webcomponents/shadycss || https://stackoverflow.com/questions/46429913/css-custom-properties-polyfill-for-ie11

I'll have to do some testing. It should work for the meantime.

@VeraZab and I were chatting and we think it would make the most sense for the long term goal to switch over to styled-components in a later phase of the editor.

I think for this phase, I'll explore and try to implement the css custom props, and then after we ship that, we should be talking about if styled-components is the direction we want to go 💯

@bpostlethwaite
Copy link
Member Author

Okay sounds like a plan!

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 a pull request may close this issue.

2 participants