Skip to content

Instantly share code, notes, and snippets.

@thompsongl
Last active August 15, 2019 16:28
Show Gist options
  • Save thompsongl/1ac42f85872c56854c45d6adee2e8ca0 to your computer and use it in GitHub Desktop.
Save thompsongl/1ac42f85872c56854c45d6adee2e8ca0 to your computer and use it in GitHub Desktop.
Generating Styles in EUI

Generating Style Code in EUI

Issue/Spec

Goals

  1. Continue to support broad technology choices
    • Modern JS applications are our prime concern, but we do not want to drop support for static HTML or legacy applications
  2. Continue to utilize Sass
  3. Modularize EUI
    • Obvious performance and DX implications, but also a prerequisite to migrating to any other style methodology.

Resulting Principles

  • Not start from scratch
    • Continue to rely on what EUI does well, but begin to address its monolithic nature.
  • Be open to change
    • CSS-in-JS is enticing and has enormous promise, and we're positioning ourselves for that future. Right now, though, a wholesale change is a bridge too far.

Research

astroturf and styled-jsx were given the most attention because of their inherant support for Sass and their ability to consume external .scss and .css files (making continued support for static HTML possible).

styled-components and emotion were obvious considerations, but both have decidedly excluded Sass and would require us to rewrite hundreds of foundational style utilities in JavaScript.

Minimal PoC Diffs


Feature Matrix

Feature astroturf styled-jsx
Category CSS Modules CSS-in-JS
Class name generation Full rewrite Additive/Compound
Can import .scss files
Can write Sass inline
Requires .css file after build
CSS is inlined at build
Does not require structural changes to EUI components

The fearure matrix really doesn't tell the whole story. When removing theming concerns from the equation, the modifications that styled-jsx would introduce are not seen as benefits, and are non-standard in terms of future movement to other CSS-in-JS systems. CSS Modules (via astroturf), however, would introduce minimal, standardized modifications and would defer sweeping changes for later discussion. When modularization, better style encapsulation, and minimizing overhaul are looked at as criteria, CSS Modules becomes a more realistic choice.

Resources

Zoom Video; Meeting 1

Zoom Video; Meeting 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment