More properties, cleanup
This commit is contained in:
@@ -2,7 +2,8 @@ package nl.astraeus.css
|
||||
|
||||
import nl.astraeus.css.properties.*
|
||||
import nl.astraeus.css.properties.AlignContent.Companion.flexStart
|
||||
import nl.astraeus.css.style.StyleDefinition
|
||||
import nl.astraeus.css.style.Css
|
||||
import nl.astraeus.css.style.Style
|
||||
|
||||
class StyleBase(
|
||||
val mainColor: Color = Color.hsl(128, 50, 50),
|
||||
@@ -10,7 +11,7 @@ class StyleBase(
|
||||
val mainFont: TextProperty = text("Arial")
|
||||
)
|
||||
|
||||
private fun StyleDefinition.sizePX(
|
||||
private fun Style.sizePX(
|
||||
left: Int,
|
||||
top: Int,
|
||||
width: Int,
|
||||
@@ -28,31 +29,31 @@ private fun generateCss(
|
||||
val css = CssBuilder()
|
||||
|
||||
css.style {
|
||||
css("body") {
|
||||
select("body") {
|
||||
fontFamily = base.mainFont
|
||||
color = base.mainColor
|
||||
backgroundColor = base.mainBackgroundColor
|
||||
}
|
||||
|
||||
css(".test") {
|
||||
select(".test") {
|
||||
top = Measurement.px(10)
|
||||
left = Measurement.em(5)
|
||||
backgroundColor = Color.rgba(255, 255, 255, 0.75)
|
||||
|
||||
css("> a") {
|
||||
select("> a") {
|
||||
color = Color.hsl(200, 50, 50)
|
||||
}
|
||||
}
|
||||
|
||||
css("nav") {
|
||||
css("ul") {
|
||||
select("nav") {
|
||||
select("ul") {
|
||||
color = Color.hsl(0, 100, 25)
|
||||
backgroundColor = base.mainBackgroundColor
|
||||
}
|
||||
css("li") {
|
||||
select("li") {
|
||||
sizePX(25, 25, 200, 200)
|
||||
|
||||
css("a") {
|
||||
select("a") {
|
||||
width = Measurement.px(725)
|
||||
background = text("red initial")
|
||||
backgroundColor = base.mainBackgroundColor
|
||||
@@ -76,34 +77,83 @@ fun main() {
|
||||
println(css1)
|
||||
println(css2)
|
||||
|
||||
val sd = css {
|
||||
css("#pipo") {
|
||||
val border = css {
|
||||
borderRadius = BorderRadius(1, 2, 3, 4)
|
||||
borderColor = listOf(Color.hsl(22,66,55))
|
||||
|
||||
select("a") {
|
||||
width = Measurement.px(10)
|
||||
}
|
||||
}
|
||||
|
||||
val border2: Css = {
|
||||
borderRadius = BorderRadius(1, 2, 3, 4)
|
||||
borderColor = listOf(Color.hsl(20,60,50))
|
||||
}
|
||||
|
||||
val font: Css = {
|
||||
fontFamily = text("Arial, Courier")
|
||||
fontSize = FontSize.larger()
|
||||
}
|
||||
|
||||
val sd = style {
|
||||
select("#pipo") {
|
||||
backgroundColor = Color.hex("eeeeee")
|
||||
fontFamily = text("Arial, Courier")
|
||||
animationDelay = listOf(DelayDuration.initial())
|
||||
|
||||
css("div") {
|
||||
select("div") {
|
||||
fontFace {
|
||||
fontFamily = text("SanSation")
|
||||
fontSize = FontSize.larger()
|
||||
src = text("font/sansation_bold.woff")
|
||||
fontStretch = FontStretch.condensed()
|
||||
fontStyle = FontStyle.italic()
|
||||
fontWeight = FontWeight._600()
|
||||
}
|
||||
|
||||
fontFamily = text("SanSation")
|
||||
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()
|
||||
)
|
||||
borderRadius = listOf(
|
||||
BorderRadius.px(4),
|
||||
BorderRadius.px(5),
|
||||
BorderRadius.px(6),
|
||||
BorderRadius.px(7),
|
||||
BorderRadius.px(8)
|
||||
)
|
||||
select("span") {
|
||||
animationIterationCount = listOf(
|
||||
Count.count(3),
|
||||
Count.infinite()
|
||||
)
|
||||
animationTimingFunction = listOf(
|
||||
AnimationTimingFunction.cubicBezier(0.1, 0.2, 0.3, 0.4),
|
||||
AnimationTimingFunction.easeInOut()
|
||||
)
|
||||
}
|
||||
select("border-0") {
|
||||
apply(border)
|
||||
borderRadius = BorderRadius(4, 5, 6, 7)
|
||||
}
|
||||
select("border-1") {
|
||||
apply(border2)
|
||||
borderRadius = BorderRadius(4, 5, 6, 7)
|
||||
}
|
||||
select("border-2") {
|
||||
borderRadius = BorderRadius(4, 5, 6, 7)
|
||||
apply(border2)
|
||||
|
||||
display = Display.none()
|
||||
borderBottomWidth = BorderWidth.perc(13)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val borderStyle = style {
|
||||
select(".border") {
|
||||
apply(border)
|
||||
apply(font)
|
||||
|
||||
select("> p") {
|
||||
fontSize = FontSize.smaller()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,4 +162,6 @@ fun main() {
|
||||
println(sd.generateCss())
|
||||
println("======")
|
||||
println(sd.generateCss(minified = true))
|
||||
println("======")
|
||||
println(borderStyle.generateCss())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user