summaryrefslogtreecommitdiff
path: root/bs5/universal/native/shared/Button.re
blob: 653b7d7a7d8002398bd08bbdaf96c16e4599ac0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
open Melange_json.Primitives;

[@react.client.component]
let make = (~noteId: option(int), ~children: React.element) => {
  let (isPending, startTransition) = React.useTransition();
  let {navigate, _}: ClientRouter.t = ClientRouter.useRouter();
  let isDraft = Belt.Option.isNone(noteId);

  let className =
    Cx.make([
      Theme.button,
      isDraft ? "edit-button--solid" : "edit-button--outline",
    ]);

  <button
    className
    disabled=isPending
    onClick={_ => {
      startTransition(() => {
        navigate({
          selectedId: noteId,
          isEditing: true,
          searchText: None,
        })
      })
    }}
    role="menuitem">
    children
  </button>;
};