v. 1.0.3, add inline style, fix TemplateRowColumn value types
Took 27 minutes
This commit is contained in:
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "nl.astraeus"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -52,9 +52,9 @@ testlogger {
|
||||
showStandardStreams = true
|
||||
}
|
||||
|
||||
extra["PUBLISH_GROUP_ID"] = "nl.astraeus"
|
||||
extra["PUBLISH_VERSION"] = "1.0.2"
|
||||
extra["PUBLISH_ARTIFACT_ID"] = "kotlin-css-generator"
|
||||
extra["PUBLISH_GROUP_ID"] = group
|
||||
extra["PUBLISH_VERSION"] = version
|
||||
extra["PUBLISH_ARTIFACT_ID"] = name
|
||||
|
||||
// Stub secrets to let the project sync and build without the publication values set up
|
||||
val signingKeyId: String by project
|
||||
|
||||
@@ -58,14 +58,14 @@ class TemplateRowColumn(
|
||||
) : CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
val none = GridValue("none")
|
||||
val auto = GridValue("auto")
|
||||
val maxContent = GridValue("max-content")
|
||||
val minContent = GridValue("min-content")
|
||||
val initial = GridValue("initial")
|
||||
val inherit = GridValue("inherit")
|
||||
val none = TemplateRowColumn("none")
|
||||
val auto = TemplateRowColumn("auto")
|
||||
val maxContent = TemplateRowColumn("max-content")
|
||||
val minContent = TemplateRowColumn("min-content")
|
||||
val initial = TemplateRowColumn("initial")
|
||||
val inherit = TemplateRowColumn("inherit")
|
||||
|
||||
fun length(length: Measurement) = GridValue(length.value)
|
||||
fun length(length: Measurement) = TemplateRowColumn(length.value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -419,9 +419,7 @@ fun attrStartsWith(name: DescriptionProvider, value: String): DescriptionProvide
|
||||
ValueDescriptionProvider("[${name.description()}^=$value]")
|
||||
|
||||
@CssTagMarker
|
||||
open class Style : CssGenerator() {
|
||||
var fontFace: FontFace? = null
|
||||
var keyFrames: MutableMap<String, KeyFrames> = mutableMapOf()
|
||||
open class InlineStyle : CssGenerator() {
|
||||
|
||||
private val validators = mapOf<String, List<Validator>>(
|
||||
"background-position" to listOf(InitialInheritSingleValue()),
|
||||
@@ -446,82 +444,6 @@ open class Style : CssGenerator() {
|
||||
definitions[selector]?.add(style)
|
||||
}
|
||||
|
||||
/**
|
||||
* like the scss &
|
||||
* @param selector blabla
|
||||
*/
|
||||
fun and(vararg selectors: DescriptionProvider, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(selector.description(), style)
|
||||
}
|
||||
}
|
||||
|
||||
fun and(vararg selectors: String, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(selector, style)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(vararg selectors: DescriptionProvider, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(" ${selector.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(vararg selectors: String, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(" $selector", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun descendant(vararg descNames: DescriptionProvider, style: Css) {
|
||||
for (descName in descNames) {
|
||||
addStyle(" ${descName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun descendant(vararg descNames: String, style: Css) {
|
||||
for (descName in descNames) {
|
||||
addStyle(" $descName", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun child(vararg childNames: DescriptionProvider, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" > ${childName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun child(vararg childNames: String, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" > $childName", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun sibling(vararg childNames: DescriptionProvider, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" ~ ${childName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun sibling(vararg childNames: String, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" ~ $childName", style)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -538,30 +460,10 @@ open class Style : CssGenerator() {
|
||||
addStyle(":hover", style)
|
||||
}
|
||||
|
||||
fun firstChild(style: Css) {
|
||||
addStyle(":first-child", style)
|
||||
}
|
||||
|
||||
fun lastChild(style: Css) {
|
||||
addStyle(":last-child", style)
|
||||
}
|
||||
|
||||
fun pseudoElement(selector: DescriptionProvider, style: Css) {
|
||||
addStyle(":${selector.description()}", style)
|
||||
}
|
||||
|
||||
fun pseudoChild(selector: DescriptionProvider, style: Css) {
|
||||
addStyle("::${selector.description()}", style)
|
||||
}
|
||||
|
||||
fun visited(style: Css) {
|
||||
addStyle(":visited", style)
|
||||
}
|
||||
|
||||
fun not(selector: DescriptionProvider, style: Css) {
|
||||
addStyle(":not(${selector.description()})", style)
|
||||
}
|
||||
|
||||
fun plain(name: String, value: String) {
|
||||
props[name] = prp(value)
|
||||
}
|
||||
@@ -1024,12 +926,6 @@ open class Style : CssGenerator() {
|
||||
props["font"] = prp(font)
|
||||
}
|
||||
|
||||
fun fontFace(face: FontFace.() -> Unit) {
|
||||
fontFace = FontFace()
|
||||
|
||||
face.invoke(fontFace!!)
|
||||
}
|
||||
|
||||
fun fontFamily(font: String) {
|
||||
props["font-family"] = prp(font)
|
||||
}
|
||||
@@ -1185,10 +1081,6 @@ open class Style : CssGenerator() {
|
||||
props["hyphens"] = prp(hyphens)
|
||||
}
|
||||
|
||||
fun import(style: Css) {
|
||||
style(this)
|
||||
}
|
||||
|
||||
fun isolation(isolation: Isolation) {
|
||||
props["isolation"] = prp(isolation)
|
||||
}
|
||||
@@ -1197,14 +1089,6 @@ open class Style : CssGenerator() {
|
||||
props["justify-content"] = prp(content)
|
||||
}
|
||||
|
||||
fun keyFrames(animationName: String, frames: KeyFrames.() -> Unit) {
|
||||
val frameCss = KeyFrames()
|
||||
|
||||
frames.invoke(frameCss)
|
||||
|
||||
keyFrames[animationName] = frameCss
|
||||
}
|
||||
|
||||
fun left(left: Measurement) {
|
||||
props["left"] = prp(left)
|
||||
}
|
||||
@@ -1625,6 +1509,130 @@ open class Style : CssGenerator() {
|
||||
}
|
||||
}
|
||||
|
||||
@CssTagMarker
|
||||
open class Style : InlineStyle() {
|
||||
var fontFace: FontFace? = null
|
||||
var keyFrames: MutableMap<String, KeyFrames> = mutableMapOf()
|
||||
|
||||
private fun addStyle(selector: String, style: Css) {
|
||||
definitions[selector] = definitions[selector] ?: mutableListOf()
|
||||
definitions[selector]?.add(style)
|
||||
}
|
||||
|
||||
/**
|
||||
* like the scss &
|
||||
*/
|
||||
fun and(vararg selectors: DescriptionProvider, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(selector.description(), style)
|
||||
}
|
||||
}
|
||||
|
||||
fun and(vararg selectors: String, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(selector, style)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(vararg selectors: DescriptionProvider, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(" ${selector.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(vararg selectors: String, style: Css) {
|
||||
for (selector in selectors) {
|
||||
addStyle(" $selector", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun descendant(vararg descNames: DescriptionProvider, style: Css) {
|
||||
for (descName in descNames) {
|
||||
addStyle(" ${descName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun descendant(vararg descNames: String, style: Css) {
|
||||
for (descName in descNames) {
|
||||
addStyle(" $descName", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun child(vararg childNames: DescriptionProvider, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" > ${childName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun child(vararg childNames: String, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" > $childName", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun sibling(vararg childNames: DescriptionProvider, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" ~ ${childName.description()}", style)
|
||||
}
|
||||
}
|
||||
|
||||
fun sibling(vararg childNames: String, style: Css) {
|
||||
for (childName in childNames) {
|
||||
addStyle(" ~ $childName", style)
|
||||
}
|
||||
}
|
||||
|
||||
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 firstChild(style: Css) {
|
||||
addStyle(":first-child", style)
|
||||
}
|
||||
|
||||
fun lastChild(style: Css) {
|
||||
addStyle(":last-child", style)
|
||||
}
|
||||
|
||||
fun pseudoElement(selector: DescriptionProvider, style: Css) {
|
||||
addStyle(":${selector.description()}", style)
|
||||
}
|
||||
|
||||
fun pseudoChild(selector: DescriptionProvider, style: Css) {
|
||||
addStyle("::${selector.description()}", style)
|
||||
}
|
||||
|
||||
fun not(selector: DescriptionProvider, style: Css) {
|
||||
addStyle(":not(${selector.description()})", style)
|
||||
}
|
||||
|
||||
fun fontFace(face: FontFace.() -> Unit) {
|
||||
fontFace = FontFace()
|
||||
|
||||
face.invoke(fontFace!!)
|
||||
}
|
||||
|
||||
fun import(style: Css) {
|
||||
style(this)
|
||||
}
|
||||
|
||||
fun keyFrames(animationName: String, frames: KeyFrames.() -> Unit) {
|
||||
val frameCss = KeyFrames()
|
||||
|
||||
frames.invoke(frameCss)
|
||||
|
||||
keyFrames[animationName] = frameCss
|
||||
}
|
||||
}
|
||||
|
||||
@CssTagMarker
|
||||
open class ConditionalStyle : Style() {
|
||||
var media: MutableMap<String, ConditionalCss> = mutableMapOf()
|
||||
|
||||
Reference in New Issue
Block a user