Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Css modules #1236

Merged
merged 9 commits into from
Nov 27, 2018
Merged

Css modules #1236

merged 9 commits into from
Nov 27, 2018

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Nov 21, 2018

Prototype of #1090. Builds on top of #1235 to migrate two files (SettingsPane and ChartNode) away from using the "theme" context and to using CSS variables instead.

The SettingsPane component now uses CSS modules. ChartNode on the other hand continues to use inline styles. I don't know if I have a strong preference for one approach over the other– I just want to get rid of the theme context and thought it would be worth trying both approaches.

This PR shows a net increase in lines-of-code, but this is due to the yarn.lock file and additional CSS module Webpack loader config. As for the component code itself, so much code can be removed by doing this (compare before and after).

I think we should gradually migrate views to use the new approach because it would dramatically simplify the process of updating and maintaining DevTools UI.

Incremental migration should be easy, since themes will continue to be passed down via context as well as written to CSS variables. (A nice end goal would be to remove the context entirely. 😄)

@bvaughn
Copy link
Contributor Author

bvaughn commented Nov 21, 2018

This PR gives me a "Spring cleaning" feeling. It was kind of annoying updating the styles, but once it was done it felt so nice.

This enabled the theme prop to be removed from all three charting components.
@bvaughn
Copy link
Contributor Author

bvaughn commented Nov 22, 2018

I pushed one more example with da81414. This time I didn't use an external CSS file– but I did switch the inline styles for ChartNode to use CSS vars instead of the theme context, and was able to remove a lot unnecessary theme props from its ancestors.

I'm not totally set on using CSS modules for styling here. I just think we should git rid of the theme context.

@bvaughn
Copy link
Contributor Author

bvaughn commented Nov 27, 2018

I feel good about this. I don't think it's pressing enough to drop everything and rip out the context theme, but I think it's something that would be nice to do here and there, iteratively.

@bvaughn bvaughn merged commit 196b381 into facebook:master Nov 27, 2018
@bvaughn bvaughn deleted the css-modules branch November 27, 2018 15:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants