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

@stylin.js/stylina

v0.1.5-alpha.2

Published

A vanilla inline styles statement lib

Downloads

103

Readme

Stylina

Stylin Logo

A stylin.js lightweight library for vanilla, to style builtin element using the prefix key in-

Get Started

You just need to add the cdn (https://unpkg.com/@stylin.js/stylina@<version>) to your script tag with type="module", make sure that you add the correct version as you want, see our versions.

<html lang="en">
  ...
  <body>
    ...
  </body>
  <script
    type="module"
    src="https://unpkg.com/@stylin.js/stylina@<version>"
  ></script>
</html>

Usage

CSS in-element

You must use CSS Properties as HTML attributes by passing the prefix in- as mention above. See the following code:

<!DOCTYPE html>
<html lang="en">
  ...
  <body>
    <h1 in-color="blue" in-background-color="red">
      hello <strong in-color="green">world</strong>
    </h1>
    <h2 in-color="blue" in-background-color="red">
      hi <small in-color="green">everyone</small>
    </h2>
  </body>
  <script
    type="module"
    src="https://unpkg.com/@stylin.js/stylina@<version>"
  ></script>
</html>

Define class

You can group defined style in a class and name him as you which, using the attribute in-def-class, see the following example:

<!DOCTYPE html>
<html lang="en">
  ...
  <body>
    <h1 in-color="blue" in-background-color="red" in-def-class="my-heading">
      hello <strong in-color="green" in-def-class="my-emphasis">world</strong>
    </h1>
    <h2 in-color="blue" in-background-color="red">
      hi <small in-color="green">everyone</small>
    </h2>
  </body>
  <script
    type="module"
    src="https://unpkg.com/@stylin.js/stylina@<version>"
  ></script>
</html>

Use defined classes

For sure, you can reuse your pre-defined style, see the example:

<!DOCTYPE html>
<html lang="en">
  ...
  <body>
    <h1 in-color="blue" in-background-color="red" in-def-class="my-heading">
      hello <strong in-color="green" in-def-class="my-emphasis">world</strong>
    </h1>
    <h2 in-use-class="my-heading">
      hi <small in-use-class="my-emphasis">everyone</small>
    </h2>
  </body>
  <script
    type="module"
    src="https://unpkg.com/@stylin.js/stylina@<version>"
  ></script>
</html>

Combined Styles and overwrite

You can combine the in-def-class and in-use-class, to subscribe your styles, following example:

<!DOCTYPE html>
<html lang="en">
  ...
  <body>
    <div
      in-use-class="circle"
      in-background="green"
      in-def-class="green-circle"
    >
      green
    </div>
    <div
      in-def-class="circle"
      in-width="4rem"
      in-margin="1rem"
      in-height="4rem"
      in-color="white"
      in-display="flex"
      in-background="red"
      in-font-weight="bold"
      in-border-radius="50%"
      in-align-items="center"
      in-justify-content="center"
    >
      red
    </div>
    <div in-use-class="circle,green-circle">green</div>
  </body>
  <script
    type="module"
    src="https://unpkg.com/@stylin.js/stylina@<version>"
  ></script>
</html>

Explanation

  1. On above example, in the 1st element we have in-use-class="circle" to declare that we will use this className;
  2. and then we have a style in-background="green";
  3. following by in-def-class="green-circle" to declare that we are overwriting in class .circle a new style (background: green), in a combined class .green-circle.circle;
  4. In the 2nd element, we are name all the styles as .circle, using the attribute in-def-class="circle";
  5. In the last element with in-use-class="circle,green-circle" we are use both of declared classes, circle (to use circle styles) and green-circle (to overwrite the circle background color).

Advanced Topics

Pseudo Selectors

For pseudo selector after in- you must add on- following by the pseudo selector name, for example:

<!DOCTYPE html>
<html lang="en">
  ...
  <body>
    <h1 in-color="green" in-on-hover="color: red">hello world</h1>
  </body>
  <script
    type="module"
    src="https://unpkg.com/@stylin.js/stylina@<version>"
  ></script>
</html>

Responsiveness

For responsiveness you just must add the < symbol between styles breakpoints

<!DOCTYPE html>
<html lang="en">
  ...
  <body>
    <h1 in-color="green < blue < red < yellow" in-on-hover="color: red < black < gray < cyan" >
      hello world
    </h1>
  </body>
  <script
    type="module"
    src="https://unpkg.com/@stylin.js/stylina@<version>"
  ></script>
</html>

Note: For breakpoints we are using mobile first bootstrap breakpoints, where:

  • 1st style is for xs;
  • 2nd style for sm;
  • 3rd style for md;
  • 4th style for lg;
  • 5th style for xl;
  • and 6th for xxl.