package miaou-core

  1. Overview
  2. Docs
Miaou core/widgets (no drivers, no SDL)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.5.2.tar.gz
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6

doc/src/miaou_widgets_layout/card_widget.ml.html

Source file card_widget.ml

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
31
32
33
34
35
36
37
38
39
40
41
42
(*****************************************************************************)
(*                                                                           *)
(* SPDX-License-Identifier: MIT                                              *)
(* Copyright (c) 2025 Nomadic Labs <contact@nomadic-labs.com>                *)
(* Copyright (c) 2026 Mathias Bourgoin <mathias.bourgoin@atacama.tech>       *)
(*                                                                           *)
(*****************************************************************************)

[@@@warning "-32-34-37-69"]

module W = Miaou_widgets_display.Widgets

type t = {
  title : string option;
  body : string;
  footer : string option;
  accent : int option;
      (** @deprecated Use semantic styling functions (themed_accent, themed_primary)
          in your title content instead of passing raw color codes. *)
}

let create ?title ?footer ?accent ~body () = {title; body; footer; accent}

let with_body t body = {t with body}

let render t ~cols =
  let title =
    match t.title with
    | Some s -> (
        match t.accent with
        | Some c ->
            (* Legacy: raw color code passed - kept for backwards compatibility *)
            W.fg c (W.bold s)
        | None ->
            (* Default: use themed emphasis for title *)
            W.themed_emphasis s)
    | None -> ""
  in
  let footer = match t.footer with Some f -> f | None -> "" in
  W.render_frame ~title ~body:t.body ~footer ~cols ()

let () = Miaou_registry.register ~name:"card" ~mli:[%blob "card_widget.mli"] ()