Version 0.3.11

This commit is contained in:
2021-02-25 19:54:13 +01:00
parent d1d0b5ce33
commit edd33b41a5
5 changed files with 179 additions and 73 deletions

View File

@@ -4,7 +4,7 @@ plugins {
} }
group = "nl.astraeus" group = "nl.astraeus"
version = "0.3.11-SNAPSHOT" version = "0.3.11"
repositories { repositories {
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") } maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }

View File

@@ -8,43 +8,6 @@ open class Color(
val readOnly: Boolean = false val readOnly: Boolean = false
) : CssProperty(value) { ) : CssProperty(value) {
/* val hue: Int? = null
val saturation: Int? = null
val lightness: Int? = null
val alpha: Double? = null
init {
}
override fun css(): String {
return super.css()
}
fun adjust(
red: Int? = null,
green: Int? = null,
blue: Int? = null,
hue: Int? = null,
saturation: Int? = null,
lightness: Int? = null,
alpha: Double? = null
): Color {
return this
}
fun darken(): Color {
if (readOnly) {
return this
} else {
return this
}
}
fun lighten(): Color {
return this
}*/
companion object { companion object {
val auto = Color("auto", true) val auto = Color("auto", true)
val transparant = Color("transparant", true) val transparant = Color("transparant", true)
@@ -52,39 +15,180 @@ open class Color(
val inherit = Color("inherit", true) val inherit = Color("inherit", true)
fun hex(hex: String) = Color("#$hex") fun hex(hex: String) = Color("#$hex")
fun rgb( fun rgb(
red: Int, red: Int,
green: Int, green: Int,
blue: Int blue: Int
) = Color("rgb($red, $green, $blue)") ) = RgbaColor(red, green, blue, 1.0)
fun rgba( fun rgba(
red: Int, red: Int,
green: Int, green: Int,
blue: Int, blue: Int,
alpha: Double alpha: Double
) = Color("rgba($red, $green, $blue, $alpha)") ) = RgbaColor(red, green, blue, alpha)
fun hsl( fun hsl(
hue: Int, hue: Int,
saturation: Int, saturation: Int,
lightness: Int lightness: Int
) = Color("hsl($hue, $saturation%, $lightness%)") ) = HslaColor(hue, saturation, lightness, 1.0)
fun hsla( fun hsla(
hue: Int, hue: Int,
saturation: Int, saturation: Int,
lightness: Int, lightness: Int,
alpha: Double alpha: Double
) = Color("hsla($hue, $saturation%, $lightness%, $alpha)") ) = HslaColor(hue, saturation, lightness, alpha)
private fun fromHex( val aliceBlue = Color("#F0F8FF")
red: Int, val antiqueWhite = Color("#FAEBD7")
green: Int, val aqua = Color("#00FFFF")
blue: Int val aquamarine = Color("#7FFFD4")
) { val azure = Color("#F0FFFF")
val beige = Color("#F5F5DC")
} val bisque = Color("#FFE4C4")
val black = Color("#000000")
val blanchedAlmond = Color("#FFEBCD")
val blue = Color("#0000FF")
val blueViolet = Color("#8A2BE2")
val brown = Color("#A52A2A")
val burlyWood = Color("#DEB887")
val cadetBlue = Color("#5F9EA0")
val chartreuse = Color("#7FFF00")
val chocolate = Color("#D2691E")
val coral = Color("#FF7F50")
val cornflowerBlue = Color("#6495ED")
val cornsilk = Color("#FFF8DC")
val crimson = Color("#DC143C")
val cyan = Color("#00FFFF")
val darkBlue = Color("#00008B")
val darkCyan = Color("#008B8B")
val darkGoldenRod = Color("#B8860B")
val darkGray = Color("#A9A9A9")
val darkGrey = Color("#A9A9A9")
val darkGreen = Color("#006400")
val darkKhaki = Color("#BDB76B")
val darkMagenta = Color("#8B008B")
val darkOliveGreen = Color("#556B2F")
val darkorange = Color("#FF8C00")
val darkOrchid = Color("#9932CC")
val darkRed = Color("#8B0000")
val darkSalmon = Color("#E9967A")
val darkSeaGreen = Color("#8FBC8F")
val darkSlateBlue = Color("#483D8B")
val darkSlateGray = Color("#2F4F4F")
val darkSlateGrey = Color("#2F4F4F")
val darkTurquoise = Color("#00CED1")
val darkViolet = Color("#9400D3")
val deepPink = Color("#FF1493")
val deepSkyBlue = Color("#00BFFF")
val dimGray = Color("#696969")
val dimGrey = Color("#696969")
val dodgerBlue = Color("#1E90FF")
val fireBrick = Color("#B22222")
val floralWhite = Color("#FFFAF0")
val forestGreen = Color("#228B22")
val fuchsia = Color("#FF00FF")
val gainsboro = Color("#DCDCDC")
val ghostWhite = Color("#F8F8FF")
val gold = Color("#FFD700")
val goldenRod = Color("#DAA520")
val gray = Color("#808080")
val grey = Color("#808080")
val green = Color("#008000")
val greenYellow = Color("#ADFF2F")
val honeyDew = Color("#F0FFF0")
val hotPink = Color("#FF69B4")
val indianRed = Color(" #CD5C5C")
val indigo = Color(" #4B0082")
val ivory = Color("#FFFFF0")
val khaki = Color("#F0E68C")
val lavender = Color("#E6E6FA")
val lavenderBlush = Color("#FFF0F5")
val lawnGreen = Color("#7CFC00")
val lemonChiffon = Color("#FFFACD")
val lightBlue = Color("#ADD8E6")
val lightCoral = Color("#F08080")
val lightCyan = Color("#E0FFFF")
val lightGoldenRodYellow = Color("#FAFAD2")
val lightGray = Color("#D3D3D3")
val lightGrey = Color("#D3D3D3")
val lightGreen = Color("#90EE90")
val lightPink = Color("#FFB6C1")
val lightSalmon = Color("#FFA07A")
val lightSeaGreen = Color("#20B2AA")
val lightSkyBlue = Color("#87CEFA")
val lightSlateGray = Color("#778899")
val lightSlateGrey = Color("#778899")
val lightSteelBlue = Color("#B0C4DE")
val lightYellow = Color("#FFFFE0")
val lime = Color("#00FF00")
val limeGreen = Color("#32CD32")
val linen = Color("#FAF0E6")
val magenta = Color("#FF00FF")
val maroon = Color("#800000")
val mediumAquaMarine = Color("#66CDAA")
val mediumBlue = Color("#0000CD")
val mediumOrchid = Color("#BA55D3")
val mediumPurple = Color("#9370D8")
val mediumSeaGreen = Color("#3CB371")
val mediumSlateBlue = Color("#7B68EE")
val mediumSpringGreen = Color("#00FA9A")
val mediumTurquoise = Color("#48D1CC")
val mediumVioletRed = Color("#C71585")
val midnightBlue = Color("#191970")
val mintCream = Color("#F5FFFA")
val mistyRose = Color("#FFE4E1")
val moccasin = Color("#FFE4B5")
val navajoWhite = Color("#FFDEAD")
val navy = Color("#000080")
val oldLace = Color("#FDF5E6")
val olive = Color("#808000")
val oliveDrab = Color("#6B8E23")
val orange = Color("#FFA500")
val orangeRed = Color("#FF4500")
val orchid = Color("#DA70D6")
val paleGoldenRod = Color("#EEE8AA")
val paleGreen = Color("#98FB98")
val paleTurquoise = Color("#AFEEEE")
val paleVioletRed = Color("#D87093")
val papayaWhip = Color("#FFEFD5")
val peachPuff = Color("#FFDAB9")
val peru = Color("#CD853F")
val pink = Color("#FFC0CB")
val plum = Color("#DDA0DD")
val powderBlue = Color("#B0E0E6")
val purple = Color("#800080")
val red = Color("#FF0000")
val rosyBrown = Color("#BC8F8F")
val royalBlue = Color("#4169E1")
val saddleBrown = Color("#8B4513")
val salmon = Color("#FA8072")
val sandyBrown = Color("#F4A460")
val seaGreen = Color("#2E8B57")
val seaShell = Color("#FFF5EE")
val sienna = Color("#A0522D")
val silver = Color("#C0C0C0")
val skyBlue = Color("#87CEEB")
val slateBlue = Color("#6A5ACD")
val slateGray = Color("#708090")
val slateGrey = Color("#708090")
val snow = Color("#FFFAFA")
val springGreen = Color("#00FF7F")
val steelBlue = Color("#4682B4")
val tan = Color("#D2B48C")
val teal = Color("#008080")
val thistle = Color("#D8BFD8")
val tomato = Color("#FF6347")
val turquoise = Color("#40E0D0")
val violet = Color("#EE82EE")
val wheat = Color("#F5DEB3")
val white = Color("#FFFFFF")
val whiteSmoke = Color("#F5F5F5")
val yellow = Color("#FFFF00")
val yellowGreen = Color("#9ACD32")
} }
} }

View File

@@ -39,16 +39,16 @@ class GridFlow(
} }
class GridRowColumn( class GridValue(
value: String value: String
) : CssProperty(value) { ) : CssProperty(value) {
companion object { companion object {
val auto = GridRowColumn("auto") val auto = GridValue("auto")
fun span(column: Int) = GridRowColumn("span $column") fun span(column: Int) = GridValue("span $column")
fun columnLine(line: Int) = GridRowColumn("$line") fun column(line: Int) = GridValue("$line")
fun rowLine(line: Int) = GridRowColumn("$line") fun row(line: Int) = GridValue("$line")
} }
} }
@@ -58,14 +58,14 @@ class TemplateRowColumn(
) : CssProperty(value) { ) : CssProperty(value) {
companion object { companion object {
val none = GridRowColumn("none") val none = GridValue("none")
val auto = GridRowColumn("auto") val auto = GridValue("auto")
val maxContent = GridRowColumn("max-content") val maxContent = GridValue("max-content")
val minContent = GridRowColumn("min-content") val minContent = GridValue("min-content")
val initial = GridRowColumn("initial") val initial = GridValue("initial")
val inherit = GridRowColumn("inherit") val inherit = GridValue("inherit")
fun length(length: Measurement) = GridRowColumn(length.value) fun length(length: Measurement) = GridValue(length.value)
} }
} }

