0.2.5 ā€¢ Published 2 years ago

chained-style-props v0.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

šŸš§ This library is under construction! šŸš§

šŸš§ Classes and Props are not defined enough yet! šŸš§

šŸš§ Classes and Props may be changed ! šŸš§

Chained Style Props - Csp

Csp provides easier way to write Inline styles on React.js

What is Csp?

Csp (chained style props) is TypeScript library that generates inline style CSSProperties of React.js. Literraly chained style props.

Method chaining style

Write styles in method chaining, Instead of object that provides key and value.

<Component
  style={
    csp() //
      .Flex.column.topAlign.horizontalCenterAlign.Size.minWidth(320)
      .minHeight("100%")
      .Box.padding(5)
      .Border.solid.radius(2)
      .width(1)
      .color("#ccc").csp
  }
/>

Each props are categorized, Can only be called from parent class.

Extendible style

It also provides extending. So you can reuse declared styles.

import { commonCspStyle } from "/path-to-file";

// extends commonCspStyle, adding size adjustments.
const menuSize = csp(commonCspStyle).Size.minWidth(320).minHeight("100%").csp;

// extends menuSize, adding display:"flex", flexDiretion:"column"
const componentStyle = csp(menuSize).Flex.column.csp; //

<Component style={componentStyle} />;

It works with Typescript, so you can write code faster on your IDE.

Are you interested in?

Get started with

npm install chained-style-props
// or
yarn add chained-style-props

How to use

Here

Basic rules


  • Csp chains CSS Properties with . chain.

  • Must start with csp() and ends with csp.

  • You can extend other declared csp into csp(here).

  • All of the props are can only be called from their parent classes.

Props are categorized into Chained Class.


Each css props are classificated to several Class into Flex, Border, Size, Text... And we call these classes Chained Class.

In Css, every props are available anywhere. So we can write flex-direction:"column" and fontSize:12 at same time. It's very easy to write, but the names are too long and it should be considered to make easy to read (e.g. sort orders). Otherwise, it will be cause mamy problems.

In Csp, boderRadius:2 can be called as Radius(2) from Border class.

csp().Border.radius(2).csp;

Classes and inlcudings


Supported props in each classes are introduced in class/folder. It also has class definition file, so you can read them.

  • FlexBox : display:flex settings. (e.g. gap, wrap, direction, flex align features )
  • Elm : Elements settings (e.g. pointerEvents, backgroundColor)
  • Size : settings about size (e.g. height, width, padding, margin etc)
  • Text : settings about fonts. (g.s. fontWeight, fontSize, etc)
  • Border: settings about border.
  • Border Left, Border Right, Border Bottom, Border Top : Border classes grouped into each directions
  • Position: setting about positions.
  • Transition: settings about transitions.
0.2.5

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.53

2 years ago

0.0.523

2 years ago

0.0.522

2 years ago

0.0.521

2 years ago

0.0.52

2 years ago

0.0.51

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago