Allow multiple selectors for one style (or operator)
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "nl.astraeus"
|
||||
version = "0.4.19"
|
||||
version = "0.4.20"
|
||||
|
||||
repositories {
|
||||
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }
|
||||
|
||||
@@ -275,53 +275,77 @@ open class Style : CssGenerator() {
|
||||
* like the scss &
|
||||
* @param selector blabla
|
||||
*/
|
||||
fun and(selector: DescriptionProvider, style: Css) {
|
||||
fun and(vararg selectors: DescriptionProvider, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(selector.description(), style)
|
||||
}
|
||||
}
|
||||
|
||||
fun and(selector: String, style: Css) {
|
||||
fun and(vararg selectors: String, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(selector, style)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(selector: DescriptionProvider, style: Css) {
|
||||
fun select(vararg selectors: DescriptionProvider, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(" ${selector.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(selector: String, style: Css) {
|
||||
fun select(vararg selectors: String, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(" $selector", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun descendant(descName: DescriptionProvider, style: Css) {
|
||||
fun descendant(vararg descNames: DescriptionProvider, style: Css) {
|
||||
for (descName in descNames) {
|
||||
addStyle(" ${descName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun descendant(descName: String, style: Css) {
|
||||
fun descendant(vararg descNames: String, style: Css) {
|
||||
for (descName in descNames) {
|
||||
addStyle(" $descName", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun child(childName: DescriptionProvider, style: Css) {
|
||||
fun child(vararg childNames: DescriptionProvider, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" > ${childName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun child(childName: String, style: Css) {
|
||||
fun child(vararg childNames: String, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" > $childName", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun sibling(childName: DescriptionProvider, style: Css) {
|
||||
fun sibling(vararg childNames: DescriptionProvider, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" ~ ${childName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun sibling(childName: String, style: Css) {
|
||||
fun sibling(vararg childNames: String, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" ~ $childName", style)
|
||||
}
|
||||
|
||||
fun adjSibling(childName: DescriptionProvider, style: Css) {
|
||||
addStyle(" + ${childName.description()}", style)
|
||||
}
|
||||
|
||||
fun adjSibling(childName: String, style: Css) {
|
||||
fun adjSibling(vararg childNames: DescriptionProvider, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" + ${childName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun adjSibling(vararg childNames: String, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" + $childName", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun active(style: Css) {
|
||||
addStyle(":active", style)
|
||||
|
||||
@@ -154,4 +154,24 @@ class TestCssBuilder {
|
||||
|
||||
println(css2.generateCss())
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testOr() {
|
||||
val css = style {
|
||||
select("h1") {
|
||||
color(Color.blue)
|
||||
|
||||
select("table") {
|
||||
color(Color.red)
|
||||
|
||||
select("th", "td") {
|
||||
color(Color.green)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println(css.generateCss())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user