2.20.40 • Published 7 years ago

glamor v2.20.40

Weekly downloads
126,549
License
MIT
Repository
github
Last release
7 years ago

glamor

Join the chat at https://gitter.im/glamor-css/Lobby

build status

css in your javascript

npm install glamor --save

usage

import { css } from 'glamor'

// make css rules
let rule = css({
  color: 'red',
  ':hover': {
    color: 'pink'
  },
  '@media(min-width: 300px)': {
    color: 'green',
    ':hover': {
      color: 'yellow'
    }
  }
})

// add as data attributes
<div {...rule} {...another}>
  zomg
</div>

// or as classes
<div className={`${rule} ${another}`}>
  zomg
</div>

// merge rules for great justice
let mono = css({
  fontFamily: 'monospace'
})

let bolder = css({
  fontWeight: 'bolder'
})

<div {...css(mono, bolder)}>
  bold code!
</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

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

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

docs

extras

speedy mode

there are two methods by which the library adds styles to the document -

  • by appending css 'rules' to a browser backed stylesheet. This is really fast, but has the disadvantage of making the styles uneditable in the devtools sidebar.
  • by appending text nodes to a style tag. This is fairly slow, but doesn't have the editing drawback.

as a compromise, we enable the former 'speedy' mode NODE_ENV=production, and disable it otherwise. You can manually toggle this with the speedy() function.

characteristics

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

  • uses 'real' stylesheets, so you can use all css features.
  • rules can be used as data-attributes or classNames.
  • simulate pseudo-classes with the simulate helper. very useful, especially when combined when hot-loading and/or editing directly in devtools.
  • really fast, by way of deduping rules, and using insertRule in production.

todo

profit, profit

I get it

2.20.40

7 years ago

2.20.39

7 years ago

2.20.38

7 years ago

2.20.37

7 years ago

2.20.36

7 years ago

2.20.35

7 years ago

2.20.34

7 years ago

2.20.33

7 years ago

2.20.32

7 years ago

2.20.31

7 years ago

2.20.30

7 years ago

2.20.29

7 years ago

2.20.28

7 years ago

2.20.27

7 years ago

2.20.26

7 years ago

3.0.0-3

7 years ago

3.0.0-2

7 years ago

2.20.25

8 years ago

3.0.0-1

8 years ago

2.20.24

8 years ago

2.20.23

8 years ago

2.20.22

8 years ago

2.20.21

8 years ago

2.20.20

8 years ago

2.20.19

8 years ago

2.20.18

8 years ago

2.20.17

8 years ago

2.20.16

8 years ago

2.20.15

8 years ago

2.20.14

8 years ago

2.20.13

8 years ago

2.20.12

8 years ago

2.20.10

8 years ago

2.20.9

8 years ago

2.20.8

8 years ago

2.20.7

8 years ago

2.20.6

8 years ago

2.20.5

8 years ago

2.20.4

8 years ago

2.20.3

8 years ago

2.20.2

8 years ago

2.20.1

8 years ago

2.20.0-alpha.2

8 years ago

2.20.0-alpha.1

8 years ago

2.19.0

8 years ago

2.18.2

8 years ago

2.18.1

8 years ago

2.18.0

8 years ago

2.17.16

8 years ago

2.17.15

8 years ago

2.17.14

8 years ago

2.17.13

8 years ago

2.17.12

8 years ago

2.17.11

8 years ago

2.17.10

8 years ago

2.17.9

8 years ago

2.17.8

8 years ago

2.17.7

8 years ago

2.17.6

8 years ago

2.17.5

8 years ago

2.17.4

8 years ago

2.17.3

8 years ago

2.17.2

8 years ago

2.17.1

8 years ago

2.17.0

8 years ago

2.16.2

8 years ago

2.16.1

8 years ago

2.16.0

8 years ago

2.15.6

8 years ago

2.15.5

8 years ago

2.15.4

8 years ago

2.15.3

8 years ago

2.15.2

8 years ago

2.15.1

8 years ago

2.15.0

8 years ago

2.14.4

8 years ago

2.14.3

8 years ago

2.14.2

8 years ago

2.14.1

8 years ago

2.14.0

8 years ago

2.13.0

8 years ago

2.12.1

8 years ago

2.12.0

8 years ago

2.11.0

8 years ago

2.10.0

8 years ago

2.9.0

8 years ago

2.8.0

8 years ago

2.7.1

8 years ago

2.7.0

8 years ago

2.6.2

8 years ago

2.6.1

8 years ago

2.6.0

8 years ago

2.5.0

8 years ago

2.4.1

8 years ago

2.4.0

8 years ago

2.3.0

8 years ago

2.2.7-alpha2

8 years ago

2.2.7-alpha

8 years ago

2.2.6

8 years ago

2.2.5

8 years ago

2.2.4

8 years ago

2.2.3

8 years ago

2.2.2

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago