More properties and cleanup

This commit is contained in:
2020-02-24 09:47:14 +01:00
parent 1c3ac8f0d0
commit 083f234d82
31 changed files with 827 additions and 413 deletions

View File

@@ -1,8 +1,12 @@
package nl.astraeus.css
import nl.astraeus.css.properties.*
import nl.astraeus.css.properties.AlignContent.Companion.flexStart
import nl.astraeus.css.style.StyleDefinition
class StyleBase(
val mainColor: Color = hsl(128, 50, 50),
val mainBackgroundColor: Color = hsl(64, 50, 50),
val mainColor: Color = Color.hsl(128, 50, 50),
val mainBackgroundColor: Color = Color.hsl(64, 50, 50),
val mainFont: TextProperty = text("Arial")
)
@@ -12,10 +16,10 @@ private fun StyleDefinition.sizePX(
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 = Measurement.px(top)
this@sizePX.left = Measurement.px(left)
this@sizePX.width = Measurement.px(width)
this@sizePX.height = Measurement.px(height)
}
private fun generateCss(
@@ -31,26 +35,28 @@ private fun generateCss(
}
css(".test") {
top = px(10)
left = em(5)
backgroundColor = rgba(255, 255, 255, 0.75)
top = Measurement.px(10)
left = Measurement.em(5)
backgroundColor = Color.rgba(255, 255, 255, 0.75)
css("> a") {
color = hsl(200, 50, 50)
color = Color.hsl(200, 50, 50)
}
}
css("nav") {
css("ul") {
color = hsl(0, 100, 25)
color = Color.hsl(0, 100, 25)
backgroundColor = base.mainBackgroundColor
}
css("li") {
sizePX(25, 25, 200, 200)
css("a") {
width = px(725)
width = Measurement.px(725)
background = text("")
backgroundColor = base.mainBackgroundColor
all = All.initial()
}
}
}
@@ -62,8 +68,8 @@ private fun generateCss(
fun main() {
val css1 = generateCss(StyleBase())
val css2 = generateCss(StyleBase(
hsl(32, 40, 50),
hsl(64, 60, 35),
Color.hsl(32, 40, 50),
Color.hsl(64, 60, 35),
text("Courier")
))
@@ -72,14 +78,17 @@ fun main() {
val sd = css {
css("#pipo") {
backgroundColor = hex("eeeeee")
backgroundColor = Color.hex("eeeeee")
fontFamily = text("Arial, Courier")
animationDelay = initial()
animationDelay = listOf(DelayDuration.initial())
css("div") {
color = hex("1b1b1b1")
alignContent = AlignContent.FLEX_START
animationIterationCount = Count.count(3)
color = Color.hex("1b1b1b1")
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())
}
}
}