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

jstyling

v1.0.13

Published

JStyling is a JavaScript UI library to style elements in a very good looking syntax, easy to manage. Inspired by the style objects you can pass into React JSX elements.

Downloads

39

Readme

- I don't hate css files, but you just won't need them anymore.

NPM Version NPM Downloads

Intro

You won't ever need a CSS file every again! Why not just do everything in JavaScript!

This is a library which can do Styling totally inside of JavaScript.

React.JS inspired object passing in as the styling, and CSS like element selection! No more having to make everything look gibberish inside your JS file for styling.

What's new in v1.0.13

  • Ability to animate using .animate()
  • Write raw CSS in JS using .setStyle()

Example

Code for this inside example/client.js (Check out how simple it is!)

Intro Code Example

// Style it! Keep it Neat & Clean
JS("button").style({
  backgroundColor: "transparent",
  backgroundImage: "linear-gradient(rgba(0,0,0,.02), rgba(0,0,0,.03))",
  border: "1px solid rgba(0,0,0,.05)",
  color: "#006edb",
  padding: ".5em 1.6em",
  borderRadius: ".5em",
  boxShadow: "0px 1px 3px rgba(0,0,0,0.04)",
});

Benefits

  • Easy and readable syntax
  • IT'S JUST ONE JS FILE, NO CSS
  • Extremely lightweight: Only 1.2kB (500B gzipped!)

CDN

<script src="https://unpkg.com/[email protected]/src/jstyling.js">

NPM Installation

npm i jstyling

Docs

.style()

Set the styling using this method:

// You pass in a JavaScript Object to .style({})
JS("button").style({
  backgroundColor: "transparent",
  backgroundImage: "linear-gradient(rgba(0,0,0,.02), rgba(0,0,0,.03))",
  border: "1px solid rgba(0,0,0,.05)",
  color: "#006edb",
  padding: ".5em 1.6em",
  borderRadius: ".5em",
  boxShadow: "0px 1px 3px rgba(0,0,0,0.04)",
});

Select any elements just like you would in CSS:

JS("h4").style(style); // Every h4
JS("#hero").style(style); // Just #hero
JS("ul li").style(style); // Children of ul

// Also DOMElements work!
const element = document.querySelector("p");
JS(element).style(style);

Reapply new styles on callbacks:

// Set a transition to get the animation effect!
JS("#hero").style({
  width: "100%",
  height: "500px",
  backgroundColor: "orange",
});

document
  .querySelector("button")
  .addEventListener("mousedown", () => {

  JS("#hero").style({
    style.transform = "translateX(30px)"
  });
});

.animate()

If you want to animate an element, you should use this method.

JS("#button3").animate({
  styles: {
    backgroundColor: "#006edb",
    height: "500px",
  },
  duration: 1000,
  ease: "ease-in-out",
});

.animate() takes in an Object with these parameters:

  1. styles: - Pass in a styling Object consisting all of your styles you want to animate in.
  2. duration: - Duration of the animation in integer miliseconds.
  3. ease: - The transition-timing-function easing as string. All of the CSS easing work

.setStyle()

If you feel like you can't access anything from the JavaScript Style Object, you can always use this method to write the CSS, inside of JavaScript of course.

// Use backticks as they can give you multi-line strings!
JS().setStyle(`
  * {
    font-family: Arial
  }
  h2::after{
    content: "hello"
  }
`);

Styling Options

JS("#indentifier").style({
  // Your styles go here!
  maxHeight: "",
  fontSize: "",
  color: "",
  // ...
  // Remember, it's all camelCase
});

The full list of all the options are the same as vanilla javascript. You can follow this useful guide for all the possible options:

w3schools.com