package tw

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

Source file accessibility.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
43
44
45
46
47
48
(** Accessibility utilities

    What's included:
    - `forced-color-adjust-auto`, `forced-color-adjust-none` - Control forced
      color adjustment behavior.

    What's not:
    - Other accessibility properties beyond forced-color-adjust.

    Parsing contract (`of_string`):
    - Accepts ["forced"; "color"; "adjust"; "auto" | "none"]. Unknown tokens
      yield `Error (`Msg "Not an accessibility utility")`. *)

module Css = Cascade.Css
open Style

module Handler = struct
  type t = Auto | No_adjust

  let name = "accessibility"
  let priority _ = 36

  let to_class = function
    | Auto -> "forced-color-adjust-auto"
    | No_adjust -> "forced-color-adjust-none"

  let to_style _theme = function
    | Auto -> style [ Css.forced_color_adjust Css.Auto ]
    | No_adjust -> style [ Css.forced_color_adjust Css.None ]

  let suborder = function Auto -> 0 | No_adjust -> 1

  let of_class _theme class_name =
    let parts = Parse.split_class class_name in
    match parts with
    | [ "forced"; "color"; "adjust"; "auto" ] -> Ok Auto
    | [ "forced"; "color"; "adjust"; "none" ] -> Ok No_adjust
    | _ -> Error (`Msg "Not an accessibility utility")

  let examples = [ Auto ]
end

open Handler
module Utility_factory = Utility.Make (Handler)

let utility = Utility_factory.v
let forced_color_adjust_auto = utility Auto
let forced_color_adjust_none = utility No_adjust