joyent-portal/packages/styled-is
2017-06-15 17:11:40 +01:00
..
src chore: initial lerna setup 2017-05-25 10:56:50 +01:00
test chore: initial lerna setup 2017-05-25 10:56:50 +01:00
.eslintignore chore: initial lerna setup 2017-05-25 10:56:50 +01:00
.eslintrc chore: initial lerna setup 2017-05-25 10:56:50 +01:00
.tern-project chore: initial lerna setup 2017-05-25 10:56:50 +01:00
CHANGELOG.md chore: publish 2017-05-25 16:07:31 +01:00
package.json feat(joyent-cp-frontend): create dg initial implementation 2017-06-15 17:11:40 +01:00
README.md docs: add container badges 2017-05-31 22:35:35 +01:00
yarn.lock chore: bootstrap data for frontend 2017-06-06 10:38:59 +01:00

styled-is

License: MPL 2.0 npm standard-readme compliant

Flag utility for styled-components.

Table of Contents

Install

yarn add --dev styled-is

Usage

import is, { isNot, isOr, isSomeNot } from 'styled-is';
import styled from 'styled-components';

const Div = styled.div`
  display: block;
  opacity: 0;
  
  ${is('red')`
    background-color: red;
  `};

  ${is('blue')`
    background-color: blue;
  `};

  ${is('red', 'blue')`
    opacity: 1;
  `};

  ${is('left')`
    float: left;
  `};

  ${is('right')`
    float: right;
  `};

  ${isNot('left', 'right')`
    float: center;
  `};

  ${isOr('left', 'right')`
    position: relative;
  `};

  ${isSomeNot('red', 'left')`
    wat: 1;
  `};
`;

// display: block;
// opacity: 0;
// float: center;
// wat: 1;
<Div>

// display: block;
// opacity: 0;
// background-color: red;
// opacity: 1;
// float: center;
// wat: 1;
<Div red>

// display: block;
// opacity: 0;
// background-color: red;
// opacity: 1;
// float: left;
// position: relative;
<Div red left>

License

MPL-2.0