# @blaze/toggles

> Open Source UI Toolkit - Feature Toggles

Latest version **1.2.1** (published 2019-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @blaze/toggles
pnpm add @blaze/toggles
yarn add @blaze/toggles
bun add @blaze/toggles
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2019-05-29 |
| First published | 2018-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 244.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1549 |
| Author | Gregory Pratt |
| Maintainers | gregorypratt |
| Keywords | javascript, html, sass, scss, css, bem, itcss, bemit, ui, ux, framework, components, webcomponents, stencil, stenciljs, monorepo |

## Links

- npm: https://www.npmjs.com/package/@blaze/toggles
- Repository: https://github.com/BlazeSoftware/blaze
- Homepage: https://www.blazeui.com
- Issues: https://github.com/BlazeSoftware/blaze/issues
- npm.io page: https://npm.io/package/@blaze/toggles

## 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.2.1 (latest) — 2019-05-29
- 1.2.0 — 2019-04-25
- 1.1.0 — 2019-03-14
- 1.0.2 — 2019-03-12
- 1.0.1 — 2019-03-07
- 1.0.0 — 2019-03-06
- 0.2.3 — 2019-02-06
- 0.2.2 — 2019-02-05
- 0.2.1 — 2018-12-19
- 0.2.0 — 2018-12-19

## README

# <a href="https://blaze-toggles.firebaseapp.com">Blaze Feature Toggles</a>

Blaze is a framework-free open source UI toolkit. It provides great structure for building websites quickly with a scalable and maintainable foundation.

**https://www.blazeui.com**

[![ci build status](https://img.shields.io/travis/BlazeSoftware/blaze.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/BlazeSoftware/blaze)

## Using the Toggles

Add the following to your `<head></head>`.

```html
<script src="https://unpkg.com/@blaze/toggles@x.x.x/dist/collection/config.js"></script>
<script src="https://unpkg.com/@blaze/toggles@x.x.x/dist/toggles.js"></script>
```

The `x.x.x` is the specific version of the library, you should use specifc versions to prevent against breaking changes.

### Config

Next add some feature toggle config, e.g.

```js
FeatureToggles.set({
  welcomeMessage: true,
  loginPage: {
    rememberMe: 'alpha',
  },
});
```

You can call `FeatureToggles.set({...})` at anytime to update config. Everytime **FeatureToggles.set** is called it raises a `featureToggleChange` event that you can hook into.

`set` also merges the config with the already set config.

Config _values_ can be either `booleans`, `strings` or `functions`.

`Promises` are supported.

e.g. the below to toggle the feature after 2 seconds once the promise has resolved.

```js
FeatureToggles.set({
  welcomeMessage: true,
  loginPage: {
    rememberMe: () => new Promise((resolve) => setTimeout(() => resolve('alpha'), 2000)),
  },
});
```

### HTML

```html
<feature-toggle feature="welcomeMessage">
  content will be VISIBLE
</feature-toggle>

<feature-toggle feature="loginPage.rememberMe" variant="alpha">
  content will be VISIBLE
</feature-toggle>

<feature-toggle feature="loginPage.rememberMe" variant="beta">
  content will be HIDDEN
</feature-toggle>
```

|  Setting  | Description                                                            |
| :-------: | :--------------------------------------------------------------------- |
| `feature` | Feature config item, supports dot notation                             |
| `variant` | The value the toggle must be to turn on this feature (default: `true`) |

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