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

kicss

v0.4.0

Published

A small JavaScript library that can help you with keeping the UI logic code decoupled from the CSS code, while making it very easy to create components with nice, real-time animations.

Downloads

8

Readme

Keep It CSS

What?

Let's use more CSS custom properties to help ourselves with communicating the interactivity between JavaScript and CSS! Instead of generating and manipulating dynamic styles in JavaScript, we can take advantage of the custom CSS properties to provide CSS with the seeds of interactivity. So that we can implement a greater portion of interactivity right in the CSS without sacrificing from the dynamic nature of styling that we often need.

KICSS is just a mental guideline for creating dynamic UIs. Whether you use a CSS-in-JS tech or CSS Modules or a pre-processor language is irrelevant. However, it may reduce your need for these tools.

KICSS stands for "Keep It CSS" and it refers to finding ways for keeping dynamic styling in CSS. Naming is inspired by the famous programming motto KISS.

It's also the name of a small JavaScript library that can help you achieve that goal.

Please check the examples below to understand the idea better.

Why?

Simply because CSS is already an excellent language for dealing with the styling on web. If only CSS had built-in ways to declare styles that are based on more real-time user events and dynamically built UIs. But we can do it ourselves!

If followed, this approach should help you with replacing much of your dynamically-generated CSS code with static, pure CSS that can deliver the same dynamic styling needs.

Depending on the case, it may eliminate your need for a 3rd party animation library.

This way of thinking will force you to learn more about what CSS can do for you.

If you (optionally) use the JavaScript library, you can easily interpolate dynamic values and create nice, real-time animations.

Examples

Installation and usage of the JavaScript library

Installation

npm install --save kicss

# or

yarn add kicss

Usage

Option 1: Include the script in HTML:

To access KICSS from global window object:

<script type="module" src="kicss.js"></script>

Or:

<script type="module" src="kicss.js?report=cursor,scroll"></script>

Available global properties to ask: cursor, scroll.

Option 2: Import as module

import kicss from 'kicss'

Or:

import { reportGlobals, reportVariable, reportScroll } from 'kicss'

API

reportScroll(name | options, direction | options)

Will report scroll values. Should be used as the scroll event handler on the element.

Parameters:

  • name: string
  • direction: 'horizontal' | 'vertical'
  • options:
    • name: string
    • direction: 'horizontal' | 'vertical'
    • interpolations?: Interpolation[]

Usage examples: Carousel Horizontal, Scroll Content

reportVariable(name, value | options)

Will assign a css property to an element if scope is present, otherwise to :root

If value is provided as a function, then it will be treated as a responsive variable and refreshed if window dimensions change.

Parameters:

  • name: string
  • value: function | any
  • options:
    • value: function | any
    • scope?: DOMNode (default: documentElement)

Usage examples: Carousel Horizontal, Scroll Content Staggered Animation Progress Car

reportIndex(selector, options)

Will run the query for the given selector, and assign an index css property to each item. If the 'rowIndexBy' option is present, a row index will be also assigned.

Parameters:

  • selector: string
  • options:
    • indexVariableName?: string (default: '--index')
    • rowIndexVariableName?: string (default: '--row-index')
    • rowIndexBy?: number

Usage examples: Doodle 1, Doodle 2 Staggered Animation

reportGlobals(options)

Will report global properties.

options?: (default: { scroll: true, cursor: true })

  • scroll?: boolean (default: true)
  • cursor?: boolean (default: true)

Usage examples: Doodle 1, Doodle 2 Preserved Contrast