All Projects → brunobertolini → Styled By

brunobertolini / Styled By

Licence: mit
Simple and powerful lib to handle styled props in your components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Styled By

tsstyled
A small, fast, and simple CSS-in-JS solution for React.
Stars: ✭ 52 (-57.38%)
Mutual labels:  styled-components, css-in-js, styles
jss-material-ui
A enhanced styling engine for material-ui
Stars: ✭ 15 (-87.7%)
Mutual labels:  styled-components, props, styles
Postjss
Use the power of PostCSS in compiling with JSS
Stars: ✭ 40 (-67.21%)
Mutual labels:  styled-components, css-in-js
Styled Theming
Create themes for your app using styled-components
Stars: ✭ 1,067 (+774.59%)
Mutual labels:  styled-components, css-in-js
Cabana React
A design system built especially for both Sketch and React. 💎⚛️
Stars: ✭ 58 (-52.46%)
Mutual labels:  styled-components, css-in-js
Polished
A lightweight toolset for writing styles in JavaScript ✨
Stars: ✭ 7,074 (+5698.36%)
Mutual labels:  styled-components, css-in-js
Styled Components
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Stars: ✭ 35,473 (+28976.23%)
Mutual labels:  styled-components, css-in-js
Nanostyled
A <1kB library for styling React components as if with CSS-in-JS, without CSS-in-JS
Stars: ✭ 104 (-14.75%)
Mutual labels:  styled-components, css-in-js
Glamorous Native
React Native component styling solved💄
Stars: ✭ 566 (+363.93%)
Mutual labels:  styled-components, css-in-js
Styled Typography
Typograpy components for react and styled-components
Stars: ✭ 113 (-7.38%)
Mutual labels:  styled-components, css-in-js
Styled Components Rhythm
Vertical Rhythm and Font Baselines with Styled Components
Stars: ✭ 76 (-37.7%)
Mutual labels:  styled-components, css-in-js
Horror
😱 React HTML elements with CSS-in-JS
Stars: ✭ 78 (-36.07%)
Mutual labels:  styled-components, css-in-js
Styled System
⬢ Style props for rapid UI development
Stars: ✭ 7,126 (+5740.98%)
Mutual labels:  styled-components, css-in-js
Styled Tools
Useful interpolated functions for CSS-in-JS
Stars: ✭ 761 (+523.77%)
Mutual labels:  styled-components, css-in-js
Cattous
CSS in JSX for lazy developers, built using styled-components and styled-system
Stars: ✭ 38 (-68.85%)
Mutual labels:  styled-components, css-in-js
Design System
Priceline.com Design System
Stars: ✭ 604 (+395.08%)
Mutual labels:  styled-components, css-in-js
Atomize
library for creating atomic react components
Stars: ✭ 54 (-55.74%)
Mutual labels:  styled-components, css-in-js
Onno
Responsive style props for building themed design systems
Stars: ✭ 95 (-22.13%)
Mutual labels:  styled-components, css-in-js
Design System Utils
👩‍🎨 Access your design tokens with ease
Stars: ✭ 465 (+281.15%)
Mutual labels:  styled-components, css-in-js
React Redux Saga Boilerplate
Starter kit with react-router, react-helmet, redux, redux-saga and styled-components
Stars: ✭ 535 (+338.52%)
Mutual labels:  styled-components, css-in-js

StyledBy

Build Status codecov

Simple and powerful lib to handle styled props in your components

Install

yarn add styled-by

Basic usage

import React from 'react';
import styled from 'styled-components';
import styledBy from 'styled-by';

const Button = styled.button`
  background: ${styledBy('background')};
  color: ${styledBy('color')};
  padding: 10px;
  border-radius: 10px;
`;

export default function App() {
  return (
    <Button background="#FFF" color="rgba(0,0,0,0.5)">
      Ok
    </Button>
  );
}

Options

Basicaly, if you use styledBy('prop'), it returns prop value. But, if you want do more, use options.

Options can be:

  • string;
  • function;
  • object (and object value can be string or function)

String

Option as string, will be applied when prop is present.

const Button = styled.button`
  ${styledBy('disabled', 'background: #CCC;')}
`

<Button disabled />

Function

Option as function, always will be called passing props, even if props is undefined

  const Button = styled.button`
  ${styledBy('disabled', props => `background: ${props.disabled ? '#CCC' : '#FFF'};`)}
`

<Button disabled />

Object String

Option as object string, will be handled by prop value

const Button = styled.button`
  ${styledBy('corner', {
    rounded: `border-radius: 5px;`,
    circle: `border-radius: 100px;`
  })}
`

<Button corner="rounded" />

When option is a object, and styledBy don't find passed option, and if _ option is defined as a function, call it.

const Button = styled.button`
  ${styledBy('corner', {
    _: ({ corner }) => {}
    rounded: `border-radius: 5px;`,
    circle: `border-radius: 100px;`
  })}
`

<Button corner="square" />

Object Function

Option as object function, will be handled by prop value, and call function as prop param

const Button = styled.button`
  ${styledBy('kind', {
    default: ({ theme, color }) => `
      background: ${theme.colors[color].base};
      color: ${theme.colors[color].contrast};
      border: none;
    `,
    outline: ({ theme, color }) => `
      background: transparent;
      color: ${theme.colors[color].base};
      border: 1px solid ${theme.colors[color].base};
    `,
    clean: ({ theme, color }) => `
      background: transparent;
      color: ${theme.colors[color].base};
      border: none;
    `
  })}
`

<Button color="primary" kind="outline" />

Options list

Instead of prop name in firts param, you can pass many options as a object

const Button = styled.button`
  ${styledBy({
    disabled: `background: #CCC;`,
    corner: {
      square: 'border-radius: 0;',
      rounded: 'border-radius: 5px;',
      circle: 'border-radius: 50px;'
    }
  })}
`

This works like many styledBy props declarations

License

MIT © Bruno Bertolini

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].