npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chained-style-props

v0.2.5

Published

Write Css styles in react easily.

Downloads

8

Readme

🚧 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.