Merge function-builder branch into master

This commit is contained in:
2021-05-11 09:04:49 +02:00
parent 4730e6d3d7
commit d1094bddef
82 changed files with 2542 additions and 1062 deletions

View File

@@ -5,13 +5,13 @@ class AlignContent(
) : CssProperty(value) {
companion object {
fun stretch() = AlignContent("stretch")
fun center() = AlignContent("center")
fun flexStart() = AlignContent("flex-start")
fun flexEnd() = AlignContent("flex-end")
fun spaceBetween() = AlignContent("space-between")
fun spaceAround() = AlignContent("space-around")
fun initial() = AlignContent("initial")
fun inherit() = AlignContent("inherit")
val stretch = AlignContent("stretch")
val center = AlignContent("center")
val flexStart = AlignContent("flex-start")
val flexEnd = AlignContent("flex-end")
val spaceBetween = AlignContent("space-between")
val spaceAround = AlignContent("space-around")
val initial = AlignContent("initial")
val inherit = AlignContent("inherit")
}
}

View File

@@ -2,16 +2,16 @@ package nl.astraeus.css.properties
class AlignItems(
value: String
) : CssProperty(value) {
): CssProperty(value) {
companion object {
fun stretch() = AlignItems("stretch")
fun center() = AlignItems("center")
fun flexStart() = AlignItems("flex-start")
fun flexEnd() = AlignItems("flex-end")
fun baseline() = AlignItems("baseline")
fun initial() = AlignItems("initial")
fun inherit() = AlignItems("inherit")
val stretch = AlignItems("stretch")
val center = AlignItems("center")
val flexStart = AlignItems("flex-start")
val flexEnd = AlignItems("flex-end")
val baseline = AlignItems("baseline")
val initial = AlignItems("initial")
val inherit = AlignItems("inherit")
}
}

View File

@@ -2,16 +2,17 @@ package nl.astraeus.css.properties
class AlignSelf(
value: String
) : CssProperty(value) {
): CssProperty(value) {
companion object {
fun auto() = AlignSelf("auto")
fun stretch() = AlignSelf("stretch")
fun center() = AlignSelf("center")
fun flexStart() = AlignSelf("flex-start")
fun flexEnd() = AlignSelf("flex-end")
fun baseline() = AlignSelf("baseline")
fun initial() = AlignSelf("initial")
fun inherit() = AlignSelf("inherit")
val auto = AlignSelf("auto")
val stretch = AlignSelf("stretch")
val center = AlignSelf("center")
val flexStart = AlignSelf("flex-start")
val flexEnd = AlignSelf("flex-end")
val baseline = AlignSelf("baseline")
val initial = AlignSelf("initial")
val inherit = AlignSelf("inherit")
}
}

View File

@@ -2,13 +2,13 @@ package nl.astraeus.css.properties
class All(
value: String
) : CssProperty(value) {
): CssProperty(value) {
companion object {
fun initial() = All("initial")
fun inherit() = All("inherit")
fun unset() = All("unset")
fun revert() = All("revert")
val unset = All("unset")
val revert = All("revert")
val initial = All("initial")
val inherit = All("inherit")
}
}

View File

@@ -5,12 +5,12 @@ class AnimationDirection(
) : CssProperty(value) {
companion object {
fun normal() = AnimationDirection("normal")
fun reverse() = AnimationDirection("reverse")
fun alternate() = AnimationDirection("alternate")
fun alternateReverse() = AnimationDirection("alternate-reverse")
fun initial() = AnimationDirection("initial")
fun inherit() = AnimationDirection("inherit")
val normal = AnimationDirection("normal")
val reverse = AnimationDirection("reverse")
val alternate = AnimationDirection("alternate")
val alternateReverse = AnimationDirection("alternate-reverse")
val initial = AnimationDirection("initial")
val inherit = AnimationDirection("inherit")
}
}
@@ -19,12 +19,12 @@ class AnimationFillMode(
) : CssProperty(value) {
companion object {
fun none() = AnimationFillMode("none")
fun forwards() = AnimationFillMode("forwards")
fun backwards() = AnimationFillMode("backwards")
fun both() = AnimationFillMode("both")
fun initial() = AnimationFillMode("initial")
fun inherit() = AnimationFillMode("inherit")
val none = AnimationFillMode("none")
val forwards = AnimationFillMode("forwards")
val backwards = AnimationFillMode("backwards")
val both = AnimationFillMode("both")
val initial = AnimationFillMode("initial")
val inherit = AnimationFillMode("inherit")
}
}
@@ -33,10 +33,10 @@ class AnimationFrame(
): CssProperty(value) {
companion object {
fun name(name: String): AnimationFrame = AnimationFrame(name)
fun none(): AnimationFrame = AnimationFrame("none")
fun initial(): AnimationFrame = AnimationFrame("initial")
fun inherit(): AnimationFrame = AnimationFrame("inherit")
fun name(name: String) = AnimationFrame(name)
val none: AnimationFrame = AnimationFrame("none")
val initial: AnimationFrame = AnimationFrame("initial")
val inherit: AnimationFrame = AnimationFrame("inherit")
}
}
@@ -47,31 +47,9 @@ class AnimationPlayState(
companion object {
fun name(name: String) = AnimationPlayState(name)
fun paused() = AnimationPlayState("paused")
fun running() = AnimationPlayState("running")
fun initial() = AnimationPlayState("initial")
fun inherit() = AnimationPlayState("inherit")
}
}
class AnimationTimingFunction(
value: String = ""
) : CssProperty(value) {
companion object {
fun linear() = AnimationTimingFunction("linear")
fun ease() = AnimationTimingFunction("ease")
fun easeIn() = AnimationTimingFunction("ease-in")
fun easeOut() = AnimationTimingFunction("ease-out")
fun easeInOut() = AnimationTimingFunction("ease-in-out")
fun cubicBezier(
n1: Double,
n2: Double,
n3: Double,
n4: Double
) = AnimationTimingFunction("cubic-bezier($n1,$n2,$n3,$n4)")
fun initial() = AnimationTimingFunction("initial")
fun inherit() = AnimationTimingFunction("inherit")
val paused = AnimationPlayState("paused")
val running = AnimationPlayState("running")
val initial = AnimationPlayState("initial")
val inherit = AnimationPlayState("inherit")
}
}

View File

@@ -5,9 +5,9 @@ class BackfaceVisibility(
) : CssProperty(value) {
companion object {
fun visible() = BackfaceVisibility("visible")
fun hidden() = BackfaceVisibility("hidden")
fun initial() = BackfaceVisibility("initial")
fun inherit() = BackfaceVisibility("inherit")
val visible = BackfaceVisibility("visible")
val hidden = BackfaceVisibility("hidden")
val initial = BackfaceVisibility("initial")
val inherit = BackfaceVisibility("inherit")
}
}

View File

@@ -5,11 +5,11 @@ class BackgroundAttachment(
) : CssProperty(value) {
companion object {
fun scroll() = BackgroundAttachment("scroll")
fun fixed() = BackgroundAttachment("fixed")
fun local() = BackgroundAttachment("local")
fun initial() = BackgroundAttachment("initial")
fun inherit() = BackgroundAttachment("inherit")
val scroll = BackgroundAttachment("scroll")
val fixed = BackgroundAttachment("fixed")
val local = BackgroundAttachment("local")
val initial = BackgroundAttachment("initial")
val inherit = BackgroundAttachment("inherit")
}
}
@@ -18,16 +18,16 @@ class BackgroundBlendMode(
) : CssProperty(value) {
companion object {
fun normal() = BackgroundBlendMode("normal")
fun multiply() = BackgroundBlendMode("multiply")
fun screen() = BackgroundBlendMode("screen")
fun overlay() = BackgroundBlendMode("overlay")
fun darken() = BackgroundBlendMode("darken")
fun lighten() = BackgroundBlendMode("lighten")
fun colorDodge() = BackgroundBlendMode("color-dodge")
fun saturation() = BackgroundBlendMode("saturation")
fun color() = BackgroundBlendMode("color")
fun luminosity() = BackgroundBlendMode("luminosity")
val normal = BackgroundBlendMode("normal")
val multiply = BackgroundBlendMode("multiply")
val screen = BackgroundBlendMode("screen")
val overlay = BackgroundBlendMode("overlay")
val darken = BackgroundBlendMode("darken")
val lighten = BackgroundBlendMode("lighten")
val colorDodge = BackgroundBlendMode("color-dodge")
val saturation = BackgroundBlendMode("saturation")
val color = BackgroundBlendMode("color")
val luminosity = BackgroundBlendMode("luminosity")
}
}
@@ -36,12 +36,11 @@ class BackgroundPosition(
) : CssProperty(value) {
companion object {
fun left() = BackgroundPosition("left")
fun center() = BackgroundPosition("center")
fun right() = BackgroundPosition("right")
fun initial() = BackgroundPosition("initial")
fun inherit() = BackgroundPosition("inherit")
val left = BackgroundPosition("left")
val center = BackgroundPosition("center")
val right = BackgroundPosition("right")
val initial = BackgroundPosition("initial")
val inherit = BackgroundPosition("inherit")
}
}
@@ -50,15 +49,15 @@ class BackgroundRepeat(
) : CssProperty(value) {
companion object {
fun repeat() = BackgroundRepeat("repeat")
fun repeatX() = BackgroundRepeat("repeat-x")
fun repeatY() = BackgroundRepeat("repeat-y")
fun noRepeat() = BackgroundRepeat("no-repeat")
fun space() = BackgroundRepeat("space")
fun round() = BackgroundRepeat("round")
fun initial() = BackgroundRepeat("initial")
fun inherit() = BackgroundRepeat("inherit")
fun unset() = BackgroundRepeat("unset")
val repeat = BackgroundRepeat("repeat")
val repeatX = BackgroundRepeat("repeat-x")
val repeatY = BackgroundRepeat("repeat-y")
val noRepeat = BackgroundRepeat("no-repeat")
val space = BackgroundRepeat("space")
val round = BackgroundRepeat("round")
val initial = BackgroundRepeat("initial")
val inherit = BackgroundRepeat("inherit")
val unset = BackgroundRepeat("unset")
}
}
@@ -69,11 +68,12 @@ class BackgroundSize(
companion object {
fun px(px: Int) = BackgroundSize("${px}px")
fun perc(pc: Double) = BackgroundSize("${pc}%")
fun auto() = BackgroundSize("auto")
fun cover() = BackgroundSize("cover")
fun contain() = BackgroundSize("contain")
fun initial() = BackgroundSize("initial")
fun inherit() = BackgroundSize("inherit")
val auto = BackgroundSize("auto")
val cover = BackgroundSize("cover")
val contain = BackgroundSize("contain")
val initial = BackgroundSize("initial")
val inherit = BackgroundSize("inherit")
}
}

