Git Product home page Git Product logo

glamor's Introduction

glamor

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

build status

css for component systems

npm install glamor --save

usage

import { style, merge } from 'glamor'

// make css rules 
let rule = style({ 
  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>

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

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

<div {...merge(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

  • 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
  • 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

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

glamor's People

Contributors

gitter-badger avatar iest avatar jlesquembre avatar kyleamathews avatar mjackson avatar natew avatar otbe avatar rszewczyk avatar sarbbottam avatar seldo avatar shikharkapoor avatar threepointone avatar tsriram avatar vdanchenkov avatar vutran avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.