Builder test

This commit is contained in:
2020-03-01 15:22:19 +01:00
parent 1f819c925f
commit 5a0eeac2fe
10 changed files with 166 additions and 110 deletions

View File

@@ -3,7 +3,7 @@ package nl.astraeus.css
import nl.astraeus.css.properties.*
import nl.astraeus.css.properties.Measurement.Companion.em
import nl.astraeus.css.properties.Measurement.Companion.px
import nl.astraeus.css.style.StyleDefinition
import nl.astraeus.css.style.Style
class StyleBase(
val mainColor: Color = Color.hsl(128, 50, 50),
@@ -11,16 +11,16 @@ class StyleBase(
val mainFont: TextProperty = text("Arial")
)
private fun StyleDefinition.sizePX(
private fun Style.sizePX(
left: Int,
top: Int,
width: Int,
height: Int
) {
this@sizePX.top = px(top)
this@sizePX.left = px(left)
this@sizePX.width = px(width)
this@sizePX.height = px(height)
this@sizePX.top(top.px())
this@sizePX.left(left.px())
this@sizePX.width(width.px())
this@sizePX.height(height.px())
}
private fun generateCss(
@@ -30,34 +30,34 @@ private fun generateCss(
css.style {
select("body") {
fontFamily = base.mainFont
color = base.mainColor
backgroundColor = base.mainBackgroundColor
alignContent = AlignContent.initial()
// fontFamily = base.mainFont
// color = base.mainColor
// backgroundColor = base.mainBackgroundColor
// alignContent = AlignContent.initial()
}
select(".test") {
top = px(10)
left = em(5)
backgroundColor = Color.rgba(255, 255, 255, 0.75)
select("> a") {
color = Color.hsl(200, 50, 50)
}
// top = px(10)
// left = em(5)
// backgroundColor = Color.rgba(255, 255, 255, 0.75)
//
// select("> a") {
// color = Color.hsl(200, 50, 50)
// }
}
select("nav") {
select("ul") {
color = Color.hsl(0, 100, 25)
backgroundColor = base.mainBackgroundColor
// color = Color.hsl(0, 100, 25)
// backgroundColor = base.mainBackgroundColor
}
select("li") {
sizePX(25, 25, 200, 200)
select("a") {
width = px(725)
background = text("")
backgroundColor = base.mainBackgroundColor
// width = px(725)
// background = text("")
// backgroundColor = base.mainBackgroundColor
}
}
}
@@ -77,19 +77,19 @@ fun main() {
println(css1)
println(css2)
val sd = css {
val sd = style {
select("#pipo") {
backgroundColor = Color.hex("eeeeee")
fontFamily = text("Arial, Courier")
animationDelay = listOf(DelayDuration.initial())
// backgroundColor = Color.hex("eeeeee")
// fontFamily = text("Arial, Courier")
// animationDelay = listOf(DelayDuration.initial())
select("div") {
color = Color.hex("1b1b1b1")
alignContent = AlignContent.flexStart()
animationName = listOf(text("foo"), text("bar"))
animationIterationCount = listOf(
Count.count(3), Count.infinite())
animationTimingFunction = listOf(AnimationTimingFunction.cubicBezier(0.1, 0.2, 0.3, 0.4), AnimationTimingFunction.easeInOut())
// color = Color.hex("1b1b1b1")
// alignContent = AlignContent.flexStart()
// animationName = listOf(text("foo"), text("bar"))
// animationIterationCount = listOf(
// Count.count(3), Count.infinite())
// animationTimingFunction = listOf(AnimationTimingFunction.cubicBezier(0.1, 0.2, 0.3, 0.4), AnimationTimingFunction.easeInOut())
}
}
}