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

alef

v0.1.13

Published

Dynamic and high-performance CSS in JavaScript

Downloads

15

Readme

Alef

Alef is a fast and modular library to handle styling in JavaScript. It is dynamic by design and renders your styles depending on your application state.

It generates CSS and therefore supports all common CSS features such as media queries, pseudo classes, keyframes and font-faces. It also renders on server-side with ease and ships with a powerful plugin API adding e.g. automatic vendor prefixing or fallback value support.

Alef can be used with React or with any other view library. React Native support has been removed.

Improvements from Fela

  • Entire codebase converted to TypeScript
  • Shorter classnames generated using a Base64 alphabet (instead of just numbers)
  • Will no longer generate problematic classnames (such as those likely to be blocked by ad-blockers)
  • Performance enhancements (including API-breaking changes)
  • Removed support for React Native
  • Removed some Angular stuff that I don't care about
  • Uses tabs for indentation

Installation

We're busy refactoring and hitting the delete key, so you can't install it (yet).

Features

  • Dynamic styling
  • Universal rendering
  • Dead code elimination
  • High performance
  • Minimal CSS output
  • Framework-agnostic
  • Pseudo classes & Media queries
  • Child & Attribute selectors
  • Vendor prefixing
  • Component theming
  • Many useful plugins
  • Local namespace

The Gist

Alef is all about rendering styles, especially so called rules. A universal renderer will help us to render styles of all kind. Once rendered into a DOM node, a change listener will subscribe to changes and automatically add new rules. The following example illustrates the key parts of Alef though it only shows the very basics.

import { createRenderer } from 'alef'
import { render } from 'alef-dom'

// rules are just plain functions of props
// returning a valid object of style declarations
const rule = props => ({
  fontSize: props.fontSize + 'px',
  marginTop: props.margin ? '15px' : 0,
  color: 'red',
  lineHeight: 1.4,
  ':hover': {
    color: 'blue',
    fontSize: props.fontSize + 2 + 'px'
  },
  // nest media queries and pseudo classes
  // inside the style object
  '@media (min-height: 300px)': {
    backgroundColor: 'gray',
    ':hover': {
      color: 'black'
    }
  }
})

// creates a new renderer to render styles
const renderer = createRenderer()

// rendering the rule returns a className reference
// which can be attached to any element
const className = renderer.renderRule(rule, { fontSize: 12 })

// it uses atomic css design to reuse styles
// on declaration base and to keep the markup minimal
console.log(className) // => a b c d e f h

// renders all styles into the DOM
render(renderer)

Documentation

The Fela documentation should be a good start, although don't actually try to use Alef unless you are me.

Who's using Alef?

Nobody except for me...which should be a good thing.

License

Alef is licensed under the MIT License. Documentation is licensed under Creative Common License. Created by @as-com, based on excellent work by @rofrischmann and other contributors.