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

styled-components-mixins

v0.0.5

Published

Popular libraries as mixins for styled-components

Downloads

33

Readme

This project is a part of *-mixins, with goal to provide a better CSS experience to the React infected people.

Install

NPM

Use

 // import classes you need from the library you need.
 import {class1, class2} from 'styled-components-mixins/{LIBRARY}';
 // use them as mixins
 const Component = styled.div`
    ${class1}
    z-index: 1;
 `;

Includes:

  • https://github.com/tachyons-css/tachyons/

  • https://github.com/twbs/bootstrap

  • https://github.com/turretcss/turretcss

  • https://github.com/Dogfalo/materialize

  • https://github.com/monarkee/beard

  • https://github.com/basscss/basscss

if you need more - raise an issue, open a PR, or use webpack`s css-to-js-loader.

Demo

Edit Styled Components

Theory

Atomic (or Functional) css is quite good methodology, but as long it solves many issues - it also introduces a new one.

You can create a Button, and you can describe how it must look like.

<button class="bg-purple f6 br3 ph3 pv2 white hover-bg-light-purple">
  Button Text
</button>

But you will soil HTML code with details of behavior. Both css driven by html or html driven by css is bad. Something in the middle - BEM - is also not very usable.

You can use LESS to combine all modificators, to have single control point

.bg-purple{
  .f6;
  .br3; 
  .ph3; 
  .pv2; 
  .white;  
  .hover-bg-light-purple;
}

But result CSS will be HUGE.

But you can use client-side CSS framework, to do the same. To get a Component. And you will love the result.

const Button = styled.button`
  ${f6};
  ${br3}; 
  ${ph3}; 
  ${pv2}; 
  ${white};  
  ${hover-bg-light-purple};
`

Limitations

*-Mixins can provide only mixins. A single class, style, or an atom.

If some library has selector like:

  .someclass .someanotherClass

*-Mixins will provide only .someclass, and adding .someanotherClass to the html markup - is your duty. No magic.

Naming conversion

One cannot use real css names in js, so we have to convert names to a js-friendly format:

  • ".class" becomes class
  • "tag" becomes tag_tag
  • "#id" becomes $id
  • "hover-bg" becomes hover_bg
  • "block--element" becomes block$$element
  • ".class.anotherclass" becomes class_and_anotherclass

Prior art

Idea was found here - https://adamwathan.me/css-utility-classes-and-separation-of-concerns/

This is just an adoptation for a different style of CSS generation.

idea

Licence

MIT