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'
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,
})
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.
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.
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.