aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/format/css/query.lux
blob: 7e2272c4a6d9b447387bc33ef0b78f64f55df986 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
(.using
 [library
  [lux {"-" and or not}
   [control
    [parser
     ["s" code]]]
   [data
    ["[0]" text
     ["%" format {"+" format}]]]
   [macro
    ["[0]" template]
    ["[0]" code]
    [syntax {"+" syntax:}]]
   [type
    [abstract {"-" pattern}]]]]
 ["[0]" // "_"
  ["[1][0]" value {"+" Value Length Count Resolution Ratio
                   Orientation Scan Boolean Update
                   Block_Overflow Inline_Overflow
                   Display_Mode Color_Gamut Inverted_Colors
                   Pointer Hover
                   Light Scripting Motion Color_Scheme}]])

(syntax: (text_symbol [symbol s.text])
  (in (list (code.local_symbol (text.replaced "-" "_" symbol)))))

(abstract: .public Media
  Text

  (def: .public media
    (-> Media Text)
    (|>> representation))

  (template [<media>]
    [(`` (def: .public (~~ (text_symbol <media>))
           Media
           (abstraction <media>)))]

    ["all"]
    ["print"]
    ["screen"]
    ["speech"]
    ))

(abstract: .public Feature
  Text

  (def: .public feature
    (-> Feature Text)
    (|>> representation))

  (template [<feature> <brand>]
    [(`` (def: .public ((~~ (text_symbol <feature>)) input)
           (-> (Value <brand>) Feature)
           (abstraction (format "(" <feature> ": " (//value.value input) ")"))))]

    ["min-color" Count]
    ["color" Count]
    ["max-color" Count]

    ["min-color-index" Count]
    ["color-index" Count]
    ["max-color-index" Count]

    ["min-monochrome" Count]
    ["monochrome" Count]
    ["max-monochrome" Count]

    ["min-height" Length]
    ["height" Length]
    ["max-height" Length]

    ["min-width" Length]
    ["width" Length]
    ["max-width" Length]

    ["min-resolution" Resolution]
    ["resolution" Resolution]
    ["max-resolution" Resolution]

    ["aspect-ratio" Ratio]
    ["max-aspect-ratio" Ratio]
    ["min-aspect-ratio" Ratio]

    ["display-mode" Display_Mode]
    ["color-gamut" Color_Gamut]
    ["grid" Boolean]
    ["orientation" Orientation]
    ["overflow-block" Block_Overflow]
    ["overflow-inline" Inline_Overflow]
    ["scan" Scan]
    ["update" Update]
    ["inverted-colors" Inverted_Colors]
    ["pointer" Pointer]
    ["any-pointer" Pointer]
    ["hover" Hover]
    ["any-hover" Hover]
    ["light-level" Light]
    ["scripting" Scripting]
    ["prefers-reduced-motion" Motion]
    ["prefers-color-scheme" Color_Scheme]
    )
  )

(abstract: .public Query
  Text

  (def: .public query
    (-> Query Text)
    (|>> representation))

  (template [<name> <operator>]
    [(def: .public <name>
       (-> Media Query)
       (|>> ..media (format <operator>) abstraction))]

    [except "not "]
    [only "only "]
    )

  (def: .public not
    (-> Feature Query)
    (|>> ..feature (format "not ") abstraction))

  (template [<name> <operator>]
    [(def: .public (<name> left right)
       (-> Query Query Query)
       (abstraction (format (representation left)
                            <operator>
                            (representation right))))]

    [and " and "]
    [or " or "]
    )
  )