# themeizer

> Package for embedding themes from "Themeizer" Figma plugin at the server level or at build stage

Latest version **1.1.2** (published 2022-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install themeizer
pnpm add themeizer
yarn add themeizer
bun add themeizer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2022-02-12 |
| First published | 2021-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Savelyev Alexander |
| Maintainers | vordgi |
| Keywords | themeizer, theming, css-variables, variables, colors, css, styles, figma |

## Links

- npm: https://www.npmjs.com/package/themeizer
- Repository: https://github.com/vordgi/themeizer-pkg
- Homepage: https://github.com/vordgi/themeizer-pkg#readme
- Issues: https://github.com/vordgi/themeizer-pkg/issues
- npm.io page: https://npm.io/package/themeizer

## Dependencies (1)

- [fetch-cache-wrapper](https://npm.io/package/fetch-cache-wrapper.md) 0.1.1

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2022-02-12
- 1.1.1 — 2022-01-25
- 1.1.0 — 2022-01-15
- 1.0.0 — 2022-01-11
- 0.3.0 — 2021-12-28
- 0.2.1 — 2021-12-28
- 0.2.0 — 2021-12-28
- 0.1.5 — 2021-12-22
- 0.1.4 — 2021-12-20
- 0.1.3 — 2021-12-20
- 0.1.2 — 2021-12-19
- 0.1.1 — 2021-12-19
- 0.1.0 — 2021-12-19
- 0.0.7 — 2021-12-15
- 0.0.6 — 2021-12-14
- … 1 more at https://npm.io/package/themeizer/versions

## README

# Themeizer
Package for embedding themes from "Themeizer" Figma plugin at the server level or at build stage.

## Features
* Embedding styles at build time
* Manual embedding on the server
* Caching and loading every n seconds (_revalidate_)

## Installation

Using npm:
```bash
$ npm install themeizer
```

Using yarn:
```bash
$ yarn add themeizer
```

## Configuration

| Option | Required | Type | Description |
| ------ | -------- | ---- | ----------- |
| url    | true     | string | api url to load and read colors |
| headers | false | JSON | an object of headers required for reading from api |
| revalidate | false | number | period in which to fetch styles (in minutes) |

1. Add configuration to environment variables. For example, via `.env` files:
```js
// .env.local
THEMEIZER_OPTIONS={"url":"https://example.com/api/themes","revalidate":0.1,"headers":{"token":"example-token"}}
```

## Usage

### Build-time embedding:

Add the meta tag with the data-attribute `data-type="themeizer"` where you want.

```html
<head>
    ...
    <meta data-type="themeizer" />
    ...
</head>
...
```

The meta tag will be replaced with style classes, in the format:

```css
.theme-light {
    --primary: #1565C0;
}

.theme-dark {
    --primary: #90CAF9;
}
```

### Server-level style classes inlining

1. Using default method to get css

Get css object on server side
```js
const { css } = await Themeizer.init();
```

Add css code with theme classes to your code

```jsx
<style>
    {css}
</style>
```

2. Using custom injection

Get the styles object on the server side
```js
const { cssVariablesLibs } = await Themeizer.init();
```

Build theme classes from this object
```jsx
{Object.entries(colors).map(([themeName, themeObj]) => (
    <style>
        {`
        .theme-${themeName} {
              ${themeObj.list.join('\n')}
              ${themeObj.type === 'dark' ? 'color-scheme: dark;' : ''}
        }
        `}
    </style>
))}
```

## Themeizer ecosystem
* [Figma plugin "Themeizer"](https://www.figma.com/community/plugin/1065764293242137356/Themeizer) - plugin for changing themes in design and publishing them in the cloud;
* [themeizer](https://www.npmjs.com/package/themeizer) - package for embedding themes from "Themeizer" Figma plugin at the server level or at build stage;
* [next-themeizer](https://www.npmjs.com/package/next-themeizer) - package for adding "Themeizer" ecosystem interaction configuration to your next.js application;
* [themeizer-cli](https://www.npmjs.com/package/themeizer-cli) - a package to automatically replace published colors (as well as linear and radial gradients) in style files with a css variable;
* [stylelint-themeizer](https://www.npmjs.com/package/stylelint-themeizer) - stylelint plugin for "Themeizer" ecosystem.

## License

[MIT](https://github.com/vordgi/themeizer/blob/main/LICENSE)

---
_Source: https://npm.io/package/themeizer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