View File

@@ -3,17 +3,6 @@ package nl.astraeus.css.properties
class BorderRadius(
value: String
): CssProperty(value) {
constructor(topLeft: Int, topRight: Int, bottomRight: Int, bottomLeft: Int): this(
"${topLeft}px ${topRight}px ${bottomRight}px ${bottomLeft}px"
)
constructor(topLeft: Int, topRightBottomLeft: Int, bottomRight: Int): this(
"${topLeft}px ${topRightBottomLeft}px ${bottomRight}px"
)
constructor(topLeftBottomRight: Int, topRightBottomLeft: Int): this(
"${topLeftBottomRight}px ${topRightBottomLeft}px"
)
constructor(radius: Int): this("${radius}px")
companion object {
fun px(nr: Int) = BorderRadius("${nr}px")
fun em(nr: Int) = BorderRadius("${nr}em")
@@ -24,28 +13,28 @@ class BorderRadius(
fun pc(nr: Double) = BorderRadius("${nr}pc")
fun cm(nr: Int) = BorderRadius("${nr}cm")
fun cm(nr: Double) = BorderRadius("${nr}cm")
fun initial() = BorderRadius("initial")
fun inherit() = BorderRadius("inherit")
val initial = BorderRadius("initial")
val inherit = BorderRadius("inherit")
}
}
class RuleBorderStyle(
class BorderStyle(
value: String
): CssProperty(value) {
companion object {
fun none() = RuleBorderStyle("none")
fun hidden() = RuleBorderStyle("hidden")
fun dotted() = RuleBorderStyle("dotted")
fun dashed() = RuleBorderStyle("dashed")
fun solid() = RuleBorderStyle("solid")
fun double() = RuleBorderStyle("double")
fun groove() = RuleBorderStyle("groove")
fun ridge() = RuleBorderStyle("ridge")
fun inset() = RuleBorderStyle("inset")
fun outset() = RuleBorderStyle("outset")
fun initial() = RuleBorderStyle("initial")
fun inherit() = RuleBorderStyle("inherit")
val none = BorderStyle("none")
val hidden = BorderStyle("hidden")
val dotted = BorderStyle("dotted")
val dashed = BorderStyle("dashed")
val solid = BorderStyle("solid")
val double = BorderStyle("double")
val groove = BorderStyle("groove")
val ridge = BorderStyle("ridge")
val inset = BorderStyle("inset")
val outset = BorderStyle("outset")
val initial = BorderStyle("initial")
val inherit = BorderStyle("inherit")
}
}
@@ -54,22 +43,11 @@ class BorderWidth(
): CssProperty(value) {
companion object {
fun thin() = BorderWidth("thin")
fun medium() = BorderWidth("medium")
fun thick() = BorderWidth("thick")
fun px(nr: Int) = BorderWidth("${nr}px")
fun em(nr: Int) = BorderWidth("${nr}em")
fun em(nr: Double) = BorderWidth("${nr}em")
fun perc(nr: Int) = BorderWidth("${nr}%")
fun perc(nr: Double) = BorderWidth("${nr}%")
fun pc(nr: Int) = BorderWidth("${nr}pc")
fun pc(nr: Double) = BorderWidth("${nr}pc")
fun cm(nr: Int) = BorderWidth("${nr}cm")
fun cm(nr: Double) = BorderWidth("${nr}cm")
fun initial() = BorderWidth("initial")
fun inherit() = BorderWidth("inherit")
val thin = BorderWidth("thin")
val medium = BorderWidth("medium")
val thick = BorderWidth("thick")
val initial = BorderWidth("initial")
val inherit = BorderWidth("inherit")
}
}
@@ -78,8 +56,8 @@ class BorderCollapse(
): CssProperty(value) {
companion object {
fun separate() = BorderWidth("separate")
fun collapse() = BorderWidth("collapse")
val separate = BorderCollapse("separate")
val collapse = BorderCollapse("collapse")
}
}
@@ -88,13 +66,13 @@ class BorderImageWidth (
): CssProperty(value) {
companion object {
fun px(nr: Int) = BorderRadius("${nr}px")
fun nr(nr: Int) = Image("$nr")
fun perc(nr: Int) = BorderRadius("${nr}%")
fun perc(nr: Double) = BorderRadius("${nr}%")
fun auto() = BorderWidth("auto")
fun initial() = BorderWidth("initial")
fun inherit() = BorderWidth("inherit")
fun px(nr: Int) = BorderImageWidth("${nr}px")
fun nr(nr: Int) = BorderImageWidth("$nr")
fun perc(nr: Int) = BorderImageWidth("${nr}%")
fun perc(nr: Double) = BorderImageWidth("${nr}%")
val auto = BorderImageWidth("auto")
val initial = BorderImageWidth("initial")
val inherit = BorderImageWidth("inherit")
}
}
@@ -103,16 +81,16 @@ class BorderSpacing(
): CssProperty(value) {
companion object {
fun px(nr: Int) = BorderRadius("${nr}px")
fun em(nr: Int) = BorderRadius("${nr}em")
fun em(nr: Double) = BorderRadius("${nr}em")
fun perc(nr: Int) = BorderRadius("${nr}%")
fun perc(nr: Double) = BorderRadius("${nr}%")
fun pc(nr: Int) = BorderRadius("${nr}pc")
fun pc(nr: Double) = BorderRadius("${nr}pc")
fun cm(nr: Int) = BorderRadius("${nr}cm")
fun cm(nr: Double) = BorderRadius("${nr}cm")
fun initial() = BorderRadius("initial")
fun inherit() = BorderRadius("inherit")
fun px(nr: Int) = BorderSpacing("${nr}px")
fun em(nr: Int) = BorderSpacing("${nr}em")
fun em(nr: Double) = BorderSpacing("${nr}em")
fun perc(nr: Int) = BorderSpacing("${nr}%")
fun perc(nr: Double) = BorderSpacing("${nr}%")
fun pc(nr: Int) = BorderSpacing("${nr}pc")
fun pc(nr: Double) = BorderSpacing("${nr}pc")
fun cm(nr: Int) = BorderSpacing("${nr}cm")
fun cm(nr: Double) = BorderSpacing("${nr}cm")
val initial = BorderSpacing("initial")
val inherit = BorderSpacing("inherit")
}
}

View File

@@ -5,11 +5,11 @@ class BoxDecorationBreak(
): CssProperty(value) {
companion object {
fun slice() = BorderWidth("slice")
fun clone() = BorderWidth("clone")
fun initial() = BorderWidth("initial")
fun inherit() = BorderWidth("inherit")
fun unset() = BorderWidth("unset")
val slice = BoxDecorationBreak("slice")
val clone = BoxDecorationBreak("clone")
val initial = BoxDecorationBreak("initial")
val inherit = BoxDecorationBreak("inherit")
val unset = BoxDecorationBreak("unset")
}
}
@@ -18,11 +18,12 @@ class BoxShadow(
): CssProperty(value) {
companion object {
fun none() = BoxShadow("none")
val none = BoxShadow("none")
val inset = BoxShadow("inset")
val initial = BoxShadow("initial")
val inherit = BoxShadow("inherit")
fun text(txt: String) = BoxShadow(txt)
fun inset() = BoxShadow("inset")
fun initial() = BoxShadow("initial")
fun inherit() = BoxShadow("inherit")
}
}
@@ -31,9 +32,9 @@ class BoxSizing(
): CssProperty(value) {
companion object {
fun contextBox() = BoxSizing("content-box")
fun borderBox() = BoxSizing("border-box")
fun initial() = BoxShadow("initial")
fun inherit() = BoxShadow("inherit")
val contextBox = BoxSizing("content-box")
val borderBox = BoxSizing("border-box")
val initial = BoxShadow("initial")
val inherit = BoxShadow("inherit")
}
}

View File

@@ -6,22 +6,22 @@ class Break(
): CssProperty(value) {
companion object {
fun auto() = Break("auto")
fun all() = Break("all")
fun always() = Break("always")
fun avoid() = Break("avoid")
fun avoidColumn() = Break("avoid-column")
fun avoidPage() = Break("avoid-page")
fun avoidRegion() = Break("avoid-region")
fun column() = Break("column")
fun left() = Break("left")
fun page() = Break("page")
fun recto() = Break("recto")
fun region() = Break("region")
fun right() = Break("right")
fun verso() = Break("verso")
fun initial() = Break("initial")
fun inherit() = Break("inherit")
val auto = Break("auto")
val all = Break("all")
val always = Break("always")
val avoid = Break("avoid")
val avoidColumn = Break("avoid-column")
val avoidPage = Break("avoid-page")
val avoidRegion = Break("avoid-region")
val column = Break("column")
val left = Break("left")
val page = Break("page")
val recto = Break("recto")
val region = Break("region")
val right = Break("right")
val verso = Break("verso")
val initial = Break("initial")
val inherit = Break("inherit")
}
}

View File

@@ -5,10 +5,10 @@ class CaptionSide(
): CssProperty(value) {
companion object {
fun top() = BoxSizing("top")
fun bottom() = BoxSizing("bottom")
fun initial() = BoxShadow("initial")
fun inherit() = BoxShadow("inherit")
val top = CaptionSide("top")
val bottom = CaptionSide("bottom")
val initial = CaptionSide("initial")
val inherit = CaptionSide("inherit")
}
}

View File

@@ -6,12 +6,12 @@ class Clear(
): CssProperty(value) {
companion object {
fun none() = Clear("none")
fun left() = Clear("left")
fun right() = Clear("right")
fun both() = Clear("both")
fun initial() = Clear("initial")
fun inherit() = Clear("inherit")
val none = Clear("none")
val left = Clear("left")
val right = Clear("right")
val both = Clear("both")
val initial = Clear("initial")
val inherit = Clear("inherit")
}
}

View File

@@ -5,10 +5,10 @@ class Clip(
) : CssProperty(value) {
companion object {
fun auto() = Clip("auto")
fun rect(top: Int, right: Int, bottom: Int, left: Int) = Clip("rect(${top}px,${right}px,${bottom}px,${left}px)")
fun initial() = Clip("initial")
fun inherit() = Clip("inherit")
val auto = Clip("auto")
val initial = Clip("initial")
val inherit = Clip("inherit")
}
}
@@ -18,7 +18,7 @@ class ClipPath(
) : CssProperty(value) {
companion object {
fun auto() = ClipPath("auto")
val auto = ClipPath("auto")
fun circle(perc: Double) = ClipPath("circle(${perc}%)")
fun ellipse(radiusX: Double, radiusY: Double) = ClipPath("ellipse(${radiusX}%,${radiusY}%)")
fun ellipse(
@@ -27,15 +27,18 @@ class ClipPath(
positionX: Double,
positionY: Double
) = ClipPath("ellipse(${radiusX}%,${radiusY}% at ${positionX}%,${positionY}%)")
// todo: other options
fun marginBox() = ClipPath("margin-box")
fun borderBox() = ClipPath("border-box")
fun paddingBox() = ClipPath("padding-box")
fun contentBox() = ClipPath("content-box")
fun fillBox() = ClipPath("fill-box")
fun strokeBox() = ClipPath("stroke-box")
fun viewBox() = ClipPath("view-box")
fun none() = ClipPath("none")
fun other(text: String) = ClipPath(text)
val marginBox = ClipPath("margin-box")
val borderBox = ClipPath("border-box")
val paddingBox = ClipPath("padding-box")
val contentBox = ClipPath("content-box")
val fillBox = ClipPath("fill-box")
val strokeBox = ClipPath("stroke-box")
val viewBox = ClipPath("view-box")
val none = ClipPath("none")
}
}
@@ -44,11 +47,11 @@ class ClipOrigin(
) : CssProperty(value) {
companion object {
fun borderBox() = ClipOrigin("border-box")
fun paddingBox() = ClipOrigin("padding-box")
fun contentBox() = ClipOrigin("content-box")
fun initial() = ClipOrigin("initial")
fun inherit() = ClipOrigin("inherit")
val borderBox = ClipOrigin("border-box")
val paddingBox = ClipOrigin("padding-box")
val contentBox = ClipOrigin("content-box")
val initial = ClipOrigin("initial")
val inherit = ClipOrigin("inherit")
}
}

View File

@@ -1,36 +1,500 @@
package nl.astraeus.css.properties
class Color(
value: String
) : CssProperty(value) {
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.roundToInt
companion object {
fun auto() = Color("auto")
fun transparant() = Color("transparant")
fun initial() = Color("initial")
fun inherit() = Color("inherit")
fun hex(hex: String) = Color("#$hex")
fun rgb(
red: Int,
green: Int,
blue: Int
) = Color("rgb($red, $green, $blue)")
fun rgba(
red: Int,
green: Int,
blue: Int,
alpha: Double
) = Color("rgba($red, $green, $blue, $alpha)")
fun hsl(
hue: Int,
saturation: Int,
lightness: Int
) = Color("hsl($hue, $saturation, $lightness)")
fun hsla(
hue: Int,
saturation: Int,
lightness: Int,
alpha: Double
) = Color("hsla($hue, $saturation, $lightness, $alpha)")
/**
* See [CSS Color Module Level 3](https://www.w3.org/TR/2018/REC-css-color-3-20180619/)
*
* This class represents a CSS color value. String parameters to the constructor argument
* can take one of the following forms:
*
* * HTML color name, e.g. ``Red``, ``DarkSalmon`` (case-insensitive), though in this case the use of the pre-defined constants is recommended.
* * ``#rgb`` or ``#rrggbb``
* * ``rgb(0..255, 0..255, 0..255)``, ``rgb(0..100%, 0..100%, 0..100%)``, ``rgb(0..100%, 0..100%, 0..100%, 0..1)``, ``rgba(0..255, 0..255, 0..255, 0..1)``
* * ``hsl(0..360, 0-100%, 0..100%)`` or ``hsla(0..360, 0-100%, 0..100%, 0..1)``
*
* Technically, the Hue parameter to ``hsl`` or ``hsla`` can exceed ``360``, because it represents a *degree* (angle) on
* the color wheel. But as per the algorithm proposed by the W3C, the value will ultimately be capped to ``360`` through
* a series of modulus operations; see section *4.2.4. HSL color values* of the above specification.
*
* Taken from: https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-css
*/
@Suppress("SpellCheckingInspection")
class Color(value: String) : CssProperty(value) {
private var rgb: String? = null
private constructor(value: String, rgb: String) : this(value) {
this.rgb = rgb
}
companion object {
val initial = Color("initial")
val inherit = Color("inherit")
val unset = Color("unset")
val transparent = Color("transparent")
val currentColor = Color("currentColor")
// W3C predefined HTML colors (147), see the referenced specification above.
val aliceBlue = Color("aliceblue", "#f0f8ff")
val antiqueWhite = Color("antiquewhite", "#faebd7")
val aqua = Color("aqua", "#00ffff")
val aquamarine = Color("aquamarine", "#7fffd4")
val azure = Color("azure", "#f0ffff")
val beige = Color("beige", "#f5f5dc")
val bisque = Color("bisque", "#ffe4c4")
val black = Color("black", "#000000")
val blanchedAlmond = Color("blanchedalmond", "#ffebcd")
val blue = Color("blue", "#0000ff")
val blueViolet = Color("blueviolet", "#8a2be2")
val brown = Color("brown", "#a52a2a")
val burlyWood = Color("burlywood", "#deb887")
val cadetBlue = Color("cadetblue", "#5f9ea0")
val chartreuse = Color("chartreuse", "#7fff00")
val chocolate = Color("chocolate", "#d2691e")
val coral = Color("coral", "#ff7f50")
val cornflowerBlue = Color("cornflowerblue", "#6495ed")
val cornsilk = Color("cornsilk", "#fff8dc")
val crimson = Color("crimson", "#dc143c")
val cyan = Color("cyan", "#00ffff")
val darkBlue = Color("darkblue", "#00008b")
val darkCyan = Color("darkcyan", "#008b8b")
val darkGoldenrod = Color("darkgoldenrod", "#b8860b")
val darkGray = Color("darkgray", "#a9a9a9")
val darkGreen = Color("darkgreen", "#006400")
val darkGrey = Color("darkgrey", "#a9a9a9")
val darkKhaki = Color("darkkhaki", "#bdb76b")
val darkMagenta = Color("darkmagenta", "#8b008b")
val darkOliveGreen = Color("darkolivegreen", "#556b2f")
val darkOrange = Color("darkorange", "#ff8c00")
val darkOrchid = Color("darkorchid", "#9932cc")
val darkRed = Color("darkred", "#8b0000")
val darkSalmon = Color("darksalmon", "#e9967a")
val darkSeaGreen = Color("darkseagreen", "#8fbc8f")
val darkSlateBlue = Color("darkslateblue", "#483d8b")
val darkSlateGray = Color("darkslategray", "#2f4f4f")
val darkSlateGrey = Color("darkslategrey", "#2f4f4f")
val darkTurquoise = Color("darkturquoise", "#00ced1")
val darkViolet = Color("darkviolet", "#9400d3")
val deepPink = Color("deeppink", "#ff1493")
val deepSkyBlue = Color("deepskyblue", "#00bfff")
val dimGray = Color("dimgray", "#696969")
val dimGrey = Color("dimgrey", "#696969")
val dodgerBlue = Color("dodgerblue", "#1e90ff")
val firebrick = Color("firebrick", "#b22222")
val floralWhite = Color("floralwhite", "#fffaf0")
val forestGreen = Color("forestgreen", "#228b22")
val fuchsia = Color("fuchsia", "#ff00ff")
val gainsboro = Color("gainsboro", "#dcdcdc")
val ghostWhite = Color("ghostwhite", "#f8f8ff")
val gold = Color("gold", "#ffd700")
val goldenrod = Color("goldenrod", "#daa520")
val gray = Color("gray", "#808080")
val green = Color("green", "#008000")
val greenYellow = Color("greenyellow", "#adff2f")
val grey = Color("grey", "#808080")
val honeydew = Color("honeydew", "#f0fff0")
val hotPink = Color("hotpink", "#ff69b4")
val indianRed = Color("indianred", "#cd5c5c")
val indigo = Color("indigo", "#4b0082")
val ivory = Color("ivory", "#fffff0")
val khaki = Color("khaki", "#f0e68c")
val lavender = Color("lavender", "#e6e6fa")
val lavenderBlush = Color("lavenderblush", "#fff0f5")
val lawnGreen = Color("lawngreen", "#7cfc00")
val lemonChiffon = Color("lemonchiffon", "#fffacd")
val lightBlue = Color("lightblue", "#add8e6")
val lightCoral = Color("lightcoral", "#f08080")
val lightCyan = Color("lightcyan", "#e0ffff")
val lightGoldenrodYellow = Color("lightgoldenrodyellow", "#fafad2")
val lightGray = Color("lightgray", "#d3d3d3")
val lightGreen = Color("lightgreen", "#90ee90")
val lightGrey = Color("lightgrey", "#d3d3d3")
val lightPink = Color("lightpink", "#ffb6c1")
val lightSalmon = Color("lightsalmon", "#ffa07a")
val lightSeaGreen = Color("lightseagreen", "#20b2aa")
val lightSkyBlue = Color("lightskyblue", "#87cefa")
val lightSlateGray = Color("lightslategray", "#778899")
val lightSlateGrey = Color("lightslategrey", "#778899")
val lightSteelBlue = Color("lightsteelblue", "#b0c4de")
val lightYellow = Color("lightyellow", "#ffffe0")
val lime = Color("lime", "#00ff00")
val limeGreen = Color("limegreen", "#32cd32")
val linen = Color("linen", "#faf0e6")
val magenta = Color("magenta", "#ff00ff")
val maroon = Color("maroon", "#800000")
val mediumAquamarine = Color("mediumaquamarine", "#66cdaa")
val mediumBlue = Color("mediumblue", "#0000cd")
val mediumOrchid = Color("mediumorchid", "#ba55d3")
val mediumPurple = Color("mediumpurple", "#9370d8")
val mediumSeaGreen = Color("mediumseagreen", "#3cb371")
val mediumSlateBlue = Color("mediumslateblue", "#7b68ee")
val mediumSpringGreen = Color("mediumspringgreen", "#00fa9a")
val mediumTurquoise = Color("mediumturquoise", "#48d1cc")
val mediumVioletRed = Color("mediumvioletred", "#c71585")
val midnightBlue = Color("midnightblue", "#191970")
val mintCream = Color("mintcream", "#f5fffa")
val mistyRose = Color("mistyrose", "#ffe4e1")
val moccasin = Color("moccasin", "#ffe4b5")
val navajoWhite = Color("navajowhite", "#ffdead")
val navy = Color("navy", "#000080")
val oldLace = Color("oldlace", "#fdf5e6")
val olive = Color("olive", "#808000")
val oliveDrab = Color("olivedrab", "#6b8e23")
val orange = Color("orange", "#ffa500")
val orangeRed = Color("orangered", "#ff4500")
val orchid = Color("orchid", "#da70d6")
val paleGoldenrod = Color("palegoldenrod", "#eee8aa")
val paleGreen = Color("palegreen", "#98fb98")
val paleTurquoise = Color("paleturquoise", "#afeeee")
val paleVioletRed = Color("palevioletred", "#db7093")
val papayaWhip = Color("papayawhip", "#ffefd5")
val peachPuff = Color("peachpuff", "#ffdab9")
val peru = Color("peru", "#cd853f")
val pink = Color("pink", "#ffc0cb")
val plum = Color("plum", "#dda0dd")
val powderBlue = Color("powderblue", "#b0e0e6")
val purple = Color("purple", "#800080")
val red = Color("red", "#ff0000")
val rosyBrown = Color("rosybrown", "#bc8f8f")
val royalBlue = Color("royalblue", "#4169e1")
val saddleBrown = Color("saddlebrown", "#8b4513")
val salmon = Color("salmon", "#fa8072")
val sandyBrown = Color("sandybrown", "#f4a460")
val seaGreen = Color("seagreen", "#2e8b57")
val seaShell = Color("seashell", "#fff5ee")
val sienna = Color("sienna", "#a0522d")
val silver = Color("silver", "#c0c0c0")
val skyBlue = Color("skyblue", "#87ceeb")
val slateBlue = Color("slateblue", "#6a5acd")
val slateGray = Color("slategray", "#708090")
val slateGrey = Color("slategrey", "#708090")
val snow = Color("snow", "#fffafa")
val springGreen = Color("springgreen", "#00ff7f")
val steelBlue = Color("steelblue", "#4682b4")
val tan = Color("tan", "#d2b48c")
val teal = Color("teal", "#008080")
val thistle = Color("thistle", "#d8bfd8")
val tomato = Color("tomato", "#ff6347")
val turquoise = Color("turquoise", "#40e0d0")
val violet = Color("violet", "#ee82ee")
val wheat = Color("wheat", "#f5deb3")
val white = Color("white", "#ffffff")
val whiteSmoke = Color("whitesmoke", "#f5f5f5")
val yellow = Color("yellow", "#ffff00")
val yellowGreen = Color("yellowgreen", "#9acd32")
fun normalizeFractionalPercent(value: Double): Double =
value.coerceIn(minimumValue = 0.0, maximumValue = 1.0)
fun normalizePercent(value: Int): Int =
value.coerceIn(minimumValue = 0, maximumValue = 100)
fun normalizeRGB(value: Int): Int =
value.coerceIn(minimumValue = 0, maximumValue = 255)
// algorithm for capping from W3C
fun normalizeHue(value: Double): Int =
(((value % 360) + 360) % 360).roundToInt()
fun normalizeAlpha(value: Double): Double =
normalizeFractionalPercent(value)
// Match for hsl(int, int%, int%) | hsla(int, int%, int%, 0.5) | etc.
private val HSLA_REGEX by lazy {
Regex(
"^hsla?\\((-?[0-9]+\\.?[0-9]*(?:deg|grad|rad|turn)?)\\s*[, ]?\\s*(\\d{1,3})%\\s*[, ]\\s*(\\d{1,3})%\\s*[, ]?\\s*(\\d|(?:\\d?\\.\\d+))?\\)\$",
RegexOption.IGNORE_CASE
)
}
// Match for rgb(255, 255, 255) | rgba(255, 255, 255, 0.5) | rgb(100% 100% 100%) | etc.
private val RGBA_REGEX by lazy {
Regex(
"^rgba?\\((\\d{1,3}%?)\\s*[, ]\\s*(\\d{1,3}%?)\\s*[, ]\\s*(\\d{1,3}%?)[, ]?\\s*(\\d|(?:\\d?\\.\\d+))?\\)\$",
RegexOption.IGNORE_CASE
)
}
}
/**
* withAlpha preserves existing alpha value: rgba(0, 0, 0, 0.5).withAlpha(0.1) = rgba(0, 0, 0, 0.05)
*/
fun withAlpha(alpha: Double) =
when {
value.startsWith("hsl", true) -> with(fromHSLANotation()) { hsla(hue, saturation, lightness, normalizeAlpha(alpha) * this.alpha) }
else -> with(toRGBA()) { rgba(red, green, blue, normalizeAlpha(alpha) * this.alpha) }
}
/**
* changeAlpha rewrites existing alpha value: rgba(0, 0, 0, 0.5).withAlpha(0.1) = rgba(0, 0, 0, 0.1)
*/
fun changeAlpha(alpha: Double) =
when {
value.startsWith("hsl", true) -> with(fromHSLANotation()) { hsla(hue, saturation, lightness, normalizeAlpha(alpha)) }
else -> with(toRGBA()) { rgba(red, green, blue, normalizeAlpha(alpha)) }
}
// https://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb
fun blend(backgroundColor: Color): Color {
val source = this.toRGBA()
val background = backgroundColor.toRGBA()
val targetR = ((1 - source.alpha) * background.red) + (source.alpha * source.red)
val targetG = ((1 - source.alpha) * background.green) + (source.alpha * source.green)
val targetB = ((1 - source.alpha) * background.blue) + (source.alpha * source.blue)
return rgb(targetR.roundToInt(), targetG.roundToInt(), targetB.roundToInt())
}
/**
* Lighten the color by the specified percent (between 0-100), returning a new instance of Color.
*
* @param percent the percent to lighten the Color
* @return a new lightened version of this color
*/
fun lighten(percent: Int): Color {
val isHSLA = value.startsWith("hsl", ignoreCase = true)
val hsla = if (isHSLA) fromHSLANotation() else toRGBA().asHSLA()
val lightness = hsla.lightness + (hsla.lightness * (normalizePercent(percent) / 100.0)).roundToInt()
val newHSLa = hsla.copy(lightness = normalizePercent(lightness))
return if (isHSLA) {
hsla(newHSLa.hue, newHSLa.saturation, newHSLa.lightness, newHSLa.alpha)
} else {
with(newHSLa.asRGBA()) { rgba(red, green, blue, alpha) }
}
}
/**
* Darken the color by the specified percent (between 0-100), returning a new instance of Color.
*
* @param percent the percent to darken the Color
* @return a new darkened version of this color
*/
fun darken(percent: Int): Color {
val isHSLA = value.startsWith("hsl", ignoreCase = true)
val hsla = if (isHSLA) fromHSLANotation() else toRGBA().asHSLA()
val darkness = hsla.lightness - (hsla.lightness * (normalizePercent(percent) / 100.0)).roundToInt()
val newHSLa = hsla.copy(lightness = normalizePercent(darkness))
return if (isHSLA) {
hsla(newHSLa.hue, newHSLa.saturation, newHSLa.lightness, newHSLa.alpha)
} else {
with(newHSLa.asRGBA()) { rgba(red, green, blue, alpha) }
}
}
/**
* Increase contrast, if lightness > 50 then darken else lighten
*
* @param percent the percent to lighten/darken the Color
* @return a new ligtened/darkened version of this color
*/
fun contrast(percent: Int): Color {
val isHSLA = value.startsWith("hsl", ignoreCase = true)
val hsla = if (isHSLA) fromHSLANotation() else toRGBA().asHSLA()
val darkness = if (hsla.lightness > 50) {
hsla.lightness - (hsla.lightness * (normalizePercent(percent) / 100.0)).roundToInt()
} else {
hsla.lightness + (hsla.lightness * (normalizePercent(percent) / 100.0)).roundToInt()
}
val newHSLa = hsla.copy(lightness = normalizePercent(darkness))
return if (isHSLA) {
hsla(newHSLa.hue, newHSLa.saturation, newHSLa.lightness, newHSLa.alpha)
} else {
with(newHSLa.asRGBA()) { rgba(red, green, blue, alpha) }
}
}
/**
* Saturate the color by the specified percent (between 0-100), returning a new instance of Color.
*
* @param percent the percent to saturate the Color
* @return a new saturated version of this color
*/
fun saturate(percent: Int): Color {
val isHSLA = value.startsWith("hsl", ignoreCase = true)
val hsla = if (isHSLA) fromHSLANotation() else toRGBA().asHSLA()
val saturation = hsla.saturation + (hsla.saturation * (normalizePercent(percent) / 100.0)).roundToInt()
val newHSLa = hsla.copy(saturation = normalizePercent(saturation))
return if (isHSLA) {
hsla(newHSLa.hue, newHSLa.saturation, newHSLa.lightness, newHSLa.alpha)
} else {
with(newHSLa.asRGBA()) { rgba(red, green, blue, alpha) }
}
}
/**
* Desaturate the color by the specified percent (between 0-100), returning a new instance of Color.
*
* @param percent the percent to desaturate the Color
* @return a new desaturated version of this color
*/
fun desaturate(percent: Int): Color {
val isHSLA = value.startsWith("hsl", ignoreCase = true)
val hsla = if (isHSLA) fromHSLANotation() else toRGBA().asHSLA()
val desaturation = hsla.saturation - (hsla.saturation * (normalizePercent(percent) / 100.0)).roundToInt()
val newHSLa = hsla.copy(saturation = normalizePercent(desaturation))
return if (isHSLA) {
hsla(newHSLa.hue, newHSLa.saturation, newHSLa.lightness, newHSLa.alpha)
} else {
with(newHSLa.asRGBA()) { rgba(red, green, blue, alpha) }
}
}
internal data class RGBA(
val red: Int,
val green: Int,
val blue: Int,
val alpha: Double = 1.0
) {
// Algorithm adapted from http://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/
fun asHSLA(): HSLA {
// scale R, G, B values into 0..1 fractions
val r = red / 255.0
val g = green / 255.0
val b = blue / 255.0
val cMax = maxOf(r, g, b)
val cMin = minOf(r, g, b)
val chroma = cMax - cMin
val lg = normalizeFractionalPercent((cMax + cMin) / 2)
val s = if (chroma != 0.0) normalizeFractionalPercent(chroma / (1.0 - abs((2.0 * lg) - 1.0))) else 0.0
val h = when (cMax) {
cMin -> 0.0
r -> 60 * (((g - b) / chroma) % 6.0)
g -> 60 * (((b - r) / chroma) + 2)
b -> 60 * (((r - g) / chroma) + 4)
else -> error("Unexpected value for max") // theoretically unreachable bc maxOf(r, g, b) above
}
return HSLA(normalizeHue(h), (s * 100).roundToInt(), (lg * 100).roundToInt(), alpha)
}
}
internal data class HSLA(
val hue: Int,
val saturation: Int,
val lightness: Int,
val alpha: Double = 1.0
) {
// Algorithm from W3C link referenced in class comment (section 4.2.4. HSL color values)
fun asRGBA(): RGBA {
fun hueToRGB(m1: Double, m2: Double, h: Double): Double {
val hu = if (h < 0) h + 1 else if (h > 1) h - 1 else h
return when {
(hu < 1.0 / 6) -> m1 + (m2 - m1) * 6 * hu
(hu < 1.0 / 2) -> m2
(hu < 2.0 / 3) -> m1 + ((m2 - m1) * 6 * (2.0 / 3 - hu))
else -> m1
}
}
if (saturation == 0) return RGBA(lightness, lightness, lightness)
// scale H, S, V values into 0..1 fractions
val h = (hue % 360.0) / 360.0
val s = saturation / 100.0
val lg = lightness / 100.0
val m2 = if (lg < 0.5) lg * (1 + s) else (lg + s - lg * s)
val m1 = 2 * lg - m2
val r = normalizeFractionalPercent(hueToRGB(m1, m2, h + (1.0 / 3)))
val g = normalizeFractionalPercent(hueToRGB(m1, m2, h))
val b = normalizeFractionalPercent(hueToRGB(m1, m2, h - (1.0 / 3)))
return RGBA((r * 255).roundToInt(), (g * 255).roundToInt(), (b * 255).roundToInt(), alpha)
}
}
internal fun fromHSLANotation(): HSLA {
val match = HSLA_REGEX.find(value)
fun getHSLParameter(index: Int) =
match?.groups?.get(index)?.value
?: throw IllegalArgumentException("Expected hsl or hsla notation, got $value")
val hueShape = getHSLParameter(1)
val hue = normalizeHue(
when {
hueShape.endsWith("grad", true) -> hueShape.substringBefore("grad").toDouble() * (9.0 / 10)
hueShape.endsWith("rad", true) -> (hueShape.substringBefore("rad").toDouble() * 180) / PI
hueShape.endsWith("turn", true) -> hueShape.substringBefore("turn").toDouble() * 360.0
hueShape.endsWith("deg", true) -> hueShape.substringBefore("deg").toDouble()
else -> hueShape.toDouble()
}
)
val saturation = normalizePercent(getHSLParameter(2).toInt())
val lightness = normalizePercent(getHSLParameter(3).toInt())
val alpha = normalizeAlpha(match?.groups?.get(4)?.value?.toDouble() ?: 1.0)
return HSLA(hue, saturation, lightness, alpha)
}
internal fun fromRGBANotation(): RGBA {
val match = RGBA_REGEX.find(value)
fun getRGBParameter(index: Int): Int {
val group = match?.groups?.get(index)?.value
?: throw IllegalArgumentException("Expected rgb or rgba notation, got $value")
return when {
(group.endsWith('%')) -> (normalizeFractionalPercent(group.substringBefore('%').toDouble() / 100.0) * 255.0).toInt()
else -> normalizeRGB(group.toInt())
}
}
val red = getRGBParameter(1)
val green = getRGBParameter(2)
val blue = getRGBParameter(3)
val alpha = normalizeAlpha(match?.groups?.get(4)?.value?.toDouble() ?: 1.0)
return RGBA(red, green, blue, alpha)
}
internal fun toRGBA(): RGBA {
val v = rgb ?: value
return when {
v.startsWith("rgb") -> fromRGBANotation()
// Matches #rgb
v.startsWith("#") && v.length == 4 -> RGBA(
"${v[1]}${v[1]}".toInt(16),
"${v[2]}${v[2]}".toInt(16),
"${v[3]}${v[3]}".toInt(16)
)
// Matches both #rrggbb and #rrggbbaa
v.startsWith("#") && (v.length == 7 || v.length == 9) -> RGBA(
(v.substring(1..2)).toInt(16),
(v.substring(3..4)).toInt(16),
(v.substring(5..6)).toInt(16)
)
else -> throw IllegalArgumentException("Only hexadecimal, rgb, and rgba notations are accepted, got $v")
}
}
}
private fun String.withZeros() = this + "0".repeat(max(0, 3 - this.length))
fun hex(value: Int) = Color("#${value.toString(16).withZeros()}")
fun rgb(red: Int, green: Int, blue: Int) = Color("rgb($red, $green, $blue)")
fun rgba(red: Int, green: Int, blue: Int, alpha: Double) = Color("rgba($red, $green, $blue, ${formatAlpha(alpha)})")
fun hsl(hue: Int, saturation: Int, lightness: Int) = Color("hsl($hue, $saturation%, $lightness%)")
fun hsla(hue: Int, saturation: Int, lightness: Int, alpha: Double) = Color("hsla($hue, $saturation%, $lightness%, ${formatAlpha(alpha)})")
fun blackAlpha(alpha: Double) = Color.black.withAlpha(alpha)
fun whiteAlpha(alpha: Double) = Color.white.withAlpha(alpha)
private fun formatAlpha(alpha: Double): String =
alpha.toString().let {
if ("." in it) it else "$it.0"
}

View File

@@ -14,8 +14,8 @@ class Length(
fun pc(nr: Double) = Length("${nr}pc")
fun cm(nr: Int) = Length("${nr}cm")
fun cm(nr: Double) = Length("${nr}cm")
fun initial() = Length("initial")
fun inherit() = Length("inherit")
val initial = Length("initial")
val inherit = Length("inherit")
}
}
@@ -25,9 +25,9 @@ class Fill(
) : CssProperty(value) {
companion object {
fun balance() = Fill("balance")
fun auto() = Fill("auto")
fun initial() = Fill("initial")
fun inherit() = Fill("inherit")
val balance = Fill("balance")
val auto = Fill("auto")
val initial = Fill("initial")
val inherit = Fill("inherit")
}
}

View File

@@ -5,18 +5,19 @@ class Content(
) : CssProperty(value) {
companion object {
fun normal() = Content("normal")
fun none() = Content("none")
fun counter() = Content("counter")
val normal = Content("normal")
val none = Content("none")
val counter = Content("counter")
val openQuote = Content("open-quote")
val closeQuote = Content("close-quote")
val noOpenQuote = Content("no-open-quote")
val noCloseQuote = Content("no-close-quote")
val initial = Content("initial")
val inherit = Content("inherit")
fun attr(attribute: String) = Content("attr($attribute)")
fun string(txt: String) = Content("\"$txt\"")
fun openQuote() = Content("open-quote")
fun closeQuote() = Content("close-quote")
fun noOpenQuote() = Content("no-open-quote")
fun noCloseQuote() = Content("no-close-quote")
fun url(url: String) = Content("url($url)")
fun initial() = Content("initial")
fun inherit() = Content("inherit")
}
}

View File

@@ -5,15 +5,11 @@ class Count(
) : CssProperty(value) {
companion object {
fun count(number: Int): Count =
Count("$number")
fun auto(): Count =
Count("auto")
fun infinite(): Count =
Count("infinite")
fun initial(): Count =
Count("initial")
fun inherit(): Count =
Count("inherit")
val auto: Count = Count("auto")
val infinite: Count = Count("infinite")
val initial: Count = Count("initial")
val inherit: Count = Count("inherit")
fun count(number: Int): Count = Count("$number")
}
}

View File

@@ -0,0 +1,15 @@
package nl.astraeus.css.properties
class CssFloat(
value: String
) : CssProperty(value) {
companion object {
val none = CssFloat("none")
val left = CssFloat("left")
val right = CssFloat("right")
val initial = CssFloat("initial")
val inherit = CssFloat("inherit")
}
}

View File

@@ -1,10 +1,14 @@
package nl.astraeus.css.properties
open class CssProperty(
val value: String
) {
interface CssValue {
fun css(): String
}
fun css(): String = value
open class CssProperty(
var value: String
): CssValue {
override fun css(): String = value
}

View File

@@ -5,8 +5,10 @@ class DelayDuration(
) : CssProperty(value) {
companion object {
val initial = DelayDuration("initial")
val inherit = DelayDuration("inherit")
fun seconds(seconds: Int) = DelayDuration("${seconds}s")
fun initial() = DelayDuration("initial")
fun inherit() = DelayDuration("inherit")
fun millis(milliSeconds: Int) = DelayDuration("${milliSeconds}ms")
}
}

View File

@@ -5,10 +5,10 @@ class Direction(
) : CssProperty(value) {
companion object {
fun ltr() = Direction("ltr")
fun rtl() = Direction("rtl")
fun initial() = Direction("initial")
fun inherit() = Direction("inherit")
val ltr = Direction("ltr")
val rtl = Direction("rtl")
val initial = Direction("initial")
val inherit = Direction("inherit")
}
}

View File

@@ -5,29 +5,29 @@ class Display(
) : CssProperty(value) {
companion object {
fun inline() = Display("inline")
fun block() = Display("block")
fun contents() = Display("contents")
fun flex() = Display("flex")
fun grid() = Display("grid")
fun inlineBlock() = Display("inline-block")
fun inlineFlex() = Display("inline-flex")
fun inlineGrid() = Display("inline-grid")
fun inlineTable() = Display("inline-table")
fun listItem() = Display("list-item")
fun runIn() = Display("run-in")
fun table() = Display("table")
fun tableCaption() = Display("table-caption")
fun tableColumnGroup() = Display("table-column-group")
fun tableHeaderGroup() = Display("table-header-group")
fun tableFooterGroup() = Display("table-footer-group")
fun tableRowGroup() = Display("table-row-group")
fun tableCell() = Display("table-cell")
fun tableColumn() = Display("table-column")
fun tableRow() = Display("table-row")
fun none() = Display("none")
fun initial() = Display("initial")
fun inherit() = Display("inherit")
val inline = Display("inline")
val block = Display("block")
val contents = Display("contents")
val flex = Display("flex")
val grid = Display("grid")
val inlineBlock = Display("inline-block")
val inlineFlex = Display("inline-flex")
val inlineGrid = Display("inline-grid")
val inlineTable = Display("inline-table")
val listItem = Display("list-item")
val runIn = Display("run-in")
val table = Display("table")
val tableCaption = Display("table-caption")
val tableColumnGroup = Display("table-column-group")
val tableHeaderGroup = Display("table-header-group")
val tableFooterGroup = Display("table-footer-group")
val tableRowGroup = Display("table-row-group")
val tableCell = Display("table-cell")
val tableColumn = Display("table-column")
val tableRow = Display("table-row")
val none = Display("none")
val initial = Display("initial")
val inherit = Display("inherit")
}
}

View File

@@ -5,10 +5,10 @@ class EmptyCells(
) : CssProperty(value) {
companion object {
fun show() = EmptyCells("show")
fun hide() = EmptyCells("hide")
fun initial() = EmptyCells("initial")
fun inherit() = EmptyCells("inherit")
val show = EmptyCells("show")
val hide = EmptyCells("hide")
val initial = EmptyCells("initial")
val inherit = EmptyCells("inherit")
}
}

View File

@@ -5,12 +5,12 @@ class FlexDirection(
) : CssProperty(value) {
companion object {
fun row() = FlexDirection("row")
fun rowReverse() = FlexDirection("row-reverse")
fun column() = FlexDirection("column")
fun columnReverse() = FlexDirection("column-reverse")
fun initial() = FlexDirection("initial")
fun inherit() = FlexDirection("inherit")
val row = FlexDirection("row")
val rowReverse = FlexDirection("row-reverse")
val column = FlexDirection("column")
val columnReverse = FlexDirection("column-reverse")
val initial = FlexDirection("initial")
val inherit = FlexDirection("inherit")
}
}
@@ -20,9 +20,10 @@ class FlexGrowShrink(
) : CssProperty(value) {
companion object {
fun number(number: Int) = FlexDirection("$number")
fun initial() = FlexDirection("initial")
fun inherit() = FlexDirection("inherit")
val initial = FlexGrowShrink("initial")
val inherit = FlexGrowShrink("inherit")
fun number(number: Int) = FlexGrowShrink("$number")
}
}
@@ -32,11 +33,11 @@ class FlexWrap(
) : CssProperty(value) {
companion object {
fun nowrap() = FlexWrap("nowrap")
fun wrap() = FlexWrap("wrap")
fun wrapReverse() = FlexWrap("wrap-reverse")
fun initial() = FlexWrap("initial")
fun inherit() = FlexWrap("inherit")
val nowrap = FlexWrap("nowrap")
val wrap = FlexWrap("wrap")
val wrapReverse = FlexWrap("wrap-reverse")
val initial = FlexWrap("initial")
val inherit = FlexWrap("inherit")
}
}

View File

@@ -1,15 +0,0 @@
package nl.astraeus.css.properties
class Float(
value: String
) : CssProperty(value) {
companion object {
fun none() = Float("none")
fun left() = Float("left")
fun right() = Float("right")
fun initial() = Float("initial")
fun inherit() = Float("inherit")
}
}

View File

@@ -5,17 +5,18 @@ class FontSize(
) : CssProperty(value) {
companion object {
fun xxSmall() = FontSize("xx-small")
fun xSmall() = FontSize("x-small")
fun small() = FontSize("small")
fun medium() = FontSize("medium")
fun large() = FontSize("large")
fun xLarge() = FontSize("x-large")
fun xxLarge() = FontSize("xx-large")
fun smaller() = FontSize("smaller")
fun larger() = FontSize("larger")
fun initial() = FontSize("initial")
fun inherit() = FontSize("inherit")
val xxSmall = FontSize("xx-small")
val xSmall = FontSize("x-small")
val small = FontSize("small")
val medium = FontSize("medium")
val large = FontSize("large")
val xLarge = FontSize("x-large")
val xxLarge = FontSize("xx-large")
val smaller = FontSize("smaller")
val larger = FontSize("larger")
val initial = FontSize("initial")
val inherit = FontSize("inherit")
fun px(nr: Int) = FontSize("${nr}px")
fun em(nr: Int) = FontSize("${nr}em")
fun em(nr: Double) = FontSize("${nr}em")
@@ -26,6 +27,7 @@ class FontSize(
fun cm(nr: Int) = FontSize("${nr}cm")
fun cm(nr: Double) = FontSize("${nr}cm")
}
}
class FontStretch(
@@ -33,15 +35,17 @@ class FontStretch(
) : CssProperty(value) {
companion object {
fun normal() = FontStretch("normal")
fun condensed() = FontStretch("condensed")
fun ultraCondensed() = FontStretch("ultra-condensed")
fun extraCondensed() = FontStretch("extra-condensed")
fun semiCondensed() = FontStretch("semi-condensed")
fun expanded() = FontStretch("expanded")
fun semiExpanded() = FontStretch("semi-expanded")
fun extraExpanded() = FontStretch("extra-expanded")
fun ultraExpanded() = FontStretch("ultra-expanded")
val normal = FontStretch("normal")
val condensed = FontStretch("condensed")
val ultraCondensed = FontStretch("ultra-condensed")
val extraCondensed = FontStretch("extra-condensed")
val semiCondensed = FontStretch("semi-condensed")
val expanded = FontStretch("expanded")
val semiExpanded = FontStretch("semi-expanded")
val extraExpanded = FontStretch("extra-expanded")
val ultraExpanded = FontStretch("ultra-expanded")
val initial = FontWeight("initial")
val inherit = FontWeight("inherit")
}
}
@@ -51,9 +55,11 @@ class FontStyle(
) : CssProperty(value) {
companion object {
fun normal() = FontStyle("normal")
fun italic() = FontStyle("italic")
fun oblique() = FontStyle("oblique")
val normal = FontStyle("normal")
val italic = FontStyle("italic")
val oblique = FontStyle("oblique")
val initial = FontStyle("initial")
val inherit = FontStyle("inherit")
}
}
@@ -63,18 +69,74 @@ class FontWeight(
) : CssProperty(value) {
companion object {
fun normal() = FontWeight("normal")
fun bold() = FontWeight("bold")
fun _100() = FontWeight("100")
fun _200() = FontWeight("200")
fun _300() = FontWeight("300")
fun _400() = FontWeight("400")
fun _500() = FontWeight("500")
fun _600() = FontWeight("600")
fun _700() = FontWeight("700")
fun _800() = FontWeight("800")
fun _900() = FontWeight("900")
val normal = FontWeight("normal")
val bold = FontWeight("bold")
val _100 = FontWeight("100")
val _200 = FontWeight("200")
val _300 = FontWeight("300")
val _400 = FontWeight("400")
val _500 = FontWeight("500")
val _600 = FontWeight("600")
val _700 = FontWeight("700")
val _800 = FontWeight("800")
val _900 = FontWeight("900")
val initial = FontWeight("initial")
val inherit = FontWeight("inherit")
}
}
class FontKerning(
value: String
) : CssProperty(value) {
companion object {
val auto = FontKerning("auto")
val normal = FontKerning("normal")
val none = FontKerning("none")
}
}
class FontSizeAdjust(
value: String
) : CssProperty(value) {
companion object {
val none = FontSizeAdjust("none")
val initial = FontSizeAdjust("initial")
val inherit = FontSizeAdjust("inherit")
}
}
class FontVariant(
value: String
) : CssProperty(value) {
companion object {
val normal = FontVariant("normal")
val smallCaps = FontVariant("small-caps")
val initial = FontVariant("initial")
val inherit = FontVariant("inherit")
}
}
class FontVariantCaps(
value: String
) : CssProperty(value) {
companion object {
val normal = FontVariantCaps("normal")
val smallCaps = FontVariantCaps("small-caps")
val allSmallCaps = FontVariantCaps("all-small-caps")
val petiteCaps = FontVariantCaps("petite-caps")
val allPetiteCaps = FontVariantCaps("all-petite-caps")
val unicase = FontVariantCaps("unicase")
val initial = FontVariantCaps("initial")
val inherit = FontVariantCaps("inherit")
val unset = FontVariantCaps("unset")
}
}

View File

@@ -0,0 +1,72 @@
package nl.astraeus.css.properties
class Grid(
value: String
) : CssProperty(value) {
companion object {
val none = Grid("none")
val initial = Grid("initial")
val inherit = Grid("inherit")
}
}
class GridAuto(
value: String
) : CssProperty(value) {
companion object {
val auto = GridAuto("auto")
val maxContent = GridAuto("max-content")
val minContent = GridAuto("min-content")
}
}
class GridFlow(
value: String
) : CssProperty(value) {
companion object {
val row = GridFlow("row")
val column = GridFlow("column")
val dense = GridFlow("dense")
val rowDense = GridFlow("row dense")
val columnDense = GridFlow("column dense")
}
}
class GridValue(
value: String
) : CssProperty(value) {
companion object {
val auto = GridValue("auto")
fun span(column: Int) = GridValue("span $column")
fun column(line: Int) = GridValue("$line")
fun row(line: Int) = GridValue("$line")
}
}
class TemplateRowColumn(
value: String
) : CssProperty(value) {
companion object {
val none = GridValue("none")
val auto = GridValue("auto")
val maxContent = GridValue("max-content")
val minContent = GridValue("min-content")
val initial = GridValue("initial")
val inherit = GridValue("inherit")
fun length(length: Measurement) = GridValue(length.value)
}
}

View File

@@ -0,0 +1,15 @@
package nl.astraeus.css.properties
class Hyphens(
value: String
) : CssProperty(value) {
companion object {
val none = Hyphens("none")
val manual = Hyphens("manual")
val auto = Hyphens("auto")
val initial = Hyphens("initial")
val inherit = Hyphens("inherit")
}
}

View File

@@ -5,10 +5,11 @@ class Image(
) : CssProperty(value) {
companion object {
val none = Image("none")
val initial = Image("initial")
val inherit = Image("inherit")
fun url(url: String) = Image("url($url)")
fun none() = Image("none")
fun initial() = Image("initial")
fun inherit() = Image("inherit")
}
}
@@ -17,11 +18,12 @@ class ImageRepeat(
) : CssProperty(value) {
companion object {
fun stretch(url: String) = Image("stretch")
fun repeat() = Image("repeat")
fun round() = Image("round")
fun initial() = Image("initial")
fun inherit() = Image("inherit")
val repeat = ImageRepeat("repeat")
val round = ImageRepeat("round")
val initial = ImageRepeat("initial")
val inherit = ImageRepeat("inherit")
fun stretch(url: String) = ImageRepeat("stretch")
}
}
@@ -31,14 +33,15 @@ class ImageSlice(
) : CssProperty(value) {
companion object {
fun nr(nr: Int) = Image("$nr")
fun perc(perc: Int) = Image("$perc%")
fun perc(perc: Double) = Image("$perc%")
fun stretch(url: String) = Image("stretch")
fun repeat() = Image("repeat")
fun fill() = Image("fill")
fun initial() = Image("initial")
fun inherit() = Image("inherit")
val repeat = ImageSlice("repeat")
val fill = ImageSlice("fill")
val initial = ImageSlice("initial")
val inherit = ImageSlice("inherit")
fun nr(nr: Int) = ImageSlice("$nr")
fun perc(perc: Int) = ImageSlice("$perc%")
fun perc(perc: Double) = ImageSlice("$perc%")
fun stretch(url: String) = ImageSlice("stretch")
}
}
@@ -48,11 +51,12 @@ class ImageSource(
) : CssProperty(value) {
companion object {
fun none() = ImageSource("none")
val none = ImageSource("none")
val initial = ImageSource("initial")
val inherit = ImageSource("inherit")
fun text(txt: String) = ImageSource(txt)
fun image(url: String) = ImageSource("'$url'")
fun initial() = ImageSource("initial")
fun inherit() = ImageSource("inherit")
}
}

View File

@@ -0,0 +1,12 @@
package nl.astraeus.css.properties
class InitialInherit(
value: String
) : CssProperty(value) {
companion object {
val initial = InitialInherit("initial")
val inherit = InitialInherit("inherit")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class Isolation(
value: String
) : CssProperty(value) {
companion object {
val auto = Isolation("auto")
val isolate = Isolation("isolate")
val initial = Isolation("initial")
val inherit = Isolation("inherit")
}
}

View File

@@ -0,0 +1,17 @@
package nl.astraeus.css.properties
class JustifyContent(
value: String
) : CssProperty(value) {
companion object {
val flexStart = JustifyContent("flex-start")
val flexEnd = JustifyContent("flex-end")
val center = JustifyContent("center")
val spaceBetween = JustifyContent("space-between")
val spaceAround = JustifyContent("space-around")
val initial = JustifyContent("initial")
val inherit = JustifyContent("inherit")
}
}

View File

@@ -0,0 +1,13 @@
package nl.astraeus.css.properties
class LetterSpacing(
value: String
) : CssProperty(value) {
companion object {
val normal = LetterSpacing("normal")
val initial = LetterSpacing("initial")
val inherit = LetterSpacing("inherit")
}
}

View File

@@ -0,0 +1,48 @@
package nl.astraeus.css.properties
class ListStylePosition(
value: String
) : CssProperty(value) {
companion object {
val inside = ListStylePosition("inside")
val outside = ListStylePosition("outside")
val initial = ListStylePosition("initial")
val inherit = ListStylePosition("inherit")
}
}
class ListStyleType(
value: String
) : CssProperty(value) {
companion object {
val disc = ListStyleType("disc")
val armenian = ListStyleType("armenian")
val circle = ListStyleType("circle")
val cjkIdeographic = ListStyleType("cjk-ideographic")
val decimal = ListStyleType("decimal")
val decimalLeadingZero = ListStyleType("decimal-leading-zero")
val georgian = ListStyleType("georgian")
val hebrew = ListStyleType("hebrew")
val hiragana = ListStyleType("hiragana")
val hiraganaIroha = ListStyleType("hiragana-iroha")
val katakana = ListStyleType("katakana")
val katakanaIroha = ListStyleType("katakana-iroha")
val lowerAlpha = ListStyleType("lower-alpha")
val lowerGreek = ListStyleType("lower-greek")
val lowerLatin = ListStyleType("lower-latin")
val lowerRoman = ListStyleType("lower-roman")
val none = ListStyleType("none")
val square = ListStyleType("square")
val upperAlpha = ListStyleType("upper-alpha")
val upperGreek = ListStyleType("upper-greek")
val upperLatin = ListStyleType("upper-latin")
val upperRoman = ListStyleType("upper-roman")
val initial = ListStyleType("initial")
val inherit = ListStyleType("inherit")
}
}

View File

@@ -5,18 +5,56 @@ open class Measurement(
) : CssProperty(value) {
companion object {
fun auto() = Measurement("auto")
fun initial() = Measurement("initial")
fun inherit() = Measurement("inherit")
fun normal() = Measurement("normal")
fun px(nr: Int) = Measurement("${nr}px")
fun em(nr: Int) = Measurement("${nr}em")
fun em(nr: Double) = Measurement("${nr}em")
fun perc(nr: Int) = Measurement("${nr}%")
fun perc(nr: Double) = Measurement("${nr}%")
fun pc(nr: Int) = Measurement("${nr}pc")
fun pc(nr: Double) = Measurement("${nr}pc")
fun cm(nr: Int) = Measurement("${nr}cm")
fun cm(nr: Double) = Measurement("${nr}cm")
val auto = Measurement("auto")
val initial = Measurement("initial")
val inherit = Measurement("inherit")
val normal = Measurement("normal")
fun px(nr: Int) = if (nr == 0) { Measurement("0") } else { Measurement("${nr}px") }
fun px(nr: Double) = nr.px
fun em(nr: Int) = nr.em
fun em(nr: Double) = nr.em
fun prc(nr: Int) = nr.prc
fun prc(nr: Double) = nr.prc
fun pc(nr: Int) = nr.pc
fun pc(nr: Double) = nr.pc
fun cm(nr: Int) = nr.cm
fun cm(nr: Double) = nr.cm
}
}
val Int.px: Measurement
get() = Measurement("${this}${if (this == 0) { "" } else { "px"}}")
val Int.em: Measurement
get() = Measurement("${this}${if (this == 0) { "" } else { "em"}}")
val Int.rem: Measurement
get() = Measurement("${this}${if (this == 0) { "" } else { "rem"}}")
val Int.prc: Measurement
get() = Measurement("${this}%")
val Int.pc: Measurement
get() = Measurement("${this}pc")
val Int.cm: Measurement
get() = Measurement("${this}cm")
fun Int.px(): Measurement = Measurement.px(this)
val Double.px: Measurement
get() = Measurement("${this}px")
val Double.em: Measurement
get() = Measurement("${this}em")
val Double.rem: Measurement
get() = Measurement("${this}rem")
val Double.prc: Measurement
get() = Measurement("${this}%")
val Double.pc: Measurement
get() = Measurement("${this}pc")
val Double.cm: Measurement
get() = Measurement("${this}cm")
fun Double.px(): Measurement = Measurement.px(this)
open class LineHeight(value: String) : CssProperty(value) {
companion object {
val normal = LineHeight("normal")
val initial = LineHeight("initial")
val inherit = LineHeight("inherit")
}
}

View File

@@ -0,0 +1,25 @@
package nl.astraeus.css.properties
class MixBlendMode(
value: String
) : CssProperty(value) {
companion object {
val normal = MixBlendMode("normal")
val multiply = MixBlendMode("multiply")
val screen = MixBlendMode("screen")
val overlay = MixBlendMode("overlay")
val darken = MixBlendMode("darken")
val lighten = MixBlendMode("lighten")
val colorDodge = MixBlendMode("color-dodge")
val colorBurn = MixBlendMode("color-burn")
val difference = MixBlendMode("difference")
val exclusion = MixBlendMode("exclusion")
val hue = MixBlendMode("hue")
val saturation = MixBlendMode("saturation")
val color = MixBlendMode("color")
val luminosity = MixBlendMode("luminosity")
}
}

View File

@@ -0,0 +1,17 @@
package nl.astraeus.css.properties
class ObjectFit(
value: String
) : CssProperty(value) {
companion object {
val fill = ObjectFit("fill")
val contain = ObjectFit("contain")
val cover = ObjectFit("cover")
val scaleDown = ObjectFit("scale-down")
val none = ObjectFit("none")
val initial = ObjectFit("initial")
val inherit = ObjectFit("inherit")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class OutlineWidth(
value: String
) : CssProperty(value) {
companion object {
val thin = OutlineWidth("thin")
val medium = OutlineWidth("medium")
val thick = OutlineWidth("thick")
val initial = BorderWidth("initial")
val inherit = BorderWidth("inherit")
}
}

View File

@@ -0,0 +1,15 @@
package nl.astraeus.css.properties
class Overflow(
value: String
) : CssProperty(value) {
companion object {
val visible = Overflow("visible")
val hidden = Overflow("hidden")
val scroll = Overflow("scroll")
val auto = Overflow("auto")
val initial = BorderWidth("initial")
val inherit = BorderWidth("inherit")
}
}

View File

@@ -0,0 +1,17 @@
package nl.astraeus.css.properties
class PageBreak(
value: String
) : CssProperty(value) {
companion object {
val auto = PageBreak("auto")
val always = PageBreak("always")
val avoid = PageBreak("avoid")
val left = PageBreak("left")
val right = PageBreak("right")
val initial = PageBreak("initial")
val inherit = PageBreak("inherit")
}
}

View File

@@ -0,0 +1,13 @@
package nl.astraeus.css.properties
class Perspective(
value: String
) : CssProperty(value) {
companion object {
val none = Perspective("none")
val initial = Perspective("initial")
val inherit = Perspective("inherit")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class PointerEvents(
value: String
) : CssProperty(value) {
companion object {
val auto = PointerEvents("auto")
val none = PointerEvents("none")
val initial = PointerEvents("initial")
val inherit = PointerEvents("inherit")
}
}

View File

@@ -0,0 +1,17 @@
package nl.astraeus.css.properties
class Position(
value: String
) : CssProperty(value) {
companion object {
val static = Position("static")
val absolute = Position("absolute")
val fixed = Position("fixed")
val relative = Position("relative")
val sticky = Position("sticky")
val initial = Position("initial")
val inherit = Position("inherit")
}
}

View File

@@ -0,0 +1,17 @@
package nl.astraeus.css.properties
class HangingPunctuation(
value: String
) : CssProperty(value) {
companion object {
val none = HangingPunctuation("none")
val first = HangingPunctuation("first")
val last = HangingPunctuation("last")
val allowEnd = HangingPunctuation("allow-end")
val forceEnd = HangingPunctuation("force-end")
val initial = HangingPunctuation("initial")
val inherit = HangingPunctuation("inherit")
}
}

View File

@@ -0,0 +1,16 @@
package nl.astraeus.css.properties
class Resize(
value: String
) : CssProperty(value) {
companion object {
val none = Resize("none")
val both = Resize("both")
val horizontal = Resize("horizontal")
val vertical = Resize("vertical")
val initial = Resize("initial")
val inherit = Resize("inherit")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class ScrollBehavior(
value: String
) : CssProperty(value) {
companion object {
val auto = ScrollBehavior("auto")
val smooth = ScrollBehavior("smooth")
val initial = ScrollBehavior("initial")
val inherit = ScrollBehavior("inherit")
}
}

View File

@@ -5,10 +5,10 @@ class Span(
) : CssProperty(value) {
companion object {
fun none() = Clip("none")
fun all() = Clip("all")
fun initial() = Clip("initial")
fun inherit() = Clip("inherit")
val none = Clip("none")
val all = Clip("all")
val initial = Clip("initial")
val inherit = Clip("inherit")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class TableLayout(
value: String
) : CssProperty(value) {
companion object {
val auto = TableLayout("auto")
val fixed = TableLayout("fixed")
val initial = TableLayout("initial")
val inherit = TableLayout("auto")
}
}

View File

@@ -0,0 +1,16 @@
package nl.astraeus.css.properties
class TextAlign(
value: String
) : CssProperty(value) {
companion object {
val left = TextAlign("left")
val right = TextAlign("right")
val center = TextAlign("center")
val justify = TextAlign("justify")
val initial = TextAlign("initial")
val inherit = TextAlign("inherit")
}
}

View File

@@ -0,0 +1,19 @@
package nl.astraeus.css.properties
class TextAlignLast(
value: String
) : CssProperty(value) {
companion object {
val auto = TextAlignLast("auto")
val left = TextAlignLast("left")
val right = TextAlignLast("right")
val center = TextAlignLast("center")
val justify = TextAlignLast("justify")
val start = TextAlignLast("start")
val end = TextAlignLast("end")
val initial = TextAlignLast("initial")
val inherit = TextAlignLast("inherit")
}
}

View File

@@ -0,0 +1,16 @@
package nl.astraeus.css.properties
class TextDecorationLine(
value: String
) : CssProperty(value) {
companion object {
val none = TextDecorationLine("none")
val underline = TextDecorationLine("underline")
val overline = TextDecorationLine("overline")
val lineThrough = TextDecorationLine("line-through")
val initial = TextDecorationLine("initial")
val inherit = TextDecorationLine("inherit")
}
}

View File

@@ -0,0 +1,17 @@
package nl.astraeus.css.properties
class TextDecorationStyle(
value: String
) : CssProperty(value) {
companion object {
val solid = TextDecorationStyle("solid")
val double = TextDecorationStyle("double")
val dotted = TextDecorationStyle("dotted")
val dashed = TextDecorationStyle("dashed")
val wavy = TextDecorationStyle("wavy")
val initial = TextDecorationStyle("initial")
val inherit = TextDecorationStyle("inherit")
}
}

View File

@@ -0,0 +1,16 @@
package nl.astraeus.css.properties
class TextJustify(
value: String
) : CssProperty(value) {
companion object {
val auto = TextJustify("auto")
val interWord = TextJustify("inter-word")
val interCharacter = TextJustify("inter-character")
val none = TextJustify("none")
val initial = TextJustify("initial")
val inherit = TextJustify("inherit")
}
}

View File

@@ -0,0 +1,16 @@
package nl.astraeus.css.properties
class TextTransform(
value: String
) : CssProperty(value) {
companion object {
val none = TextTransform("none")
val capitalize = TextTransform("capitalize")
val uppercase = TextTransform("uppercase")
val lowercase = TextTransform("lowercase")
val initial = TextTransform("initial")
val inherit = TextTransform("inherit")
}
}

View File

@@ -0,0 +1,22 @@
package nl.astraeus.css.properties
class TimingFunction(
value: String
) : CssProperty(value) {
companion object {
val linear = TimingFunction("linear")
val ease = TimingFunction("ease")
val easeIn = TimingFunction("ease-in")
val easeOut = TimingFunction("ease-out")
val easeInOut = TimingFunction("ease-in-out")
val stepStart = TimingFunction("step-start")
val stepEnd = TimingFunction("step-end")
val initial = TimingFunction("initial")
val inherit = TimingFunction("inherit")
fun steps(steps: Int, start: Boolean) = TimingFunction("steps($steps, ${if (start) { "start" } else { "end" }}")
fun cubicBezier(n1: Double, n2: Double, n3: Double, n4: Double) = TimingFunction("cubic-bezier($n1, $n2, $n3, $n4)")
}
}

View File

@@ -0,0 +1,49 @@
package nl.astraeus.css.properties
class Transform(
value: String
) : CssProperty(value) {
companion object {
val none = Transform("none")
val initial = Transform("initial")
val inherit = Transform("inherit")
fun matrix(
n1: Double,
n2: Double,
n3: Double,
n4: Double,
n5: Double,
n6: Double
) = Transform("matrix($n1, $n2, $n3, $n4, $n5, $n6)")
fun matrix3d(
n01: Double, n02: Double, n03: Double, n04: Double,
n05: Double, n06: Double, n07: Double, n08: Double,
n09: Double, n10: Double, n11: Double, n12: Double,
n13: Double, n14: Double, n15: Double, n16: Double
) = Transform(
"matrix3d($n01, $n02, $n03, $n04, $n05, $n06, $n07, $n08, $n09, $n10, $n11, $n12, $n13, $n14, $n15, $n16)"
)
fun translate(x: Double, y: Double) = Transform("translate($x, $y)")
fun translate3d(x: Double, y: Double, z: Double) = Transform("translate3d($x, $y, $z)")
fun translateX(x: Double) = Transform("translateX($x)")
fun translateY(y: Double) = Transform("translateY($y)")
fun translateZ(z: Double) = Transform("translateZ($z)")
fun scale(x: Double, y: Double) = Transform("scale($x, $y)")
fun scale3d(x: Double, y: Double, z: Double) = Transform("scale3d($x, $y, $z)")
fun scaleX(x: Double) = Transform("scaleX($x)")
fun scaleY(y: Double) = Transform("scaleY($y)")
fun scaleZ(z: Double) = Transform("scaleZ($z)")
fun rotate(angle: Double) = Transform("rotate($angle)")
fun rotate3d(x: Double, y: Double, z: Double, angle: Double) = Transform("scale3d($x, $y, $z, $angle")
fun rotateX(x: Double) = Transform("rotateX($x)")
fun rotateY(y: Double) = Transform("rotateY($y)")
fun rotateZ(z: Double) = Transform("rotateZ($z)")
fun skew(x: Double, y: Double) = Transform("skew($x, $y)")
fun skewX(x: Double) = Transform("skew($x)")
fun skewY(y: Double) = Transform("skew($y)")
fun perspective(length: Measurement) = Transform("perspective(${length.css()})")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class TransformStyle(
value: String
) : CssProperty(value) {
companion object {
val flat = TransformStyle("flat")
val preserve3d = TransformStyle("preserve-3d")
val initial = TransformStyle("initial")
val inherit = TransformStyle("inherit")
}
}

View File

@@ -0,0 +1,15 @@
package nl.astraeus.css.properties
class UnicodeBidi(
value: String
) : CssProperty(value) {
companion object {
val normal = UnicodeBidi("normal")
val embed = UnicodeBidi("embed")
val bidiOverride = UnicodeBidi("bidi-override")
val initial = UnicodeBidi("initial")
val inherit = UnicodeBidi("inherit")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class UserSelect(
value: String
) : CssProperty(value) {
companion object {
val auto = UserSelect("auto")
val none = UserSelect("none")
val text = UserSelect("text")
val all = UserSelect("all")
}
}

View File

@@ -0,0 +1,20 @@
package nl.astraeus.css.properties
class VerticalAlign(
value: String
) : CssProperty(value) {
companion object {
val baseline = VerticalAlign("baseline")
val sub = VerticalAlign("sub")
val _super = VerticalAlign("super")
val top = VerticalAlign("top")
val textTop = VerticalAlign("text-top")
val middle = VerticalAlign("middle")
val bottom = VerticalAlign("bottom")
val textBottom = VerticalAlign("text-bottom")
val initial = VerticalAlign("initial")
val inherit = VerticalAlign("inherit")
}
}

View File

@@ -0,0 +1,15 @@
package nl.astraeus.css.properties
class Visibility(
value: String
) : CssProperty(value) {
companion object {
val visible = Visibility("visible")
val hidden = Visibility("hidden")
val collapse = Visibility("collapse")
val initial = Visibility("initial")
val inherit = Visibility("inherit")
}
}

View File

@@ -0,0 +1,17 @@
package nl.astraeus.css.properties
class WhiteSpace(
value: String
) : CssProperty(value) {
companion object {
val normal = WhiteSpace("normal")
val nowrap = WhiteSpace("nowrap")
val pre = WhiteSpace("pre")
val preLine = WhiteSpace("pre-line")
val preWrap = WhiteSpace("pre-wrap")
val initial = WhiteSpace("initial")
val inherit = WhiteSpace("inherit")
}
}

View File

@@ -0,0 +1,16 @@
package nl.astraeus.css.properties
class WordBreak(
value: String
) : CssProperty(value) {
companion object {
val normal = WordBreak("normal")
val breakAll = WordBreak("break-all")
val keepAll = WordBreak("keep-all")
val breakWord = WordBreak("break-word")
val initial = WordBreak("initial")
val inherit = WordBreak("inherit")
}
}

View File

@@ -0,0 +1,13 @@
package nl.astraeus.css.properties
class WordSpacing(
value: String
) : CssProperty(value) {
companion object {
val normal = WordSpacing("normal")
val initial = WordSpacing("initial")
val inherit = WordSpacing("inherit")
}
}

View File

@@ -0,0 +1,14 @@
package nl.astraeus.css.properties
class WordWrap(
value: String
) : CssProperty(value) {
companion object {
val normal = WordWrap("normal")
val breakWord = WordWrap("break-word")
val initial = WordWrap("initial")
val inherit = WordWrap("inherit")
}
}

View File

@@ -0,0 +1,13 @@
package nl.astraeus.css.properties
class WritingMode(
value: String
) : CssProperty(value) {
companion object {
val horizontalTb = WritingMode("horizontal-tb")
val verticalRl = WritingMode("vertical-rl")
val verticalLr = WritingMode("vertical-lr")
}
}

View File

@@ -0,0 +1,13 @@
package nl.astraeus.css.properties
class ZIndex(
value: String
) : CssProperty(value) {
companion object {
val auto = ZIndex("auto")
val initial = ZIndex("initial")
val inherit = ZIndex("inherit")
}
}