package bonsai

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file tabs.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
open! Core
open! Import
module Style = Tabs_style

let make ~attrs ~per_tab_attr ~on_change ~equal ~active tabs =
  List.map tabs ~f:(fun (i, tab) ->
    let is_active = equal active i in
    let classes =
      if is_active then [ Style.tab_button; Style.selected ] else [ Style.tab_button ]
    in
    let on_click =
      Vdom.Attr.on_click (fun _ ->
        if equal i active then Effect.Ignore else on_change ~from:active ~to_:i)
    in
    Vdom.Node.div ~attrs:(classes @ [ on_click; per_tab_attr i ~is_active ]) [ tab ])
  |> View.hbox ~attrs:(Style.tab_container :: attrs) ~gap:(`Em_float 0.5)
;;
OCaml

Innovation. Community. Security.