View File

@@ -14,8 +14,8 @@ open class Measurement(
fun px(nr: Double) = nr.px fun px(nr: Double) = nr.px
fun em(nr: Int) = nr.em fun em(nr: Int) = nr.em
fun em(nr: Double) = nr.em fun em(nr: Double) = nr.em
fun perc(nr: Int) = nr.perc fun prc(nr: Int) = nr.prc
fun perc(nr: Double) = nr.perc fun prc(nr: Double) = nr.prc
fun pc(nr: Int) = nr.pc fun pc(nr: Int) = nr.pc
fun pc(nr: Double) = nr.pc fun pc(nr: Double) = nr.pc
fun cm(nr: Int) = nr.cm fun cm(nr: Int) = nr.cm
@@ -27,7 +27,7 @@ val Int.px: Measurement
get() = Measurement("${this}${if (this == 0) { "" } else { "px"}}") get() = Measurement("${this}${if (this == 0) { "" } else { "px"}}")
val Int.em: Measurement val Int.em: Measurement
get() = Measurement("${this}${if (this == 0) { "" } else { "em"}}") get() = Measurement("${this}${if (this == 0) { "" } else { "em"}}")
val Int.perc: Measurement val Int.prc: Measurement
get() = Measurement("${this}%") get() = Measurement("${this}%")
val Int.pc: Measurement val Int.pc: Measurement
get() = Measurement("${this}pc") get() = Measurement("${this}pc")
@@ -39,7 +39,7 @@ val Double.px: Measurement
get() = Measurement("${this}px") get() = Measurement("${this}px")
val Double.em: Measurement val Double.em: Measurement
get() = Measurement("${this}em") get() = Measurement("${this}em")
val Double.perc: Measurement val Double.prc: Measurement
get() = Measurement("${this}%") get() = Measurement("${this}%")
val Double.pc: Measurement val Double.pc: Measurement
get() = Measurement("${this}pc") get() = Measurement("${this}pc")

View File

@@ -435,18 +435,18 @@ open class Style : CssGenerator() {
fun gridAutoFlow(flow: GridFlow) { props["grid-auto-flow"] = prp(flow) } fun gridAutoFlow(flow: GridFlow) { props["grid-auto-flow"] = prp(flow) }
fun gridAutoRows(autoRows: GridAuto) { props["grid-auto-rows"] = prp(autoRows) } fun gridAutoRows(autoRows: GridAuto) { props["grid-auto-rows"] = prp(autoRows) }
fun gridAutoRows(size: Measurement) { props["grid-auto-rows"] = prp(size) } fun gridAutoRows(size: Measurement) { props["grid-auto-rows"] = prp(size) }
fun gridColumn(start: GridRowColumn, end: GridRowColumn) { props["grid-column"] = prp(CssProperty("${start.css()}/${end.css()}")) } fun gridColumn(start: GridValue, end: GridValue) { props["grid-column"] = prp(CssProperty("${start.css()}/${end.css()}")) }
fun gridColumnEnd(end: GridRowColumn) { props["grid-column-end"] = prp(end) } fun gridColumnEnd(end: GridValue) { props["grid-column-end"] = prp(end) }
fun gridColumnGap(gap: GridRowColumn) { props["grid-column-gap"] = prp(gap) } fun gridColumnGap(gap: GridValue) { props["grid-column-gap"] = prp(gap) }
fun gridColumnStart(start: GridRowColumn) { props["grid-column-start"] = prp(start) } fun gridColumnStart(start: GridValue) { props["grid-column-start"] = prp(start) }
fun gridGap( fun gridGap(
rowGap: Measurement = Measurement.px(0), rowGap: Measurement = Measurement.px(0),
columnGap: Measurement = Measurement.px(0) columnGap: Measurement = Measurement.px(0)
) { props["grid-gap"] = prp(rowGap, columnGap) } ) { props["grid-gap"] = prp(rowGap, columnGap) }
fun gridRow(start: GridRowColumn, end: GridRowColumn) { props["grid-row"] = prp(CssProperty("${start.css()}/${end.css()}")) } fun gridRow(start: GridValue, end: GridValue) { props["grid-row"] = prp(CssProperty("${start.css()}/${end.css()}")) }
fun gridRowEnd(end: GridRowColumn) { props["grid-row-end"] = prp(end) } fun gridRowEnd(end: GridValue) { props["grid-row-end"] = prp(end) }
fun gridRowGap(gap: GridRowColumn) { props["grid-row-end"] = prp(gap) } fun gridRowGap(gap: GridValue) { props["grid-row-end"] = prp(gap) }
fun gridRowStart(start: GridRowColumn) { props["grid-row-start"] = prp(start) } fun gridRowStart(start: GridValue) { props["grid-row-start"] = prp(start) }
fun gridTemplate(template: String) { props["grid-template"] = prp(template) } fun gridTemplate(template: String) { props["grid-template"] = prp(template) }
fun gridTemplateAreas(template: String) { props["grid-template-areas"] = prp(template) } fun gridTemplateAreas(template: String) { props["grid-template-areas"] = prp(template) }
@Deprecated( @Deprecated(
@@ -455,7 +455,9 @@ open class Style : CssGenerator() {
) )
fun gridTemplateColumn(vararg columns: TemplateRowColumn) { props["grid-template-columns"] = prp(*columns) } fun gridTemplateColumn(vararg columns: TemplateRowColumn) { props["grid-template-columns"] = prp(*columns) }
fun gridTemplateColumns(vararg columns: TemplateRowColumn) { props["grid-template-columns"] = prp(*columns) } fun gridTemplateColumns(vararg columns: TemplateRowColumn) { props["grid-template-columns"] = prp(*columns) }
fun gridTemplateColumns(vararg columns: Measurement) { props["grid-template-columns"] = prp(*columns) }
fun gridTemplateRows(vararg rows: TemplateRowColumn) { props["grid-template-rows"] = prp(*rows) } fun gridTemplateRows(vararg rows: TemplateRowColumn) { props["grid-template-rows"] = prp(*rows) }
fun gridTemplateRows(vararg rows: Measurement) { props["grid-template-rows"] = prp(*rows) }
fun hangingPunctuation(punctuation: Isolation) { props["hanging-punctuation"] = prp(punctuation) } fun hangingPunctuation(punctuation: Isolation) { props["hanging-punctuation"] = prp(punctuation) }
fun height(height: Measurement) { props["height"] = prp(height) } fun height(height: Measurement) { props["height"] = prp(height) }
fun hyphens(hyphens: Hyphens) { props["hyphens"] = prp(hyphens) } fun hyphens(hyphens: Hyphens) { props["hyphens"] = prp(hyphens) }