12.2.1 • Published 3 years ago

fela-plugin-custom-property v12.2.1

Weekly downloads
9,322
License
MIT
Repository
github
Last release
3 years ago

fela-plugin-custom-property

Sometimes it's handy to define some custom properties mostly used as shortcuts.

A custom property basically is just a plain function that takes a value as input and outputs an object of style declarations.

Installation

yarn add fela-plugin-custom-property

You may alternatively use npm i --save fela-plugin-custom-property.

Usage

Make sure to read the documentation on how to use plugins.

import { createRenderer } from 'fela'
import customProperty from 'fela-plugin-custom-property'

const renderer = createRenderer({
  plugins: [customProperty()],
})

Configuration

In order to get custom properties resolved, you need to configure the plugin with all custom properties once.

import { createRenderer } from 'fela'
import customProperty from 'fela-plugin-custom-property'

const sizeProperty = (size) => ({
  width: size + 'px',
  height: size + 'px',
})

const customPropertyPlugin = customProperty({
  // the key defines the used CSS property
  // the value references the resolving function
  size: sizeProperty,
})

const renderer = createRenderer({
  plugins: [customPropertyPlugin],
})

Example

Let's say we want to have a custom property size that accepts a single number which will then be transformed into both width and height with a px unit applied.

Input

{
  size: 25
}

Output

{
  width: '25px',
  height: '25px'
}

License

Fela is licensed under the MIT License. Documentation is licensed under Creative Commons License. Created with ♥ by @robinweser and all the great contributors.

12.2.1

3 years ago

12.2.0

4 years ago

12.1.2

4 years ago

12.1.0

4 years ago

12.1.1

4 years ago

12.0.0

4 years ago

12.0.1

4 years ago

12.0.2

4 years ago

12.0.0-y.0

4 years ago

12.0.0-rc.3.0

4 years ago

12.0.0-rc.1

4 years ago

12.0.0-rc.2

4 years ago

12.0.0-rc.0

4 years ago

11.7.0

5 years ago

11.6.1

5 years ago

11.6.0

5 years ago

11.5.2

5 years ago

11.5.1

5 years ago

11.5.0

5 years ago

11.5.0-rc.0

5 years ago

11.4.0

6 years ago

11.3.3

6 years ago

11.3.2

6 years ago

11.3.1

6 years ago

11.3.0

6 years ago

11.2.0

6 years ago

11.1.1

6 years ago

11.1.2

6 years ago

11.1.0

6 years ago

11.0.2

6 years ago

11.0.0

6 years ago

11.0.1

6 years ago

10.8.2

6 years ago

10.8.1

6 years ago

10.8.0

7 years ago

10.7.0

7 years ago

10.6.1

7 years ago

10.6.0

7 years ago

10.5.0

7 years ago

10.4.1

7 years ago

10.4.0

7 years ago

10.3.0

7 years ago

10.2.4

7 years ago

10.2.3

7 years ago

10.2.2

7 years ago

10.2.1

7 years ago

10.2.0

7 years ago

10.1.3

7 years ago

10.1.2

7 years ago

10.1.1

7 years ago

10.1.0

7 years ago

10.0.2

7 years ago

10.0.1

7 years ago

10.0.0

7 years ago

7.0.5

7 years ago

7.0.4

8 years ago

7.0.3

8 years ago

7.0.2

8 years ago

7.0.1

8 years ago

7.0.0

8 years ago

6.0.3

8 years ago

6.0.2

8 years ago

6.0.1

8 years ago

6.0.0

8 years ago

5.0.11

8 years ago

5.0.10

9 years ago

5.0.9

9 years ago

5.0.8

9 years ago

5.0.7

9 years ago

5.0.6

9 years ago

5.0.5

9 years ago

5.0.4

9 years ago

5.0.3

9 years ago

5.0.2

9 years ago

5.0.1

9 years ago

5.0.0

9 years ago

4.3.5

9 years ago

4.3.4

9 years ago

4.3.3

9 years ago

4.3.2

9 years ago

4.3.1

9 years ago

4.3.0

9 years ago

4.2.6

9 years ago

4.2.5

9 years ago

4.2.4

9 years ago

4.2.3

9 years ago

4.2.2

9 years ago

4.2.1

9 years ago

4.2.0

9 years ago

4.1.2

9 years ago

4.1.1

9 years ago

4.1.0

9 years ago

4.0.1

9 years ago

4.0.0

9 years ago

3.0.8

9 years ago

3.0.7

9 years ago

3.0.6

9 years ago

3.0.5

9 years ago

3.0.4

9 years ago

3.0.3

9 years ago

3.0.2

9 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.0.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0-beta.2

10 years ago

1.0.0-beta.1

10 years ago

1.0.0-alpha.6

10 years ago

1.0.0-alpha.5

10 years ago