JSPM

  • Created
  • Published
  • Downloads 58163
  • Score
    100M100P100Q142643F
  • License MIT

inline css for component systems

Package Exports

  • glamor
  • glamor/aphrodite
  • glamor/jsxstyle
  • glamor/lib/CSSPropertyOperations
  • glamor/lib/autoprefix
  • glamor/lib/hash
  • glamor/lib/plugins
  • glamor/lib/sheet
  • glamor/package.json
  • glamor/react
  • glamor/reset
  • glamor/server

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (glamor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

glamor

build status

css for component systems

npm install glamor --save

(or)

<script src='https://unpkg.com/glamor/umd/index.min.js'></script>

usage

import { style, hover } from 'glamor'
// ...
<div 
  {...style({ color: 'red' })} 
  {...hover({ color: 'pink' })}>
  zomg
</div>

motivation

This expands on ideas from @vjeux's 2014 css-in-js talk. We introduce an api to annotate arbitrary dom nodes with style definitions ("rules") for, um, the greater good.

features

  • really small / fast / efficient, with a fluent api
  • framework independent
  • adds vendor prefixes / fallback values
  • supports all the pseudo :classes/::elements
  • @media queries
  • @font-face / @keyframes
  • escape hatches for parent and child selectors
  • dev helper to simulate pseudo classes like :hover, etc
  • server side / static rendering
  • tests / coverage

(thanks to BrowserStack for providing the infrastructure that allows us to run our build in real browsers.)

docs

extras

characteristics

while glamor shares most common attributes of other inline style / css-in-js systems, here are some key differences -

  • it does not touch class/style attributes, neither does it not generate pretty classnames; instead we use data-* attributes and jsx attribute spread (some implications). This lets you define styles 'inline', yet globally optimize as one unit.
  • in dev mode, you can simulate pseudo classes on elements by using the simulate() helper (or adding a [data-simulate-<pseudo>] attribute manually). very useful, especially when combined when hot-loading and/or editing directly in your browser devtools.
  • in production, we switch to a much faster method of appending styles to the document, able to add 10s of 1000s of rules in milliseconds. the caveat with this approach is that those styles will not be editable in chrome/firefox devtools (which is fine, for prod?). advanced users may use speedy(true/false) to toggle this setting manually.

todo

profit, profit

I get it