Allow multiple selectors for one style (or operator)
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "nl.astraeus"
|
group = "nl.astraeus"
|
||||||
version = "0.4.19"
|
version = "0.4.20"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }
|
maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") }
|
||||||
|
|||||||
@@ -275,52 +275,76 @@ open class Style : CssGenerator() {
|
|||||||
* like the scss &
|
* like the scss &
|
||||||
* @param selector blabla
|
* @param selector blabla
|
||||||
*/
|
*/
|
||||||
fun and(selector: DescriptionProvider, style: Css) {
|
fun and(vararg selectors: DescriptionProvider, style: Css) {
|
||||||
addStyle(selector.description(), style)
|
for (selector in selectors) {
|
||||||
|
addStyle(selector.description(), style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun and(selector: String, style: Css) {
|
fun and(vararg selectors: String, style: Css) {
|
||||||
addStyle(selector, style)
|
for (selector in selectors) {
|
||||||
|
addStyle(selector, style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun select(selector: DescriptionProvider, style: Css) {
|
fun select(vararg selectors: DescriptionProvider, style: Css) {
|
||||||
addStyle(" ${selector.description()}", style)
|
for (selector in selectors) {
|
||||||
|
addStyle(" ${selector.description()}", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun select(selector: String, style: Css) {
|
fun select(vararg selectors: String, style: Css) {
|
||||||
addStyle(" $selector", style)
|
for (selector in selectors) {
|
||||||
|
addStyle(" $selector", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun descendant(descName: DescriptionProvider, style: Css) {
|
fun descendant(vararg descNames: DescriptionProvider, style: Css) {
|
||||||
addStyle(" ${descName.description()}", style)
|
for (descName in descNames) {
|
||||||
|
addStyle(" ${descName.description()}", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun descendant(descName: String, style: Css) {
|
fun descendant(vararg descNames: String, style: Css) {
|
||||||
addStyle(" $descName", style)
|
for (descName in descNames) {
|
||||||
|
addStyle(" $descName", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun child(childName: DescriptionProvider, style: Css) {
|
fun child(vararg childNames: DescriptionProvider, style: Css) {
|
||||||
addStyle(" > ${childName.description()}", style)
|
for (childName in childNames) {
|
||||||
|
addStyle(" > ${childName.description()}", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun child(childName: String, style: Css) {
|
fun child(vararg childNames: String, style: Css) {
|
||||||
addStyle(" > $childName", style)
|
for (childName in childNames) {
|
||||||
|
addStyle(" > $childName", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sibling(childName: DescriptionProvider, style: Css) {
|
fun sibling(vararg childNames: DescriptionProvider, style: Css) {
|
||||||
addStyle(" ~ ${childName.description()}", style)
|
for (childName in childNames) {
|
||||||
|
addStyle(" ~ ${childName.description()}", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sibling(childName: String, style: Css) {
|
fun sibling(vararg childNames: String, style: Css) {
|
||||||
addStyle(" ~ $childName", style)
|
for (childName in childNames) {
|
||||||
|
addStyle(" ~ $childName", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun adjSibling(childName: DescriptionProvider, style: Css) {
|
fun adjSibling(vararg childNames: DescriptionProvider, style: Css) {
|
||||||
addStyle(" + ${childName.description()}", style)
|
for (childName in childNames) {
|
||||||
|
addStyle(" + ${childName.description()}", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun adjSibling(childName: String, style: Css) {
|
fun adjSibling(vararg childNames: String, style: Css) {
|
||||||
addStyle(" + $childName", style)
|
for (childName in childNames) {
|
||||||
|
addStyle(" + $childName", style)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun active(style: Css) {
|
fun active(style: Css) {
|
||||||
|
|||||||
@@ -154,4 +154,24 @@ class TestCssBuilder {
|
|||||||
|
|
||||||
println(css2.generateCss())
|
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