Module Skyline_menu_v2Source

A menu displays a list of actions in a popover. It can be attached to any element and triggered via click or right-click.

Example

  let menu = Skyline_menu_v2.controller graph in
  let options =
    let%arr action_1 and action_2 in
    {%html|
      <Skyline_menu_v2.Options.create>
        <Skyline_menu_v2.Options.item ~key:%{"action-1"} ~on_click:%{action_1}>
          Action 1
        </>
        <Skyline_menu_v2.Options.item ~key:%{"action-2"} ~on_click:%{action_2}>
          Action 2
        </>
      </>
    |}
  in
  let%arr menu and options in
  {%html|
    <div %{Skyline_menu_v2.on_contextmenu menu ~options:(Effect.return options)}>
      Right click on me!
    </div>
  |}
Sourcemodule Options : sig ... end

Menu options express a collection of actions. See Options for how to build the list of menu items.

Sourcemodule Position : sig ... end
Sourcemodule Alignment : sig ... end
Sourcemodule Open_at : sig ... end
Sourcemodule State : sig ... end
Sourcetype t = private {
  1. state : State.t;
  2. set_state : State.t -> unit Bonsai_web.Effect.t;
}

t holds the menu's state and a setter to control it.

  • state is the current state of the menu (open or closed)
  • set_state allows you to programmatically open or close the menu

Creates a menu t that can be attached to elements via on_click or on_contextmenu.

  • ?size controls the size of the menu items (defaults to `Md)
  • ?position sets the popover position relative to the anchor (defaults to Auto)
  • ?alignment sets the popover alignment relative to the anchor (defaults to Start)
  • ?state allows controlling the menu state externally
Sourceval on_click : ?open_at:Open_at.t -> t -> options:Options.t Bonsai_web.Effect.t -> Bonsai_web.Vdom.Attr.t

Creates an attr that binds an on_click event to open the menu.

  • ?open_at controls where the menu appears: Cursor positions it at the cursor location, Anchor positions it relative to the anchor element (default is Cursor)
Sourceval on_contextmenu : ?open_at:Open_at.t -> t -> options:Options.t Bonsai_web.Effect.t -> Bonsai_web.Vdom.Attr.t

Creates an attr that binds an on_contextmenu (right-click) event to open the menu.

  • ?open_at controls where the menu appears: Cursor positions it at the cursor location, Anchor positions it relative to the anchor element (default is Cursor)
Sourcemodule For_docs : sig ... end