diff --git a/bin/ui_playlist.ml b/bin/ui_playlist.ml index 5ffa99c..784690b 100644 --- a/bin/ui_playlist.ml +++ b/bin/ui_playlist.ml @@ -9,12 +9,14 @@ module Api = DS.Api (** Columns declaration *) let columns () = - Table.Columns. - [| - v "Order" "5rem" @@ [ `P (El.txt' "#") ]; - v "Cover" "5rem" @@ [ `P (El.txt' "Cover") ]; - v "Title" "1fr" @@ [ `P (El.txt' "Title") ]; - |] + Lwd.pure + @@ Lwd_seq.of_array + Table.Columns. + [| + v "Order" "5rem" @@ [ `P (El.txt' "#") ]; + v "Cover" "5rem" @@ [ `P (El.txt' "Cover") ]; + v "Title" "1fr" @@ [ `P (El.txt' "Title") ]; + |] let make ~reset_playlist ~fetch ?scroll_target (view : Lwd_view.ordered) = let ranged = diff --git a/vendor/brr_lwd_ui/lib/table/schema.ml b/vendor/brr_lwd_ui/lib/table/schema.ml index e41626a..e2f98b2 100644 --- a/vendor/brr_lwd_ui/lib/table/schema.ml +++ b/vendor/brr_lwd_ui/lib/table/schema.ml @@ -4,30 +4,31 @@ open Brr_lwd module Columns = struct type column = { name : string; css_size : string; content : Elwd.t Elwd.col } - type t = column array + type t = column Lwd_seq.t Lwd.t let v name css_size content = { name; css_size; content } let to_header t = - let cells = - Array.fold_right t ~init:[] ~f:(fun { content; _ } acc -> - `R (Elwd.div content) :: acc) - in - cells + Lwd_seq.fold_monoid + (fun { content; _ } -> Lwd_seq.element (Elwd.div content)) + Lwd_seq.monoid t let style t = - let template = - Array.to_string ~sep:" " (fun { css_size; _ } -> css_size) t + let open Lwd_infix in + let$ template = + Lwd_seq.fold_monoid + (fun { css_size; _ } -> css_size) + ("", fun s s' -> Printf.sprintf "%s %s" s s') + t in + Printf.sprintf "%s: %s;" "grid-template-columns" template end type t = { columns : Columns.t } type fixed_row_height = { table : t; row_height : Utils.Unit.t } -let style t = - let style = Columns.style t.table.columns in - String.concat ~sep:" " [ style ] +let style t = Columns.style t.table.columns let header t = let row_height = Utils.Unit.to_string t.row_height in @@ -38,6 +39,6 @@ let header t = `P (At.class' (Jstr.v "lwdui-virtual-table-row")); ] in - Elwd.div ~at @@ Columns.to_header t.table.columns + Elwd.div ~at [ `S (Columns.to_header t.table.columns |> Lwd_seq.lift) ] let _ = Utils.Unit.to_px (Rem 4.) diff --git a/vendor/brr_lwd_ui/lib/table/virtual_table.ml b/vendor/brr_lwd_ui/lib/table/virtual_table.ml index a1c2dea..2ea679c 100644 --- a/vendor/brr_lwd_ui/lib/table/virtual_table.ml +++ b/vendor/brr_lwd_ui/lib/table/virtual_table.ml @@ -288,8 +288,8 @@ let make (type data) ~(ui_table : Schema.fixed_row_height) let table = let at = Attrs.to_at @@ Attrs.classes [ "lwdui-lazy-table" ] in let grid_style = Schema.style ui_table in - let s = At.style (Jstr.v @@ grid_style) in - let at = `P s :: at in + let s = Lwd.map grid_style ~f:(fun s -> At.style (Jstr.v s)) in + let at = `R s :: at in Elwd.div ~at [ `R table_header; `R wrapper ] in table diff --git a/vendor/brr_lwd_ui/lib/table/virtual_table_bis.ml b/vendor/brr_lwd_ui/lib/table/virtual_table_bis.ml index eff0de1..732a1a6 100644 --- a/vendor/brr_lwd_ui/lib/table/virtual_table_bis.ml +++ b/vendor/brr_lwd_ui/lib/table/virtual_table_bis.ml @@ -312,8 +312,8 @@ let make (type data) ~(ui_table : Schema.fixed_row_height) let table = let at = Attrs.to_at @@ Attrs.classes [ "lwdui-lazy-table" ] in let grid_style = Schema.style ui_table in - let s = At.style (Jstr.v @@ grid_style) in - let at = `P s :: at in + let s = Lwd.map grid_style ~f:(fun s -> At.style (Jstr.v s)) in + let at = `R s :: at in Elwd.div ~at [ `R table_header; `R wrapper ] in table