aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/format/css/value.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/data/format/css/value.lux211
1 files changed, 112 insertions, 99 deletions
diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux
index a68d0b263..9b2de87f3 100644
--- a/stdlib/source/library/lux/data/format/css/value.lux
+++ b/stdlib/source/library/lux/data/format/css/value.lux
@@ -1,58 +1,59 @@
(.using
- [library
- [lux {"-" All Cursor and static false true}
- [control
- ["[0]" maybe]
- [parser
- ["s" code]]]
- [data
- ["[0]" color]
- ["[0]" product]
- [number
- ["n" nat]
- ["i" int]
- ["r" rev]
- ["f" frac]]
- ["[0]" text
- ["%" format {"+" Format format}]]
- [collection
- ["[0]" list ("[1]#[0]" functor)]]]
- [type
- abstract]
- [macro
- ["[0]" template]
- ["[0]" code]
- [syntax {"+" syntax:}]]
- [world
- [net {"+" URL}]]]]
- [//
- [selector {"+" Label}]])
-
-(syntax: (text_symbol [symbol s.text])
+ [library
+ [lux {"-" Label All Location and static false true}
+ [control
+ ["[0]" maybe]
+ [parser
+ ["<[0]>" code]]]
+ [data
+ ["[0]" color]
+ ["[0]" product]
+ ["[0]" text
+ ["%" format {"+" Format format}]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor)]]]
+ [macro
+ [syntax {"+" syntax:}]
+ ["[0]" template]
+ ["[0]" code]]
+ [math
+ [number
+ ["n" nat]
+ ["i" int]
+ ["r" rev]
+ ["f" frac]]]
+ [type
+ abstract]
+ [world
+ [net {"+" URL}]]]]
+ [//
+ [selector {"+" Label}]])
+
+(syntax: (text_symbol [symbol <code>.text])
(in (list (code.local_symbol (text.replaced "-" "_" symbol)))))
(template: (enumeration: <abstraction> <representation> <out> <sample>+ <definition>+)
- (abstract: .public <abstraction>
- <representation>
+ [(abstract: .public <abstraction>
+ <representation>
- (def: .public <out>
- (-> <abstraction> <representation>)
- (|>> :representation))
+ (def: .public <out>
+ (-> <abstraction> <representation>)
+ (|>> :representation))
- (`` (template [<name> <value>]
- [(def: .public <name> <abstraction> (:abstraction <value>))]
+ (`` (template [<name> <value>]
+ [(def: .public <name> <abstraction> (:abstraction <value>))]
- (~~ (template.spliced <sample>+))
- ))
+ (~~ (template.spliced <sample>+))
+ ))
- (template.spliced <definition>+)))
+ (template.spliced <definition>+))])
(template: (multi: <multi> <type> <separator>)
- (def: .public (<multi> pre post)
- (-> (Value <type>) (Value <type>) (Value <type>))
- (:abstraction (format (:representation pre)
- <separator>
- (:representation post)))))
+ [(def: .public (<multi> pre post)
+ (-> (Value <type>) (Value <type>) (Value <type>))
+ (:abstraction (format (:representation pre)
+ <separator>
+ (:representation post))))])
(def: (%number value)
(Format Frac)
@@ -75,7 +76,21 @@
[inherit "inherit"]
[unset "unset"]
)
-
+
+ (abstract: .public (Numeric kind) Any)
+
+ (template [<name>]
+ [(with_expansions [<name>' (template.symbol [<name> "'"])]
+ (abstract: .public <name>' Any)
+ (type: .public <name>
+ (Numeric <name>')))]
+
+ [Number]
+ [Length]
+ [Time]
+ [Percentage]
+ )
+
(template [<brand> <alias>+ <value>+]
[(abstract: .public <brand> Any)
@@ -98,18 +113,6 @@
[]
[]]
- [Number
- []
- []]
-
- [Length
- []
- []]
-
- [Time
- []
- []]
-
[Thickness
[]
[["medium"]
@@ -969,49 +972,41 @@
)
)
- (abstract: .public Percentage
- Text
+ (def: percentage_limit Nat (.++ 100))
- (def: .public percentage
- (-> Percentage Text)
- (|>> :representation))
+ (def: .public (%% value)
+ (-> Nat (Value Percentage))
+ (:abstraction (format (%.nat (n.% percentage_limit value)) "%")))
- (def: percentage_limit Nat (.++ 100))
-
- (def: .public (%% value)
- (-> Nat Percentage)
- (:abstraction (format (%.nat (n.% percentage_limit value)) "%")))
-
- (def: .public slice_percent/1
- (-> Percentage (Value Slice))
- (|>> :representation (:abstraction Value)))
-
- (def: .public (slice_percent/2 horizontal vertical)
- (-> Percentage Percentage (Value Slice))
- (:abstraction Value (format (:representation horizontal) ..slice_separator
- (:representation vertical))))
-
- (template [<input> <pre> <function>+]
- [(`` (template [<name> <function>]
- [(def: .public <name>
- (-> <input> (Value Filter))
- (|>> <pre> (list) (..apply <function>)))]
-
- (~~ (template.spliced <function>+))))]
-
- [Nat (<| (:representation Value) ..px n.frac)
- [[blur "blur"]]]
- [Nat (<| ..angle ..degree)
- [[hue_rotate "hue-rotate"]]]
- [Percentage (:representation Percentage)
- [[brightness "brightness"]
- [contrast "contrast"]
- [grayscale "grayscale"]
- [invert "invert"]
- [opacity "opacity"]
- [saturate "saturate"]
- [sepia "sepia"]]]
- )
+ (def: .public slice_percent/1
+ (-> (Value Percentage) (Value Slice))
+ (|>> :transmutation))
+
+ (def: .public (slice_percent/2 horizontal vertical)
+ (-> (Value Percentage) (Value Percentage) (Value Slice))
+ (:abstraction (format (:representation horizontal) ..slice_separator
+ (:representation vertical))))
+
+ (template [<input> <pre> <function>+]
+ [(`` (template [<name> <function>]
+ [(def: .public <name>
+ (-> <input> (Value Filter))
+ (|>> <pre> (list) (..apply <function>)))]
+
+ (~~ (template.spliced <function>+))))]
+
+ [Nat (<| :representation ..px n.frac)
+ [[blur "blur"]]]
+ [Nat (<| ..angle ..degree)
+ [[hue_rotate "hue-rotate"]]]
+ [(Value Percentage) :representation
+ [[brightness "brightness"]
+ [contrast "contrast"]
+ [grayscale "grayscale"]
+ [invert "invert"]
+ [opacity "opacity"]
+ [saturate "saturate"]
+ [sepia "sepia"]]]
)
(def: .public svg_filter
@@ -1329,4 +1324,22 @@
(multi: multi_image Image ",")
(multi: multi_shadow Shadow ",")
(multi: multi_content Content " ")
+
+ ... https://developer.mozilla.org/en-US/docs/Web/CSS/calc()
+ (template [<name> <parameter>]
+ [(def: .public (<name> parameter subject)
+ (.All (_ kind)
+ (-> (Value <parameter>) (Value (Numeric kind))
+ (Value (Numeric kind))))
+ (|> (format (:representation subject)
+ (template.text [" " <name> " "])
+ (:representation parameter))
+ (text.enclosed ["calc(" ")"])
+ :abstraction))]
+
+ [+ (Numeric kind)]
+ [- (Numeric kind)]
+ [* Number]
+ [/ Number]
+ )
)