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

adan

v1.0.2

Published

Styling tool belt on top of restyle and fela plugins

Downloads

31

Readme

Adan

Adan is styling tool belt on top of restyle and fela plugins.

Support Us

Support Robin Weser's work on adan and its ecosystem directly via GitHub Sponsors.

Benefits

  • Similar API
  • Theming
  • RTL Conversion
  • Vendor Prefixing
  • Extendable Plugin System
  • Fela Plugin Compatibility
  • TypeScript Support

The Gist

import { createSystem } from 'adan'

import responsiveValue from 'adan-plugin-responsive-value'

// supports most fela plugins out-of-the-box
import prefixer from 'fela-plugin-prefixer'

const theme = {
  colors: { primary: 'red' },
}

const css = createSystem({
  theme,
  plugins: [
    responsiveValue([
      '@media (min-width: 480px)',
      '@media (min-width: 1024px)',
    ]),
    prefixer(),
  ] as const,
})

// vendor prefixed appearance, red color, 20px on mobile and 16px on desktop
const style = css((theme) => ({
  color: theme.colors.primary,
  fontSize: [20, , 16],
  appearance: 'none',
}))

Why

tbd.

API

Adan only exports a single function.

createSystem

Takes a configuration object and returns a css function similar to the one from restyle.

Configuration

| Argument | Type | Description | | -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | plugins | Array<Plugin> | List of plugins that are used to process each style before transforming into a flat hooks style. See Plugins for a list of all available plugins. | | theme | Object | A theme object that can be accessed from within style functions. |

Plugin
type Plugin = style => style

Plugins are simple functions that take a style object and return a new one, similar to Fela plugins.

Note: See Plugins for a list of all available plugins.

Returns

A css function similar to the one from restyle. It receives styles and returns a tuple of className and nodes. It accepts both pure style objects as well as functions of theme. Additionally, it also supports multiple style objects and indefinitely nested arrays of style objects.

Example

See The Gist.

Plugins

Adan becomes really powerful when utilising the rich plugin echosystem. That way, we can extend the styling engine to support our personal needs.

Adan Plugins

Adan only ships 5 native plugins, everything else can be done with Fela Plugins.

| Name | Description | | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | | adan-plugin-logger | Logs style objects at the current processing position. | | adan-plugin-remove-undefined | Removes declarations that are either undefined or null. | | adan-plugin-responsive-value | Resolves responsive array values. | | adan-plugin-sort-property | Sorts properties according to a sort function. Helpful when trying to enforce a specific order. | | adan-plugin-sort-mobile-first | Sorts media queries in a mobile-first approach. |

Fela Plugins

Thanks to similar architecture and API design, adan supports almost all Fela plugins out of the box.

Tip: In order to get proper types, make sure that you import adan in the same file where Fela plugins are imported as types for all Fela plugins are shipped with the core package.

| Name | Description | Compatibility | | ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | fela-plugin-bidi | Enables direction-independent styles by converting them to either rtl or ltr on the fly. | Does not support context-specific direction via theme. | | fela-plugin-custom-property | Resolves custom properties. | Full | | fela-plugin-expand-shorthand | Expands shorthand properties into their longhand forms. | Full | | fela-plugin-extend | Adds a convenient syntax for (conditionally) extending styles. | Full | | fela-plugin-friendly-pseudo-class | Replaces JavaScript-friendly on* pseudo classes with valid CSS pseudo classes. | Full | | fela-plugin-fullscreen-prefixer | Adds vendor prefixes to :fullscreen pseudo classes. | - | | fela-plugin-hover-media | Wraps :hover styles in @media (hover: hover) queries. | Full | | fela-plugin-kebab-case | Converts properties written in kebab-case to camelCase. | Full | | fela-plugin-logger | Logs processed style objects. | Works, but logs an additional undefined. Use adan-plugin-logger instead. | | fela-plugin-multiple-selectors | Resolves multiple comma-separated selectors to individual object keys. | Full | | fela-plugin-named-keys | Replaces named keys with their actual value. | Full | | fela-plugin-placeholder-prefixer | Adds vendor prefixes to ::placeholder pseudo elements. | - | | fela-plugin-pseudo-prefixer | Adds vendor prefixes to pseudo classes and elements. | - | | fela-plugin-prefixer | Adds vendor prefixes to style objects. | - | | fela-plugin-responsive-value | Resolves array values to pre-defined media queries. Useful for component APIs. | Does not support the props argument to receive the theme. Use a static theme instead. | | fela-plugin-rtl | Converts styles to their right-to-left counterpart | Does not support context-specific direction via theme. | | fela-plugin-unit | Automatically adds units to values if needed. | Full | | fela-plugin-validator | Validates, logs & optionally deletes invalid properties for keyframes and rules. | Full |

Incompatible Fela Plugins

| Plugin | Alternative | | ----------------------- | --------------------------------------------------------------- | | fela-plugin-embedded | No replacement yet due to missing font and keyframe primitives. | | fela-plugin-theme-value | No replacement yet due to incompatible plugin APIs. |

License

Adan is licensed under the MIT License. Documentation is licensed under Creative Commons License. Created with ♥ by @robinweser.