Code Monkey home page Code Monkey logo

styled-compose's Introduction

@brabeji/styled-compose

DO NOT USE YET! This helper may change a lot

Similar to https://github.com/diegohaz/reuse but aware of styled-components@4 component extension mechanism.

Installation

$ yarn add brabeji/styled-compose#0.0.1

Usage

import styled from 'styled-components';
import styledMap from 'styled-map';
import compose from '@brabeji/styled-compose';

// ButtonColors
const buttonBackground = styledMap`
	default: #ccc;
	primary: blue;
	secondary: green;
	tertiary: yellow;
`;
const ButtonColors = styled.div`
	background: ${buttonBackground};
`;

// Box
const boxSize = styledMap`
	default: 100%;
	small: 70%;
	large: 130%;
`;
const boxPadding = styledMap`
	default: 15px 30px;
	small: 10px 20px;
	large: 20px 23px;
`;
const Box = styled.div`
	font-size: ${boxSize};
	padding: ${boxPadding};
`;

// Rounding
const Rounding = styled.div`
	border-radius: 5px;
`;

// Reset
const Reset = styled.div`
	background: none;
	border: none;
	margin: 0;
	padding: 0;
`;

// actual Button
const Button = compose(
	'button',
	Reset,
	Rounding,
	ButtonColors,
	Box,
);

<Button>Click me</Button>
<Button primary small>Click me</Button>
<Button secondary large>Click me</Button>
<Button tertiary as="span">Click me</Button>

styled-compose's People

Contributors

brabeji avatar

Stargazers

Jeffrey avatar Sunny Singh avatar Tobias Timm avatar Michele Bertoli avatar ⊣˚∆˚⊢ avatar Haz avatar

Watchers

⊣˚∆˚⊢ avatar James Cloos avatar  avatar

styled-compose's Issues

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.