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

Introduces pluggable styling API #145

Closed
wants to merge 1 commit into from

Conversation

kettanaito
Copy link
Owner

@kettanaito kettanaito commented Apr 7, 2019

Introduces pluggable styling API to use Atomic layout with any tag-based CSS-in-JS solution (styled-components, emotion). Provides any related adjustments to the library to be used style-agnostic.

GitHub

Specification

  1. Atomic layout uses a designated required produceStyles function that generated styled components (similar to styled from styled-components).
  2. When not provided the produceStyles option, Atomic layout prints an error asking to provide it. The error message includes an example of API usage with styled-components.
  3. You should provide produceStyles, as there is no default behavior on purpose. This is to make Atomic layout usable with any component-based CSS-in-JS solution without listing any of them as the library's dependency.
  4. To provide a style producer function pass it as a value of produceStyles property:
import emotion from '@emotion/styled'
import Layout from 'atomic-layout'

Layout.configure({
  produceStyles: emotion,
})
  1. Style producer can be specified only once, just as the rest of layout options via Layout API.

Release

Prior to version 1.0 the library's API should be treated as experimental, meaning that it may introduce breaking changes in minor versions. Although it's not a proper semantic release process, I see no reason to establish a stable API only somewhere around version 12.x.

Roadmap

  • Provide parametric integration tests to assert the same test suits but using emotion as the style producer
  • Ensure proper references and evaluation of custom styles producer

This was referenced Apr 7, 2019
@kettanaito kettanaito force-pushed the 57-pluggable-styling-api branch from b45da67 to a076fd2 Compare April 14, 2019 17:22
@coveralls
Copy link

coveralls commented Apr 14, 2019

Coverage Status

Coverage increased (+0.06%) to 91.077% when pulling 695e9d1 on 57-pluggable-styling-api into 1ff70cd on master.

@kettanaito
Copy link
Owner Author

Evaluation of Layout.options.produceStyles happens before the user-defined custom value, meaning before the call of Layout.configure() on the developer's side.

@kettanaito kettanaito force-pushed the 57-pluggable-styling-api branch from a076fd2 to 864d270 Compare April 17, 2019 19:44
@kettanaito kettanaito force-pushed the 57-pluggable-styling-api branch from 864d270 to 695e9d1 Compare May 1, 2019 08:27
@kettanaito kettanaito force-pushed the 57-pluggable-styling-api branch from 695e9d1 to e0543b4 Compare May 12, 2019 10:21
@kettanaito kettanaito added possibly obsolete needs:discussion Further information is requested labels Jun 29, 2019
@kettanaito
Copy link
Owner Author

Accepting a style generator function is a working, but not practical solution. Various CSS-in-JS libraries may have different API, adjusting to which would be garbaging the internal logic behind Layout.configure(). Overall, this is not a good solution in the long run.

Closing in favor of #261 and the latest update in #57.

@kettanaito kettanaito closed this Dec 5, 2019
@kettanaito kettanaito deleted the 57-pluggable-styling-api branch April 1, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:discussion Further information is requested possibly obsolete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Pluggable styling API
2 participants