Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adan

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adan

Styling tool belt on top of restyle and fela plugins

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Adan

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

Bundlephobia npm downloads

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
ArgumentTypeDescription
pluginsArray<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.
themeObjectA 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.

NameDescription
adan-plugin-loggerLogs style objects at the current processing position.
adan-plugin-remove-undefinedRemoves declarations that are either undefined or null.
adan-plugin-responsive-valueResolves responsive array values.
adan-plugin-sort-propertySorts properties according to a sort function. Helpful when trying to enforce a specific order.
adan-plugin-sort-mobile-firstSorts 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.

NameDescriptionCompatibility
fela-plugin-bidiEnables 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-propertyResolves custom properties.Full
fela-plugin-expand-shorthandExpands shorthand properties into their longhand forms.Full
fela-plugin-extendAdds a convenient syntax for (conditionally) extending styles.Full
fela-plugin-friendly-pseudo-classReplaces JavaScript-friendly on* pseudo classes with valid CSS pseudo classes.Full
fela-plugin-fullscreen-prefixerAdds vendor prefixes to :fullscreen pseudo classes.-
fela-plugin-hover-mediaWraps :hover styles in @media (hover: hover) queries.Full
fela-plugin-kebab-caseConverts properties written in kebab-case to camelCase.Full
fela-plugin-loggerLogs processed style objects.Works, but logs an additional undefined. Use adan-plugin-logger instead.
fela-plugin-multiple-selectorsResolves multiple comma-separated selectors to individual object keys.Full
fela-plugin-named-keysReplaces named keys with their actual value.Full
fela-plugin-placeholder-prefixerAdds vendor prefixes to ::placeholder pseudo elements.-
fela-plugin-pseudo-prefixerAdds vendor prefixes to pseudo classes and elements.-
fela-plugin-prefixerAdds vendor prefixes to style objects.-
fela-plugin-responsive-valueResolves 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-rtlConverts styles to their right-to-left counterpartDoes not support context-specific direction via theme.
fela-plugin-unitAutomatically adds units to values if needed.Full
fela-plugin-validatorValidates, logs & optionally deletes invalid properties for keyframes and rules.Full
Incompatible Fela Plugins
PluginAlternative
fela-plugin-embeddedNo replacement yet due to missing font and keyframe primitives.
fela-plugin-theme-valueNo 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.

Keywords

FAQs

Package last updated on 06 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc