Add Hsla color functions, v. 0.3.10-SNAPSHOT
This commit is contained in:
71
src/commonTest/kotlin/nl/astraeus/css/TestColor.kt
Normal file
71
src/commonTest/kotlin/nl/astraeus/css/TestColor.kt
Normal file
@@ -0,0 +1,71 @@
|
||||
package nl.astraeus.css
|
||||
|
||||
import nl.astraeus.css.properties.*
|
||||
import kotlin.test.Test
|
||||
|
||||
class TestColor {
|
||||
|
||||
@Test
|
||||
fun testBuilder() {
|
||||
val css = style {
|
||||
val baseColor = HslaColor(20, 50, 50)
|
||||
val baseColorRgb = RgbaColor.fromHsla(baseColor)
|
||||
|
||||
println("BaseColor: ${baseColor.value} - ${baseColorRgb.value}")
|
||||
|
||||
val darkerColor = baseColor.darken(10)
|
||||
val darkerColorRgb = RgbaColor.fromHsla(darkerColor)
|
||||
println("DarkerColor: ${darkerColor.value} - ${darkerColorRgb.value}")
|
||||
|
||||
val saturizedColor = baseColor.saturize(10)
|
||||
val saturizedColorRgb = RgbaColor.fromHsla(saturizedColor)
|
||||
println("SaturizedColor: ${saturizedColor.value} - ${saturizedColorRgb.value}")
|
||||
|
||||
val redColor = RgbaColor(0,255,0,1.0)
|
||||
val redColorHsla = redColor.toHsla()
|
||||
val shiftedColor = redColorHsla.adjustHue(120)
|
||||
val shiftedColorRgb = shiftedColor.toRgba()
|
||||
|
||||
println("RedColor: ${redColor.value} - ${redColorHsla.value}")
|
||||
println("ShiftedColor: ${shiftedColor.value} - ${shiftedColorRgb.value}")
|
||||
|
||||
select(".test") {
|
||||
top(10.px)
|
||||
left(4.em)
|
||||
|
||||
backgroundColor(
|
||||
RgbaColor.fromHsla(baseColor.darken(10))
|
||||
)
|
||||
|
||||
animationIterationMode(
|
||||
Count.auto,
|
||||
Count.auto,
|
||||
Count.auto,
|
||||
Count.auto,
|
||||
Count.auto
|
||||
)
|
||||
|
||||
child("li") {
|
||||
color(Color.hsl(200, 50, 50))
|
||||
}
|
||||
|
||||
select("> a") {
|
||||
color(Color.hsl(200, 50, 50))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println(css.generateCss())
|
||||
|
||||
val css2 = style {
|
||||
cls("button") {
|
||||
fontSize(12.px)
|
||||
color(Color.hsl(200, 50, 50))
|
||||
}
|
||||
}
|
||||
|
||||
println(css2.generateCss())
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
package nl.astraeus.css
|
||||
|
||||
object TestCssBuilder {
|
||||
/*
|
||||
@Test
|
||||
fun testBuilder() {
|
||||
val css = CssBuilder()
|
||||
import nl.astraeus.css.properties.Color.Companion.hsl
|
||||
import nl.astraeus.css.properties.Color.Companion.rgba
|
||||
import nl.astraeus.css.properties.Count
|
||||
import nl.astraeus.css.properties.em
|
||||
import nl.astraeus.css.properties.px
|
||||
|
||||
css.style {
|
||||
object TestCssBuilder {
|
||||
|
||||
//@Test
|
||||
fun testBuilder() {
|
||||
val css = css {
|
||||
|
||||
select(".test") {
|
||||
top(10.px())
|
||||
left(4.em())
|
||||
top(10.px)
|
||||
left(4.em)
|
||||
backgroundColor(rgba(255, 255, 255, 0.75))
|
||||
animationIterationMode(
|
||||
Count.auto,
|
||||
@@ -20,6 +24,9 @@ object TestCssBuilder {
|
||||
Count.auto
|
||||
)
|
||||
|
||||
child("li") {
|
||||
color(hsl(200,50,50))
|
||||
}
|
||||
|
||||
select("> a") {
|
||||
color(hsl(200, 50, 50))
|
||||
@@ -28,6 +35,17 @@ object TestCssBuilder {
|
||||
}
|
||||
|
||||
println(css)
|
||||
}*/
|
||||
|
||||
val css2 = css {
|
||||
cls("button") {
|
||||
fontSize(12.px)
|
||||
color(hsl(200, 50, 50))
|
||||
}
|
||||
}
|
||||
|
||||
println(css2)
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user