12.2.1 • Published 3 years ago

fela-plugin-named-keys v12.2.1

Weekly downloads
6,279
License
MIT
Repository
github
Last release
3 years ago

fela-plugin-named-keys

Note: This plugin was named fela-plugin-named-media-query before. It was renamed to semantically also match @supports rules.

This plugin is basically a convenient plugin for more readable code and better maintenance. It allows to define custom key names that are later replaced for valid keys.

Installation

yarn add fela-plugin-named-keys

You may alternatively use npm i --save fela-plugin-named-keys.

Usage

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

import { createRenderer } from 'fela'
import namedKeys from 'fela-plugin-named-keys'

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

Configuration

Parameters
 ParameterValueDefaultDescription
keyMap(Object) {}An object with key-replacement pairs
Example
import { createRenderer } from 'fela'
import namedKeys from 'fela-plugin-named-keys'

const namedKeysPlugin = namedKeys({
  desktop: '@media (min-width: 1024px)',
  tablet: '@media (min-width: 768px)',
  supportsFlex: '@supports (display: flex)',
  supportsGrid: '@supports (display: grid)',
})

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

Example

Using the above example code:

Input

{
  color: 'red',
  supportsGrid: {
    color: 'green'
  },
  desktop: {
    color: 'blue',
    supportsGrid: {
      color: 'yellow'
    }
  }
}

Output

{
  color: 'red',
  '@supports (display: grid)' : {
    color: 'green'
  },
  '@media (min-width: 1024px)': {
    color: 'blue',
    '@supports (display: grid)' : {
      color: 'yellow'
    },
  }
}

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

3 years ago

12.1.2

3 years ago

12.1.0

3 years ago

12.1.1

3 years ago

12.0.0

3 years ago

12.0.1

3 years ago

12.0.2

3 years ago

12.0.0-rc.1

3 years ago

12.0.0-rc.2

3 years ago

12.0.0-rc.0

3 years ago

12.0.0-y.0

3 years ago

12.0.0-rc.3.0

3 years ago

11.7.0

4 years ago

11.6.1

4 years ago

11.6.0

4 years ago

11.5.2

4 years ago

11.5.1

4 years ago

11.5.0

5 years ago

11.5.0-rc.0

5 years ago

11.4.0

5 years ago

11.3.3

5 years ago

11.3.2

5 years ago

11.3.1

5 years ago

11.3.0

5 years ago

11.2.0

5 years ago

11.1.2

5 years ago

11.1.1

5 years ago

11.1.0

5 years ago

11.0.2

6 years ago

11.0.1

6 years ago

11.0.0

6 years ago

10.8.2

6 years ago

10.8.1

6 years ago

10.8.0

6 years ago

10.7.0

6 years ago

10.6.1

6 years ago

10.6.0

6 years ago

10.5.0

6 years ago

10.4.1

6 years ago

10.4.0

6 years ago

10.3.0

6 years ago

10.2.4

6 years ago

10.2.3

6 years ago

10.2.2

6 years ago

10.2.1

6 years ago

10.2.0

6 years ago

10.1.3

6 years ago

10.1.2

6 years ago

10.1.1

6 years ago

10.1.0

6 years ago

10.0.2

6 years ago

10.0.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago