1.3.2 ā€¢ Published 3 years ago

bs-rsuite-ui-react v1.3.2

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

ReasonML bindings for Rsuite UI React library

npm version

Official overview (bindings according it)

p.s bindings from an enthusiast šŸ™‚

Deprecated: https://www.npmjs.com/package/@sdv-studio/bs-rsuite-ui-react

use npm i bs-rsuite-ui-react instead npm i @sdv-studio/bs-rsuite-ui-react

Plans

  1. Cover all documented components āœ…
  2. Compare with official GitHub repo
  3. Check TODOs, fixes āŒ›
  4. Example project āœ…
  5. Improve DX (reuse, variants instead string as possible and etc.) āŒ›
  6. Tests, codegen

Roadmap

āœ… = done šŸŒ“ = not full support (temp) šŸ›‘ = unimplemented

TypeComponentStatus
General<Button />; <ButtonGroup />āœ…
General<Icon />; <IconButton />āœ…
General<Tooltip />āœ…
General<Popover />;<Whisper />āœ…
GeneralAlert moduleāœ…
GeneralNotification moduleāœ…
General<Message />āœ…
General<Loader />āœ…
General<Modal />āœ…
General<Drawer />āœ…
General<Alert />āœ…
General<Divider />āœ…
General<Progress />āœ…
General<Placeholder />āœ…
:-:------------------------------------
Navigation<Dropdown />āœ…
Navigation<Nav />āœ…
Navigation<Navbar />āœ…
Navigation<Sidenav />āœ…
Navigation<Steps />āœ…
Navigation<Pagination />āœ…
Navigation<Breadcrumb />āœ…
:-:------------------------------------:-:
Data Entry<Form />šŸŒ“
Data Entry<ControlLabel />āœ…
Data Entry<FormGroup />āœ…
Data Entry<FormControl />āœ…
Data Entry<HelpBlock />āœ…
Data Entry<Checkbox />āœ…
Data Entry<Radio />; <RadioGroup />āœ…
Data Entry<Input />āœ…
Data Entry<InputNumber />āœ…
Data Entry<AutoComplete />āœ…
Data Entry<Toggle />āœ…
Data Entry<InputPicker />āœ…
Data Entry<TagPicker />āœ…
Data Entry<SelectPicker />āœ…
Data Entry<CheckPicker />āœ…
Data Entry<Toggle />āœ…
Data Entry<TreePicker />āœ…
Data Entry<CheckTreePicker />āœ…
Data Entry<Cascader />āœ…
Data Entry<MultiCascader />āœ…
Data Entry<DatePicker />āœ…
Data Entry<DateRangePicker />āœ…
Data Entry<Slider />āœ…
Data Entry<Uploader />āœ…
:-:------------------------------------:-:
Data Display<Avatar />āœ…
Data Display<Badge />āœ…
Data Display<Table /> + Cell/Column/Headerāœ…
Data Display<Tree />āœ…
Data Display<CheckTree />āœ…
Data Display<Panel />āœ…
Data Display<Timeline />āœ…
Data Display<Tag />;<TagGroup/>āœ…
Data Display<List />āœ…
Data Display<Calendar />āœ…
Data Display<Carousel />āœ…
:-:------------------------------------:-:
Layout<Grid />; <Row />; <Col />āœ…
Layout<FlexboxGrid />āœ…
Layout<Container />āœ…
:-:------------------------------------:-:
Utils<Animation />āœ…
Utils<Portal />āœ…
UtilsSchema modulešŸ›‘
UtilsDOMHelper moduleāœ…
:-:------------------------------------:-:
Undocumented<SafeAnchor />āœ…

Installation

I. Add bs-rsuite-ui-react binding as dependency

npm i bs-rsuite-ui-react
or
yarn add bs-rsuite-ui-react
or
yarn add "https://github.com/shurygindv/bs-rsuite-ui-react.git"

II. Also we need to say bsb: heey, look! Seems, bs-rsuite-ui-react perfectly complements you, let's add it to bs-dependencies

...somewhere in your bsconfig.json:

  ...
      "bs-dependencies": [
        "reason-react",
        ...,
        "bs-rsuite-ui-react"
    ],
  ...

III. We would be to see a sea of colors, sky and sun, there are two ways to achieve it, import:

LESS

[%bs.raw {|require('rsuite/lib/styles/index.less')|}];

or as plain CSS

[%bs.raw {|require('rsuite/dist/styles/rsuite-default.css')|}];

Usage

All bindings are in RsuiteUi namespace, let's try! Some examples

Notification

 RsuiteUi.Notification._open(props); // props is RsuiteUi.Notification.Props.t
 RsuiteUi.Notification.closeAll();

 RsuiteUi.Notification.success(RsuiteUi.Notification.Props.make(
   ~title = React.string("I'm title"),
   ~description = React.string("I'm desc"),
   ~placement="bottomStart",
   ()
 ));

CheckPicker

 let item = RsuiteUi.RsuiteTypes.DataItemType.make(
  ~value = "value",
  ~label = React.string("value"),
  ()
 );

 <RsuiteUi.CheckPicker data={[|item|]} />

Animation

  let (isVisible, setVisibility) = React.useState(_ => false);

  React.useEffect0(_ => {
    Js.Global.setTimeout(_ => {
      setVisibility(_ => true);
    }, 200);
    None
  });

  <RsuiteUi.Animation.Bounce
    _in={isVisible}
  >
    <div>
      {React.string("look at me")}
    </div>
  </RsuiteUi.Animation.Bounce>

Table

  let items = [|{
    "name": "some name",
    "description": "some description"
  }, {
    "name": "some name",
    "description": "some description"
  }|];

  // where `dataKey` is keyof items (<Table.Cell dataKey={..}>)
  RsuiteUi.(
      <Table
          height={420}
          data={items}
          onSortColumn={(sortColumn, _sortType) => {
            Js.log(sortColumn);
          }}
        >
          <Table.Column width={50} align=`center>
            <Table.HeaderCell>
              {React.string("Name")}
            </Table.HeaderCell>

            <Table.Cell dataKey="name" />
          </Table.Column>

          <Table.Column width={100} flexGrow={2}>
            <Table.HeaderCell>
               {React.string("Description")}
            </Table.HeaderCell>

            <Table.Cell dataKey="description" />
          </Table.Column>
      </Table>
    );

Modal

  <RsuiteUi.Modal show={true}>
      <RsuiteUi.Modal.Header>
         {React.string("Header")}
      </RsuiteUi.Modal.Header>

       <RsuiteUi.Modal.Title>
         {React.string("Title")}
      </RsuiteUi.Modal.Title>

       <RsuiteUi.Modal.Body>
        {React.string("Body")}
      </RsuiteUi.Modal.Body>

      <RsuiteUi.Modal.Footer>
       {React.string("Footer")}
      </RsuiteUi.Modal.Footer>
  </RsuiteUi.Modal>

Caveats

I. Next components: <MultiCascader />, <Cascader />, <DatePicker />, Notification module have _open prop instead open

Example:

  <MultiCascader _open={true} />
  <Cascader _open={true} />
  <DatePicker _open={true} />


   Notification._open(...); // instead Notification.open()

II. _in instead in prop

   <RsuiteUi.Animation.Bounce _in={isVisible} />

   <RsuiteUi.Animation.Transition _in={isVisible} />

   <RsuiteUi.Animation.Slide _in={isVisible} />

III. Similar situation with <FlexboxGrid />; Sometimes we would be to use prop justify with end value, but we should use end_ instead

Example

  <FlexboxGrid justify=`end_ />
  <FlexboxGrid justify=`spaceAround />
  <FlexboxGrid justify=`center />

Contributions

It would be great, make our world better! All contributions are welcomed.

FAQ (just to save time...)

1. How can we pass Component as prop?

2. What the different between ReasonReact.string and React.string?

3. How can we pass string as child?

  • Use React.string("example") instead "example"

4. What _type, _open, _val, _in mean as Component prop?

5. Why do we use an array structure instead of a immutable list everywhere?

  • ReasonML lists are represented as nested 2-element arrays in JavaScript (an encoding of cons pairs).

And many other useful details about Reason React here! See: https://github.com/reasonml/reason-react/tree/master/docs

Good luck! šŸ™‚

1.3.2

3 years ago

1.3.0

3 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

0.2.0

5 years ago