An open API service indexing awesome lists of open source software.

https://github.com/wraith13/typed-octicons

Typed wrapper of GitHub Octicons for TypeScript.
https://github.com/wraith13/typed-octicons

npm npm-package octicons

Last synced: 3 months ago
JSON representation

Typed wrapper of GitHub Octicons for TypeScript.

Awesome Lists containing this project

README

          

# typed-octicons

`typed-octicons` is a typed wrapper of [GitHub Octicons](https://www.npmjs.com/package/@primer/octicons) for TypeScript.

## Install

```
$ npm install typed-octicons --save
```

## How to use

```typescript
import octicons from "typed-octicons";

const svg: string = octicons.bell.toSVG();
console.log(svg); //

const makeOcticonSVG = (octicon: Octicon | keyof typeof octicons): SVGElement =>
{
const div = document.createElement("div");
div.innerHTML =
(
"string" === typeof octicon ?
octicons[octicon]:
octicon
)
.toSVG();
return div.firstChild;
};

document.body.appendChild(makeOcticonSVG(octicons.bell));
document.body.appendChild(makeOcticonSVG("bell"));
```

## How to build

requires: [Node.js](https://nodejs.org/), [TypeScript Compiler](https://www.npmjs.com/package/typescript)

`tsc -P .` or `tsc -P . -w`

### In VS Code

You can use automatic build. Run `Tasks: Allow Automatic Tasks in Folder` command from command palette ( Mac: F1 or Shift+Command+P, Windows and Linux: F1 or Shift+Ctrl+P), and restart VS Code.

## License

[Boost Software License](./LICENSE_1_0.txt)