Skip to content
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

Separate templates from CSS modules #14

Open
penx opened this issue Mar 13, 2019 · 1 comment
Open

Separate templates from CSS modules #14

penx opened this issue Mar 13, 2019 · 1 comment

Comments

@penx
Copy link
Owner

penx commented Mar 13, 2019

We currently tie our HTML templates to our CSS modules import/implementation. We want to make HTML templates usable by other CSS techniques at some point in the future - e.g.

  • CSS classes only
  • with CSS import
  • with prebuilt CSS module
  • with CSSinJS styled components
  • with CSSinJS css function.

However, if you separate out the template from the CSS module import then:

  • when a template uses another component, should it import the template component or css module component?
  • when a subcomponent/element uses a class name, it needs to get this from the props of the parent component => either prop drill down or context api

Some work has been done to plan how this could be done:

  • classNames prop
  • elements prop
  • components prop
  • context api util or prop drilldown

However this is a large change are raises further questions

  • if useing prop drill down, do we default styles object at every step? e.g. Radios.Label received classNames prop, if it's missing class name keys we expect, do we use defaults instead? Would say yes... Do we do this via a helper function or merging with defaults each time,? This makes simple arrow function elements a bit messier. Could just do a lookup at time of accessing classNames.hasOwnProperty("class") ? classNames['class'] : defaultClassNames["class"]

What is the smallest evolution we can make in this direction?

=> separate simple components only, i.e. those that don't import other components and don't have any/a lot of elements

=> separate elements in to individual files, pass down styles as a prop to these elements, don't separate template (or at least make css module the default), continue to import other components as css module version for now. Exported versions of elements need to be wrapped to pass down styles.

penx added a commit that referenced this issue Mar 14, 2019
In preparation for #14, start to separate simple components in to template and module.

Also:

* BEM=>React conventions in readme
* storybook styles match govuk-frontend
* update flow
* Button ClassNames flow type
* include govuk-frontend button specs
@penx
Copy link
Owner Author

penx commented Oct 28, 2019

This is too big a rabbit hole for this PoC so will likely be concentrating on a functioning, feature complete CSS modules version before tackling this!

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

No branches or pull requests

1 participant