# slate-util

> Slate utils for Buzz Page Builder

Latest version **0.3.2** (published 2018-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install slate-util
pnpm add slate-util
yarn add slate-util
bun add slate-util
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2018-01-05 |
| First published | 2017-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | joehua87 |
| Maintainers | joehua |

## Links

- npm: https://www.npmjs.com/package/slate-util
- Repository: https://github.com/joehua87/slate-util
- Homepage: https://github.com/joehua87/slate-util#readme
- Issues: https://github.com/joehua87/slate-util/issues
- npm.io page: https://npm.io/package/slate-util

## Dependencies (5)

- [lodash.omit](https://npm.io/package/lodash.omit.md) ^4.5.0
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.26.0
- [lodash.pickby](https://npm.io/package/lodash.pickby.md) ^4.6.0
- [babel-preset-env](https://npm.io/package/babel-preset-env.md) ^1.6.1
- [babel-preset-react](https://npm.io/package/babel-preset-react.md) ^6.24.1

## Recent versions

- 0.3.2 (latest) — 2018-01-05
- 0.3.1 — 2017-12-28
- 0.3.0 — 2017-12-28
- 0.1.0 — 2017-12-28

## README

# Slate Util
Slate utils for Buzz Page Builder

## What's in it
### `createRenderNode({ components, enhanceFn })`
* components: a map of components for `Slate` to resolve, for example
```js
const components = {
  title: Title,
}
```

* enhanceFn: A `hoc` function.
A simple use case for this is to add hover / click events all Slate node

### getNodeData(value: TValue, key: string)
Get Node `data` by value & key

### getNodeType(value: TValue, key: string)
Get Node `type` by value & key

### getTheme(value: TValue, key: string)
In the page builder App, we set all the themes object to Slate `document` for consitence styling, something like this:
```js
const themes = {
  Title: {
    style1: {
      root: 'f1 roboto',
      content: 'pa2 mv2',
    },
    style2: {
      ...
    },
  },
  Link: {
    style1: {
      root: 'ba b--light-gray',
      icon: 'mr2',
      value: 'pa1',
    },
    style2: {
      ...
    },
  },
}
```

The node itself able to store theme in Slate Node's `data`

So the `getTheme` method is use to get calculate the theme for a node by use its `value` & `key`

The node's `theme` & `globalTheme` will be merge like this:
```js
const theme = {
    ...globalTheme,
    ...nodeTheme,
  }
```

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