# style-handle

> JSからCSS操作

Latest version **1.2.1** (published 2016-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install style-handle
pnpm add style-handle
yarn add style-handle
bun add style-handle
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2016-10-25 |
| First published | 2015-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | honeo |
| Maintainers | honeo |
| Keywords | JS, CSS, Style |

## Links

- npm: https://www.npmjs.com/package/style-handle
- Repository: https://github.com/honeo/style-handle
- Homepage: https://github.com/honeo/style-handle#readme
- Issues: https://github.com/honeo/style-handle/issues
- npm.io page: https://npm.io/package/style-handle

## Dependencies (2)

- [make-element](https://npm.io/package/make-element.md) ^1.1.1
- [@honeo/type-check](https://npm.io/package/@honeo/type-check.md) ^2.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.1 (latest) — 2016-10-25
- 1.2.0 — 2016-06-17
- 1.1.0 — 2015-12-04
- 1.0.0 — 2015-09-21

## README

# style-handle
* [honeo/style-handle](https://github.com/honeo/style-handle)  
* [style-handle](https://www.npmjs.com/package/style-handle)

## なにこれ
JSからCSS操作するやつ。

## 使い方
```bash
$ npm i -S style-handle
```
```js
import StyleHandle from 'style-handle';

// ルール追加
StyleHandle.addRule('.hoge { prop: value; }');

// まとめて追加
StyleHandle.addText(`
/* comment */
.hoge {
    prop: value;
}
.huga {
    prop: value;
}
`);

// .cssファイルを読み込み
StyleHandle.addURL('http//example.com/hoge.css');
```

## API

### .addRule(string)
引数文字列のルールを追加して結果をobjectで返す。
```js
const obj = StyleHandle.addRule('.hoge{color: white;}');
```

### .addRules(...string)
引数文字列のルールを全て追加して結果のobjectを配列で返す。
```js
const arr = StyleHandle.addRules('.foo{padding: 10px;}', '.bar{margin: 10px;}');
```

### .removeRule(...string or index)
引数文字列またはindexのルールを削除する。
```js
const obj = StyleHandle.addRule('.hoge{color: white;}');

StyleHandle.removeRule('.hoge{color: white;}');
// or
StyleHandle.removeRule(obj.originText);
// or
StyleHandle.removeRule(obj.index);
```

### .addText(string)
引数文字列のルールをまとめて適用する。  
引数をそのまま返す。
```js
StyleHandle.addText(`
    /* comment */
    .hoge {
        color: white;
    }
`);
```

### .removeText(string)
引数文字列のルールをまとめて削除する。
```js
StyleHandle.removeText(`
    /* comment */
    .hoge {
        color: white;
    }
`);
```

### .addURL(url)
引数URLの.cssファイルを読み込む。  
引数をそのまま帰す。
```js
StyleHandle.addURL('http//example.com/hoge.css');
```

### .removeURL(url)
引数URLの.cssファイル読み込みを削除する。
```js
StyleHandle.removeURL('http//example.com/hoge.css');
```

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