|
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 2 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
| 3 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 4 | + |
| 5 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 6 | + |
| 7 | +<head> |
| 8 | +<title>README.html</title> |
| 9 | +<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8"/> |
| 10 | +<link rel="stylesheet" type="text/css" media="all" href="https://cdn.jsdelivr.net/npm/github-markdown-css/github-markdown.min.css" /> |
| 11 | +<link rel="stylesheet" type="text/css" media="all" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/github.min.css" /><meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'><style> body { box-sizing: border-box; max-width: 740px; width: 100%; margin: 40px auto; padding: 0 10px; } </style><script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'></script><script src='https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js'></script><script>document.addEventListener('DOMContentLoaded', () => { document.body.classList.add('markdown-body'); document.querySelectorAll('pre[lang] > code').forEach((code) => { code.classList.add(code.parentElement.lang); }); document.querySelectorAll('pre > code').forEach((code) => { hljs.highlightBlock(code); }); });</script> |
| 12 | +</head> |
| 13 | + |
| 14 | +<body> |
| 15 | + |
| 16 | +<h1 align="center">ReScript React Feather</h1> |
| 17 | + |
| 18 | +<p><a href="./LICENSE"><img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="License: GPL v3"></a></p> |
| 19 | +<p>ReScript binding generator for the <a href="https://github.com/feathericons/react-feather">react-feather</a> library</p> |
| 20 | +<h2 id="installation">Installation</h2> |
| 21 | +<p>First run the below commands to install the dependencies:</p> |
| 22 | +<pre><code class="language-sh">yarn add @heliaxdev/rescript-react-feather react-feather |
| 23 | +</code></pre> |
| 24 | +<p>Then, add <code>@heliaxdev/rescript-react-feather</code> to <code>bs-dependencies</code>, i.e.:</p> |
| 25 | +<pre><code class="language-json">{ |
| 26 | + ... |
| 27 | +"bs-dependencies": [ |
| 28 | + "@rescript/react", |
| 29 | + "@heliaxdev/rescript-react-feather" |
| 30 | + ], |
| 31 | +} |
| 32 | +</code></pre> |
| 33 | +<p>And you should be good to go.</p> |
| 34 | +<h2 id="usage">Usage</h2> |
| 35 | +<p>This library can be used in two ways:</p> |
| 36 | +<h3 id="zero-cost-bindings">Zero-cost bindings</h3> |
| 37 | +<p>This library has zero-cost bindings for every icon in the official <a href="https://github.com/feathericons/react-feather/blob/master/src/index.d.ts">TypeScript type definitions</a>.</p> |
| 38 | +<p>You can use them like this:</p> |
| 39 | +<pre><code class="language-rescript">module CancelButton = { |
| 40 | + @react.component |
| 41 | + let make = () => { |
| 42 | + <button ariaLabel="Cancel this, please"> |
| 43 | + <ReactFeather.X color="red" size=20 className="my-cross-icon" /> |
| 44 | + </button> |
| 45 | + } |
| 46 | +} |
| 47 | +</code></pre> |
| 48 | +<h3 id="icon-component"><code>Icon</code> component</h3> |
| 49 | +<p>Aside from the zero-cost bindings, this library also generates an <code><Icon /></code> component that receives an icon name polyvariant as a prop.</p> |
| 50 | +<p>It can be used like this:</p> |
| 51 | +<pre><code class="language-rescript">module ConfirmButton = { |
| 52 | + @react.component |
| 53 | + let make = () => { |
| 54 | + <button ariaLabel="Confirm this, please"> |
| 55 | + <ReactFeather.Icon name=#Check color="green" size=20 className="my-check-icon" /> |
| 56 | + </button> |
| 57 | + } |
| 58 | +} |
| 59 | +</code></pre> |
| 60 | +<h2 id="props">Props</h2> |
| 61 | +<p>Except for the extra <code>name</code> prop in <code>ReactFeather.Icon</code>, all components have the following type:</p> |
| 62 | +<pre><code class="language-rescript">external make: (~color: string=?, ~size: int=?, ~className: string=?) => React.element |
| 63 | +</code></pre> |
| 64 | + |
| 65 | + |
| 66 | +</body> |
| 67 | +</html> |
0 commit comments