Small fixes
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "nl.astraeus"
|
||||
version = "0.4.11"
|
||||
version = "0.4.15"
|
||||
|
||||
repositories {
|
||||
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }
|
||||
|
||||
@@ -2,4 +2,4 @@ kotlin.code.style=official
|
||||
kotlin.js.compiler=both
|
||||
|
||||
nexusUsername=deployment
|
||||
nexusPassword=nhPTzBWizph86j2Jz5KhPdiB4C
|
||||
nexusPassword=bGtci5GLFbqORmruICmTWFmGLY
|
||||
|
||||
@@ -27,6 +27,8 @@ val Int.px: Measurement
|
||||
get() = Measurement("${this}${if (this == 0) { "" } else { "px"}}")
|
||||
val Int.em: Measurement
|
||||
get() = Measurement("${this}${if (this == 0) { "" } else { "em"}}")
|
||||
val Int.rem: Measurement
|
||||
get() = Measurement("${this}${if (this == 0) { "" } else { "rem"}}")
|
||||
val Int.prc: Measurement
|
||||
get() = Measurement("${this}%")
|
||||
val Int.pc: Measurement
|
||||
@@ -39,6 +41,8 @@ val Double.px: Measurement
|
||||
get() = Measurement("${this}px")
|
||||
val Double.em: Measurement
|
||||
get() = Measurement("${this}em")
|
||||
val Double.rem: Measurement
|
||||
get() = Measurement("${this}rem")
|
||||
val Double.prc: Measurement
|
||||
get() = Measurement("${this}%")
|
||||
val Double.pc: Measurement
|
||||
|
||||
@@ -79,50 +79,6 @@ abstract class CssGenerator {
|
||||
): String {
|
||||
val builder = StringBuilder()
|
||||
|
||||
if (this is ConditionalStyle) {
|
||||
this.media.let { mq ->
|
||||
mq.keys.sorted().forEach { mediaName ->
|
||||
val css = mq[mediaName]
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("@media ")
|
||||
builder.append(mediaName)
|
||||
builder.append(" {\n")
|
||||
css?.let { css ->
|
||||
val mediaStyle = ConditionalStyle()
|
||||
|
||||
css(mediaStyle)
|
||||
|
||||
builder.append(mediaStyle.generateCss("", " $indent"))
|
||||
}
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("}\n")
|
||||
}
|
||||
}
|
||||
|
||||
this.supports.let { mq ->
|
||||
mq.keys.sorted().forEach { mediaName ->
|
||||
val css = mq[mediaName]
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("@supports ")
|
||||
builder.append(mediaName)
|
||||
builder.append(" {\n")
|
||||
css?.let { css ->
|
||||
val mediaStyle = ConditionalStyle()
|
||||
|
||||
css(mediaStyle)
|
||||
|
||||
builder.append(mediaStyle.generateCss(""," $indent"))
|
||||
}
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("}\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (name in definitions.keys) {
|
||||
val props = definitions[name]!!
|
||||
val css = StringBuilder()
|
||||
@@ -191,6 +147,50 @@ abstract class CssGenerator {
|
||||
builder.append(finalStyle.generateCss("$namespace$name".trim(), indent))
|
||||
}
|
||||
|
||||
if (this is ConditionalStyle) {
|
||||
this.media.let { mq ->
|
||||
mq.keys.sorted().forEach { mediaName ->
|
||||
val css = mq[mediaName]
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("@media ")
|
||||
builder.append(mediaName)
|
||||
builder.append(" {\n")
|
||||
css?.let { css ->
|
||||
val mediaStyle = ConditionalStyle()
|
||||
|
||||
css(mediaStyle)
|
||||
|
||||
builder.append(mediaStyle.generateCss("", " $indent"))
|
||||
}
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("}\n")
|
||||
}
|
||||
}
|
||||
|
||||
this.supports.let { mq ->
|
||||
mq.keys.sorted().forEach { mediaName ->
|
||||
val css = mq[mediaName]
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("@supports ")
|
||||
builder.append(mediaName)
|
||||
builder.append(" {\n")
|
||||
css?.let { css ->
|
||||
val mediaStyle = ConditionalStyle()
|
||||
|
||||
css(mediaStyle)
|
||||
|
||||
builder.append(mediaStyle.generateCss(""," $indent"))
|
||||
}
|
||||
|
||||
builder.append(indent)
|
||||
builder.append("}\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return if (minified) {
|
||||
val stripped = StringBuilder()
|
||||
val skip = arrayOf(' ', '\t', '\n', '\r')
|
||||
@@ -225,6 +225,7 @@ fun attrEquals(name: String, value: String) : DescriptionProvider = ValueDescrip
|
||||
fun attrContains(name: String, value: String) : DescriptionProvider = ValueDescriptionProvider("[$name*=$value]")
|
||||
fun attrEntriesContain(name: String, value: String) : DescriptionProvider = ValueDescriptionProvider("[$name~=$value]")
|
||||
fun attrEndsWith(name: String, value: String) : DescriptionProvider = ValueDescriptionProvider("[$name$=$value]")
|
||||
fun attrStartsWith(name: String, value: String) : DescriptionProvider = ValueDescriptionProvider("[$name^=$value]")
|
||||
|
||||
fun id(name: DescriptionProvider) = ValueDescriptionProvider("#${name.description()}")
|
||||
fun cls(name: DescriptionProvider) : DescriptionProvider = ValueDescriptionProvider(".${name.description()}")
|
||||
@@ -233,6 +234,7 @@ fun attrEquals(name: DescriptionProvider, value: String) : DescriptionProvider =
|
||||
fun attrContains(name: DescriptionProvider, value: String) : DescriptionProvider = ValueDescriptionProvider("[${name.description()}*=$value]")
|
||||
fun attrEntriesContain(name: DescriptionProvider, value: String) : DescriptionProvider = ValueDescriptionProvider("[${name.description()}~=$value]")
|
||||
fun attrEndsWith(name: DescriptionProvider, value: String) : DescriptionProvider = ValueDescriptionProvider("[${name.description()}$=$value]")
|
||||
fun attrStartsWith(name: DescriptionProvider, value: String) : DescriptionProvider = ValueDescriptionProvider("[${name.description()}^=$value]")
|
||||
|
||||
|
||||
@CssTagMarker
|
||||
@@ -450,6 +452,13 @@ open class Style : CssGenerator() {
|
||||
fun clip(clip: Clip) { props["clip"] = prp(clip) }
|
||||
fun clipPath(path: ClipPath) { props["clip-path"] = prp(path) }
|
||||
fun color(color: Color) { props["color"] = listOf(color) }
|
||||
var color: Color? = null
|
||||
set(value) {
|
||||
field = value
|
||||
value?.let {
|
||||
props["color"] = listOf(it)
|
||||
}
|
||||
}
|
||||
fun columnCount(count: Count) { props["column-count"] = prp(count) }
|
||||
fun columnFill(fill: Fill) { props["column-fill"] = prp(fill) }
|
||||
fun columnGap(gap: Measurement) { props["column-gap"] = prp(gap) }
|
||||
|
||||
@@ -74,6 +74,7 @@ class TestCssBuilder {
|
||||
val css2 = style {
|
||||
select(id("my-label")) {
|
||||
color(Color.antiqueWhite)
|
||||
color = Color.antiqueWhite
|
||||
}
|
||||
|
||||
select(cls("my-label")) {
|
||||
|
||||
Reference in New Issue
Block a user