项目作者: quarkly

项目描述 :
Library for creating atomic react components
高级语言: JavaScript
项目地址: git://github.com/quarkly/elementary.git
创建时间: 2019-05-26T10:40:29Z
项目社区:https://github.com/quarkly/elementary

开源协议:MIT License

下载




Elementary


Elementary is a library for creating atomic react components.
Inspired by tachyons and styled-system.



Build Status
Coverage
@quarkly/elementary"">Version
MIT License

Features

  • Any css properties - props
  • Simple writing media queries
  • Alias ​​system
  • Scaling indents and font sizes
  • Support hover, focus ..etc as props
  • Fully themed
  • Mixins support

Demo

Installation and Usage

  1. npm i @quarkly/elementary
  1. npm i styled-components

Let’s create element:

  1. import React from 'react';
  2. import ReactDom from 'react-dom';
  3. import elementary from '@quarkly/elementary';
  4. const Box = elementary.div();
  5. ReactDom.render(
  6. <Box width={[1, 1 / 2, 1 / 4]} bgc={['red', 'green', 'blue']} height="300px" ></Box>,
  7. document.getElementById('root'),
  8. );

Since Elementary is based on styled-components, the interface may be familiar to you.

  1. const Box = elementary.div`
  2. border: 2px solid tomato;
  3. `;

Advanced usage

  1. import React from 'react';
  2. import ReactDom from 'react-dom';
  3. import elementary from '@quarkly/elementary';
  4. const Box = elementary.div({
  5. effects: {
  6. hover: ':hover',
  7. },
  8. variant: 'boxes',
  9. rules: ['height', 'backgroundColor'],
  10. });
  11. ReactDom.render(
  12. <Box width={[1, 1 / 2, 1 / 4]} bgc={['red', 'green', 'blue']} height="300px" ></Box>,
  13. document.getElementById('root'),
  14. );

First argument is the configuration:

  • rules - an array of css properties that we will use.
  • effects - what effects can be used from jsx (hover, focus ..etc)
  • variant - options for component styles from themes
  • name - componentName and default styles for this component from a theme

Docs

License

Licensed under MIT.