lit-style
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

lit-style

PostCSS preprocessor for Tagged Templates

Build Status

Installation

npm i lit-style

Usage

import { process } from 'lit-style'
import * as postcssPresetEnv from 'postcss-preset-env'
 
// Create Tagged Templates functions
const style = process({
    plugins: [postcssPresetEnv({ stage: 0 })] // For example, use postcss-preset-env
})
 
const color = 'green'
 
// 💅 Gets the result of processing by PostCSS
export const body = async () => style`
    body {
        & a {
            color: ${color};
        }
    }
`
 
/* This results:
body a {
    color: green;
}
*/

Controls return value type with directive

import { process, directive } from 'lit-style'
import * as postcssPresetEnv from 'postcss-preset-env'
 
const processor = process({
    plugins: [postcssPresetEnv({ stage: 0 })]
})
 
const style = directive(processor, async css => `<style>${await css}</style>`)
 
const color = 'green'
 
export const body = async () => style`
    body {
        & a {
            color: ${color};
        }
    }
`
 
/* 💅 This beautifully results:
<style>
    body a {
        color: green;
    }
</style>
*/

Readme

Keywords

none

Package Sidebar

Install

npm i lit-style

Weekly Downloads

6

Version

1.1.4

License

MIT

Unpacked Size

11.2 kB

Total Files

13

Last publish

Collaborators

  • aggre