|
1 | 1 | # rescript-chakra
|
2 | 2 | > ReScript binding for React Chakra-UI.
|
3 | 3 |
|
| 4 | +## ToC |
| 5 | +<!-- vim-markdown-toc GFM --> |
| 6 | + |
| 7 | + * [Installation](#installation) |
| 8 | + * [Example](#example) |
| 9 | +* [Docs](#docs) |
| 10 | + * [Style Props](#style-props) |
| 11 | + * [Component](#component) |
| 12 | + * [Layout](#layout) |
| 13 | + * [Forms](#forms) |
| 14 | + * [Data Display](#data-display) |
| 15 | + * [Feedback](#feedback) |
| 16 | + * [Typography](#typography) |
| 17 | + * [Overlay](#overlay) |
| 18 | + * [Disclosure](#disclosure) |
| 19 | + * [Navigation](#navigation) |
| 20 | + * [Media and Icons](#media-and-icons) |
| 21 | + * [Others](#others) |
| 22 | + * [Hooks](#hooks) |
| 23 | +* [Contribution](#contribution) |
| 24 | + * [Make a new component binding](#make-a-new-component-binding) |
| 25 | +* [Acknowledgement](#acknowledgement) |
| 26 | + |
| 27 | +<!-- vim-markdown-toc --> |
| 28 | + |
4 | 29 | ## Installation
|
5 | 30 |
|
6 | 31 | Run the following in your favorit console:
|
7 | 32 | ```console
|
8 |
| -> yarn add rescript-chakra |
| 33 | +yarn add rescript-chakra |
9 | 34 | ```
|
10 | 35 |
|
11 | 36 | **OR**
|
| 37 | + |
| 38 | +```console |
| 39 | +npm install --save rescript-chakra |
| 40 | +``` |
12 | 41 |
|
| 42 | +**Don't forget** install dependencies requirements of `@chakra-ui/react` (Skip when exist) |
| 43 | + |
13 | 44 | ```console
|
14 |
| -> npm install --save rescript-chakra |
| 45 | +yarn add @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4 |
15 | 46 | ```
|
16 | 47 |
|
| 48 | +**OR** |
| 49 | + |
| 50 | +```console |
| 51 | +npm i @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4 |
| 52 | +``` |
| 53 | + |
| 54 | + |
17 | 55 | Then, add `rescript-chakra` in your `bsconfig.json`:
|
18 | 56 | ```diff
|
19 | 57 | -- "bs-dependencies": [],
|
20 | 58 | ++ "bs-dependencies": [rescript-chakra],
|
21 | 59 | ```
|
22 | 60 |
|
23 |
| -## Usage |
| 61 | +## Example |
24 | 62 |
|
25 |
| -```rescript |
| 63 | +* following `chakra-ui` example [**here**](https://chakra-ui.com/docs/features/style-props#margin-and-padding) |
26 | 64 |
|
| 65 | +```javascript |
| 66 | +// JavaScript 🟨 | TypeScript 🟦 |
| 67 | +import { Box } from "@chakra-ui/react" |
| 68 | +// m={2} refers to the value of `theme.space[2]` |
| 69 | +<Box m={2}>Tomato</Box> |
| 70 | +// You can also use custom values |
| 71 | +<Box maxW="960px" mx="auto" /> |
| 72 | +// sets margin `8px` on all viewports and `16px` from the first breakpoint and up |
| 73 | +<Box m={[2, 3]} /> |
| 74 | + |
| 75 | +// ReScript 🟥 |
| 76 | +open Chakra |
| 77 | +@react.component |
| 78 | +let make = () => <> |
| 79 | + // m={2} refers to the value of `theme.space[2]` |
| 80 | + <Box m={#two}> {"Tomato"->React.string} </Box> |
| 81 | + // You can also use custom values |
| 82 | + <Box maxW={#px(960)} mx=#auto /> |
| 83 | + // sets margin `8px` on all viewports and `16px` from the first breakpoint and up |
| 84 | + <Box m={#array([#two, #three])} /> |
| 85 | +</> |
27 | 86 | ```
|
28 | 87 |
|
29 | 88 | Or you can check this [**Example**](https://github.com/ri7nz/rescript-chakra/tree/main/examples).
|
30 | 89 |
|
31 |
| -## API |
32 |
| -> (WIP): docs |
| 90 | +# Docs |
| 91 | +All of Binding for Chakra-UI isn't completed, if you want to support this project, see the list below 🙌. |
| 92 | + |
| 93 | +## Style Props |
| 94 | +This is following and closely same with Chakra-UI. [**See Style Props**](https://chakra-ui.com/docs/features/style-props#reference) and Implemented typed **Props** with typed **CSS-Properties** use [bs-css](https://github.com/giraud/bs-css/blob/cb242dbd08a00bd848faecb756a9ddce68d8707a/bs-css/src/Css_AtomicTypes.rei). |
| 95 | + |
| 96 | +- [x] [Margin and Padding](https://chakra-ui.com/docs/features/style-props#margin-and-padding) |
| 97 | +- [x] [Color and Background Color](https://chakra-ui.com/docs/features/style-props#color-and-background-color) |
| 98 | +- [x] [Gradient](https://chakra-ui.com/docs/features/style-props#gradient) |
| 99 | +- [x] [Layout width and height](https://chakra-ui.com/docs/features/style-props#layout-width-and-height) |
| 100 | +- [x] [Flexbox](https://chakra-ui.com/docs/features/style-props#flexbox) |
| 101 | +- [x] [Grid Layout](https://chakra-ui.com/docs/features/style-props#grid-layout) |
| 102 | +- [x] [Background](https://chakra-ui.com/docs/features/style-props#background) |
| 103 | +- [x] [Borders](https://chakra-ui.com/docs/features/style-props#borders) |
| 104 | +- [x] [Border Radius](https://chakra-ui.com/docs/features/style-props#border-radius) |
| 105 | +- [x] [Position](https://chakra-ui.com/docs/features/style-props#position) |
| 106 | +- [x] [Shadow](https://chakra-ui.com/docs/features/style-props#shadow) |
| 107 | +- [ ] [Pseudo](https://chakra-ui.com/docs/features/style-props#pseudo) (_NOT implemeted_) |
| 108 | +- [ ] [Other Style Props](https://chakra-ui.com/docs/features/style-props#other-props) 🚧 (_Partially Implemented_) |
| 109 | + |
| 110 | +All of Style Props implementation is write in File:[Chakra__MakeProps.res](https://github.com/ri7nz/rescript-chakra/blob/main/src/Chakra__MakeProps.res) |
| 111 | + |
| 112 | +## Component |
| 113 | + |
| 114 | +### Layout |
| 115 | +- [x] Aspect Ratio |
| 116 | +- [x] Box |
| 117 | +- [x] Center |
| 118 | + - [x] Square |
| 119 | + - [x] Circle |
| 120 | +- [x] Container |
| 121 | +- [x] Flex |
| 122 | +- [x] Grid |
| 123 | + - [ ] GridItem |
| 124 | +- [x] SimpleGrid |
| 125 | +- [x] Stack |
| 126 | +- [x] Wrap |
| 127 | + - [ ] WrapItem |
| 128 | + |
| 129 | +### Forms |
| 130 | +- [x] Button |
| 131 | + - [x] Button Group |
| 132 | +- [ ] Checkbox |
| 133 | +- [ ] Editable |
| 134 | +- [ ] Form Control |
| 135 | +- [ ] Icon Button |
| 136 | +- [ ] Input |
| 137 | +- [ ] Number Input |
| 138 | +- [ ] Pin Input |
| 139 | +- [ ] Radio |
| 140 | +- [ ] Select |
| 141 | +- [ ] Slider |
| 142 | +- [ ] Switch |
| 143 | +- [ ] Textarea |
| 144 | + |
| 145 | +### Data Display |
| 146 | +- [x] Badge |
| 147 | +- [x] Close Button |
| 148 | +- [x] Code |
| 149 | +- [x] Divider |
| 150 | +- [x] Kbd |
| 151 | +- [ ] List |
| 152 | + - [ ] ListItem |
| 153 | + - [ ] ListIcon |
| 154 | + - [ ] OrderedList |
| 155 | + - [ ] UnorderedList |
| 156 | +- [x] Stat |
| 157 | + - [x] StatGroup |
| 158 | + - [ ] StatLabel |
| 159 | + - [ ] StatHelpText |
| 160 | + - [ ] StatNumber |
| 161 | + - [ ] StatArrow |
| 162 | +- [ ] Table |
| 163 | + - [ ] Thead |
| 164 | + - [ ] Tbody |
| 165 | + - [ ] Tfoot |
| 166 | + - [ ] Tr |
| 167 | + - [ ] Th |
| 168 | + - [ ] Td |
| 169 | + - [ ] TableCaption |
| 170 | +- [ ] Tag |
| 171 | + - [ ] TagLabel |
| 172 | + - [ ] TagLeftIcon |
| 173 | + - [ ] TagRightIcon |
| 174 | + - [ ] TagCloseButton |
| 175 | + |
| 176 | +### Feedback |
| 177 | +- [ ] Alert |
| 178 | +- [ ] Circular Progress |
| 179 | +- [ ] Progress |
| 180 | +- [ ] Skeleton |
| 181 | +- [ ] Spinner |
| 182 | +- [ ] Toast |
| 183 | + |
| 184 | +### Typography |
| 185 | +- [ ] Text |
| 186 | +- [ ] Heading |
| 187 | + |
| 188 | +### Overlay |
| 189 | +- [ ] Alert Dialog |
| 190 | +- [ ] Drawer |
| 191 | +- [ ] Menu |
| 192 | +- [ ] Modal |
| 193 | +- [ ] Popover |
| 194 | +- [ ] Tooltip |
| 195 | + |
| 196 | +### Disclosure |
| 197 | +- [ ] Accordion |
| 198 | +- [ ] Tabs |
| 199 | +- [ ] Visually Hidden |
| 200 | + |
| 201 | +### Navigation |
| 202 | +- [ ] Breadcrumb |
| 203 | +- [ ] Link |
| 204 | +- [ ] LinkOverlay |
| 205 | + |
| 206 | +### Media and Icons |
| 207 | +- [ ] Avatar |
| 208 | +- [ ] Icon |
| 209 | +- [ ] Image |
| 210 | + |
| 211 | +### Others |
| 212 | +- [ ] Portal |
| 213 | +- [ ] Transitions |
| 214 | + |
| 215 | +### Hooks |
| 216 | +- [ ] useBoolean |
| 217 | +- [ ] useBreakpointValue |
| 218 | +- [ ] useClipboard |
| 219 | +- [ ] useControllable |
| 220 | +- [ ] useDisclosure |
| 221 | +- [ ] useMediaQuery |
| 222 | +- [ ] useMergeRefs |
| 223 | +- [ ] useOutsideClick |
| 224 | +- [ ] usePrefersReducedMotion |
| 225 | +- [ ] useTheme |
| 226 | +- [ ] useToken |
| 227 | + |
| 228 | +# Contribution |
| 229 | +## Make a new component binding |
| 230 | +I'm use [hygen.io](https://hygen.io) for generate new component binding base on `Box.res`, see [\_templates/Box/new/new.ejs.t](./_templates/Box/new/new.ejs.t) |
| 231 | +USAGE: |
| 232 | +* basic |
| 233 | +```console |
| 234 | +hygen Box new --name Name |
| 235 | +``` |
| 236 | +* create `<Flex />` |
| 237 | +```console |
| 238 | +hygen Box new --name Flex |
| 239 | +``` |
| 240 | + |
| 241 | +# Acknowledgement |
| 242 | +* [**chakra-ui/chakra-ui**](https://github.com/chakra-ui/chakra-ui) ⚡️ Simple, Modular & Accessible UI Components for your React Applications |
| 243 | +* [**giraud/bs-css**](https://github.com/giraud/bs-css) Statically typed DSL for writing css in reason. |
0 commit comments