Merge function-builder branch into master
This commit is contained in:
@@ -1,259 +1,246 @@
|
||||
package nl.astraeus.css.style
|
||||
|
||||
import nl.astraeus.css.properties.*
|
||||
import nl.astraeus.logging.log
|
||||
|
||||
typealias Css = Style.() -> Unit
|
||||
|
||||
typealias ConditionalCss = ConditionalStyle.() -> Unit
|
||||
|
||||
@DslMarker
|
||||
annotation class CssTagMarker
|
||||
|
||||
abstract class CssGenerator {
|
||||
val definitions: MutableMap<String, Css> = mutableMapOf()
|
||||
val extentions: MutableList<Css> = mutableListOf()
|
||||
private fun prp(vararg css: CssValue): List<CssProperty> {
|
||||
val result = mutableListOf<CssProperty>()
|
||||
|
||||
abstract fun getMapping(): Map<String, Any?>
|
||||
for (c in css) {
|
||||
result.add(CssProperty(c.css()))
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun prp(vararg css: String): List<CssProperty> {
|
||||
val result = mutableListOf<CssProperty>()
|
||||
|
||||
for (c in css) {
|
||||
result.add(CssProperty(c))
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
abstract class CssGenerator {
|
||||
val definitions: MutableMap<String, MutableList<Css>> = LinkedHashMap()
|
||||
val props: MutableMap<String, List<CssProperty>> = mutableMapOf()
|
||||
|
||||
abstract fun getValidator(name: String): List<Validator>?
|
||||
|
||||
private fun propertyCss(indent: String, name: String, prop: CssProperty, minified: Boolean): String {
|
||||
getValidator(name)?.forEach {
|
||||
if (!it.validate(prop)) {
|
||||
log.warn { "Validate error '$name' - ${it.getMessage(name)}" }
|
||||
}
|
||||
}
|
||||
|
||||
return if (!minified) {
|
||||
val paddedName = StringBuilder()
|
||||
paddedName.append(indent)
|
||||
paddedName.append(name)
|
||||
paddedName.append(":")
|
||||
while (paddedName.length < 32) {
|
||||
paddedName.append(' ')
|
||||
}
|
||||
"$paddedName${prop.css()};\n"
|
||||
} else {
|
||||
"$name:${prop.css()};"
|
||||
}
|
||||
}
|
||||
|
||||
private fun propertyCss(indent: String, name: String, props: List<*>, minified: Boolean): String {
|
||||
private fun propertyCss(indent: String, name: String, props: List<CssProperty>): String {
|
||||
val builder = StringBuilder()
|
||||
|
||||
getValidator(name)?.forEach {
|
||||
if (!it.validate(props as List<CssProperty>)) {
|
||||
log.warn { "Validate error '$name' - ${it.getListMessage(name)}" }
|
||||
if (!it.validate(props)) {
|
||||
println( "Validate error '$name' - ${it.getMessage(name)}")
|
||||
}
|
||||
}
|
||||
|
||||
for ((index, prop) in props.withIndex()) {
|
||||
if (prop is CssProperty) {
|
||||
getValidator(name)?.forEach {
|
||||
if (!it.validate(prop)) {
|
||||
log.warn { "Validate error '$name' - ${it.getMessage(name)}" }
|
||||
}
|
||||
}
|
||||
if (builder.isNotEmpty()) {
|
||||
builder.append(",")
|
||||
if (!minified) {
|
||||
builder.append(" ")
|
||||
}
|
||||
}
|
||||
builder.append(prop.css())
|
||||
for (prop in props) {
|
||||
if (builder.isNotEmpty()) {
|
||||
builder.append(" ")
|
||||
}
|
||||
builder.append(prop.css())
|
||||
}
|
||||
|
||||
return if (!minified) {
|
||||
val paddedName = StringBuilder()
|
||||
paddedName.append(indent)
|
||||
paddedName.append(name)
|
||||
paddedName.append(":")
|
||||
while (paddedName.length < 32) {
|
||||
paddedName.append(' ')
|
||||
}
|
||||
"$paddedName$builder;\n"
|
||||
} else {
|
||||
"$name:$builder;"
|
||||
val paddedName = StringBuilder()
|
||||
paddedName.append(indent)
|
||||
paddedName.append(name)
|
||||
paddedName.append(":")
|
||||
while (paddedName.length < 32) {
|
||||
paddedName.append(' ')
|
||||
}
|
||||
return "$paddedName$builder;\n"
|
||||
}
|
||||
|
||||
fun generatePropertyCss(indent: String, minified: Boolean): String {
|
||||
fun generatePropertyCss(indent: String): String {
|
||||
val builder = StringBuilder()
|
||||
|
||||
for ((name, prop) in getMapping()) {
|
||||
if (prop is List<*> && prop.isNotEmpty()) {
|
||||
builder.append(propertyCss(indent, name, prop, minified))
|
||||
} else if (prop is CssProperty) {
|
||||
builder.append(propertyCss(indent, name, prop, minified))
|
||||
}
|
||||
for ((name, prop) in props) {
|
||||
builder.append(propertyCss(indent, name, prop))
|
||||
}
|
||||
|
||||
return builder.toString()
|
||||
}
|
||||
|
||||
open fun generateCss(namespace: String = "", indent: String = " ", minified: Boolean = false): String {
|
||||
open fun generateCss(
|
||||
namespace: String = "",
|
||||
indent: String = "",
|
||||
minified: Boolean = false,
|
||||
warnOnRedeclaration: Boolean = true
|
||||
): String {
|
||||
val builder = StringBuilder()
|
||||
|
||||
for ((name, prop) in definitions) {
|
||||
for (name in definitions.keys) {
|
||||
val props = definitions[name]!!
|
||||
val css = StringBuilder()
|
||||
|
||||
if (warnOnRedeclaration && props.size > 1) {
|
||||
css.append("/* style '$name' is defined ${props.size} times! */\n")
|
||||
}
|
||||
|
||||
val finalStyle = Style()
|
||||
|
||||
prop(finalStyle)
|
||||
for (prop in props) {
|
||||
prop(finalStyle)
|
||||
}
|
||||
|
||||
css.append(finalStyle.generatePropertyCss(indent, minified))
|
||||
css.append(finalStyle.generatePropertyCss(" $indent"))
|
||||
|
||||
if (css.isNotBlank()) {
|
||||
builder.append("\n$namespace $name".trim())
|
||||
if (!minified) {
|
||||
builder.append(" ")
|
||||
}
|
||||
builder.append("{")
|
||||
if (!minified) {
|
||||
builder.append("\n")
|
||||
}
|
||||
builder.append("\n$namespace$name".trim())
|
||||
|
||||
//builder.append(" $indent")
|
||||
builder.append(" {\n")
|
||||
|
||||
finalStyle.fontFace?.let { ff ->
|
||||
if (!minified) {
|
||||
builder.append(indent)
|
||||
}
|
||||
builder.append("@font-face {")
|
||||
if (!minified) {
|
||||
builder.append("\n")
|
||||
}
|
||||
builder.append(ff.generatePropertyCss(" $indent", minified))
|
||||
builder.append(indent)
|
||||
builder.append("}")
|
||||
if (!minified) {
|
||||
builder.append("\n")
|
||||
builder.append(" $indent")
|
||||
builder.append("@font-face {\n")
|
||||
builder.append(ff.generatePropertyCss( " $indent"))
|
||||
builder.append(" $indent")
|
||||
builder.append("}\n")
|
||||
}
|
||||
|
||||
finalStyle.keyFrames.let { kf ->
|
||||
kf.keys.sorted().forEach { frameName ->
|
||||
val css = kf[frameName]
|
||||
|
||||
builder.append(" $indent")
|
||||
builder.append("@keyframes ")
|
||||
builder.append(frameName)
|
||||
builder.append(" {\n")
|
||||
css?.let { css ->
|
||||
for ((nr, style) in css.frames) {
|
||||
builder.append(" $indent")
|
||||
builder.append("${nr}% ")
|
||||
builder.append(" $indent")
|
||||
builder.append("{\n")
|
||||
|
||||
val finalStyle = Style()
|
||||
|
||||
style(finalStyle)
|
||||
|
||||
builder.append(finalStyle.generatePropertyCss(" $indent"))
|
||||
|
||||
builder.append(" $indent")
|
||||
builder.append("}\n")
|
||||
}
|
||||
|
||||
builder.append(" $indent")
|
||||
builder.append("}\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.append(css)
|
||||
builder.append("}")
|
||||
if (!minified) {
|
||||
builder.append("\n\n")
|
||||
builder.append("}\n\n")
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
builder.append(finalStyle.generateCss( "$namespace $name".trim(), indent, minified))
|
||||
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 builder.toString()
|
||||
return if (minified) {
|
||||
val stripped = StringBuilder()
|
||||
val skip = arrayOf(' ', '\t', '\n', '\r')
|
||||
for (char in builder) {
|
||||
if (!skip.contains(char)) {
|
||||
stripped.append(char)
|
||||
}
|
||||
}
|
||||
stripped.toString();
|
||||
} else {
|
||||
builder.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CssTagMarker
|
||||
open class Style(
|
||||
var alignContent: AlignContent? = null,
|
||||
var alignItems: AlignItems? = null,
|
||||
var alignSelf: AlignSelf? = null,
|
||||
var all: All? = null,
|
||||
var animation: TextProperty? = null,
|
||||
var animationDelay: List<DelayDuration>? = null,
|
||||
var animationDirection: List<AnimationDirection>? = null,
|
||||
var animationDuration: List<DelayDuration>? = null,
|
||||
var animationFillMode: List<AnimationFillMode>? = null,
|
||||
var animationIterationCount: List<Count>? = null,
|
||||
var animationFrame: AnimationFrame? = null,
|
||||
var animationName: List<TextProperty>? = null,
|
||||
var animationPlayState: List<AnimationPlayState>? = null,
|
||||
var animationTimingFunction: List<AnimationTimingFunction>? = null,
|
||||
var backfaceVisibility: BackfaceVisibility? = null,
|
||||
var background: TextProperty? = null,
|
||||
var backgroundAttachment: BackgroundAttachment? = null,
|
||||
var backgroundBlendMode: BackgroundBlendMode? = null,
|
||||
var backgroundClip: ClipOrigin? = null,
|
||||
var backgroundColor: Color? = null,
|
||||
var backgroundImage: Image? = null,
|
||||
var backgroundOrigin: ClipOrigin? = null,
|
||||
var backgroundPosition: List<BackgroundPosition>? = null,
|
||||
var backgroundRepeat: List<BackgroundRepeat>? = null,
|
||||
var backgroundSize: List<BackgroundSize>? = null,
|
||||
var border: TextProperty? = null,
|
||||
var borderBottom: TextProperty? = null,
|
||||
var borderBottomColor: Color? = null,
|
||||
var borderBottomLeftRadius: List<BorderRadius>? = null,
|
||||
var borderBottomRightRadius: List<BorderRadius>? = null,
|
||||
var borderBottomStyle: RuleBorderStyle? = null,
|
||||
var borderBottomWidth: BorderWidth? = null,
|
||||
var borderCollapse: BorderCollapse? = null,
|
||||
var borderColor: List<Color>? = null,
|
||||
var borderImage: TextProperty? = null,
|
||||
var borderImageOutset: Length? = null,
|
||||
var borderImageRepeat: List<ImageRepeat>? = null,
|
||||
var borderImageSlice: List<ImageSlice>? = null,
|
||||
var borderImageSource: List<ImageSource>? = null,
|
||||
var borderImageWidth: List<BorderImageWidth>? = null,
|
||||
var borderLeft: TextProperty? = null,
|
||||
var borderLeftColor: Color? = null,
|
||||
var borderLeftStyle: RuleBorderStyle? = null,
|
||||
var borderLeftWidth: BorderWidth? = null,
|
||||
var borderRadius: BorderRadius? = null,
|
||||
var borderRight: TextProperty? = null,
|
||||
var borderRightColor: Color? = null,
|
||||
var borderRightStyle: RuleBorderStyle? = null,
|
||||
var borderRightWidth: BorderWidth? = null,
|
||||
var borderSpacing: List<BorderSpacing>? = null,
|
||||
var borderStyle: List<RuleBorderStyle>? = null,
|
||||
var borderTop: TextProperty? = null,
|
||||
var borderTopColor: Color? = null,
|
||||
var borderTopLeftRadius: BorderRadius? = null,
|
||||
var borderTopRightRadius: BorderRadius? = null,
|
||||
var borderTopStyle: RuleBorderStyle? = null,
|
||||
var borderTopWidth: BorderWidth? = null,
|
||||
var bottom: Measurement? = null,
|
||||
var boxDecorationBreak: BoxDecorationBreak? = null,
|
||||
var boxShadow: BoxShadow? = null,
|
||||
var boxSizing: BoxSizing? = null,
|
||||
var breakAfter: Break? = null,
|
||||
var breakBefore: Break? = null,
|
||||
var breakInside: Break? = null,
|
||||
var captionSide: CaptionSide? = null,
|
||||
var caretColor: Color? = null,
|
||||
//var charset: TextProperty? = null,
|
||||
var clear: Clear? = null,
|
||||
var clip: Clip? = null,
|
||||
var clipPath: ClipPath? = null,
|
||||
var columnCount: Count? = null,
|
||||
var columnFill: Fill? = null,
|
||||
var columnGap: Measurement? = null,
|
||||
var columnRule: TextProperty? = null,
|
||||
var columnRuleColor: Color? = null,
|
||||
var columnRuleStyle: RuleBorderStyle? = null,
|
||||
var columnRuleWidth: Measurement? = null,
|
||||
var columnSpan: Span? = null,
|
||||
var columnWidth: Measurement? = null,
|
||||
var columns: TextProperty? = null,
|
||||
var content: Content? = null,
|
||||
var counterIncrement: TextProperty? = null,
|
||||
var counterReset: TextProperty? = null,
|
||||
var cursor: TextProperty? = null,
|
||||
var direction: Direction? = null,
|
||||
var display: Display? = null,
|
||||
var emptyCells: EmptyCells? = null,
|
||||
var filter: TextProperty? = null,
|
||||
var flex: TextProperty? = null,
|
||||
var flexBasis: Measurement? = null,
|
||||
var flexDirection: FlexDirection? = null,
|
||||
var flexFlow: TextProperty? = null,
|
||||
var flexGrow: FlexGrowShrink? = null,
|
||||
var flexShrink: FlexGrowShrink? = null,
|
||||
var flexWrap: FlexWrap? = null,
|
||||
var float: Float? = null,
|
||||
var font: TextProperty? = null,
|
||||
interface DescriptionProvider {
|
||||
fun description(): String
|
||||
}
|
||||
|
||||
var color: Color? = null,
|
||||
var fontFamily: TextProperty? = null,
|
||||
var fontSize: FontSize? = null,
|
||||
var height: Measurement? = null,
|
||||
var left: Measurement? = null,
|
||||
var top: Measurement? = null,
|
||||
var transitionDelay: DelayDuration? = null,
|
||||
var transitionDuration: DelayDuration? = null,
|
||||
var width: Measurement? = null
|
||||
) : CssGenerator() {
|
||||
class ValueDescriptionProvider(
|
||||
val value: String
|
||||
) : DescriptionProvider {
|
||||
|
||||
override fun description() = value
|
||||
|
||||
}
|
||||
|
||||
fun id(name: String) : DescriptionProvider = ValueDescriptionProvider("#$name")
|
||||
fun cls(name: String) : DescriptionProvider = ValueDescriptionProvider(".$name")
|
||||
fun attr(name: String) : DescriptionProvider = ValueDescriptionProvider("[$name]")
|
||||
fun attrEquals(name: String, value: String) : DescriptionProvider = ValueDescriptionProvider("[$name=$value]")
|
||||
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()}")
|
||||
fun attr(name: DescriptionProvider) : DescriptionProvider = ValueDescriptionProvider("[${name.description()}]")
|
||||
fun attrEquals(name: DescriptionProvider, value: String) : DescriptionProvider = ValueDescriptionProvider("[${name.description()}=$value]")
|
||||
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
|
||||
open class Style : CssGenerator() {
|
||||
var fontFace: FontFace? = null
|
||||
var keyFrames: MutableMap<String, KeyFrames> = mutableMapOf()
|
||||
|
||||
private val validators = mapOf<String, List<Validator>>(
|
||||
"background-position" to listOf(InitialInheritSingleValue()),
|
||||
"background-size" to listOf(MaxCountValidator(2)),
|
||||
@@ -261,6 +248,8 @@ open class Style(
|
||||
MaxCountValidator(4),
|
||||
InitialInheritSingleValue()
|
||||
),
|
||||
|
||||
"animation-iteration-mode" to listOf(MaxCountValidator(4)),
|
||||
"animation-timing-function" to listOf(MaxCountValidator(4)),
|
||||
"border-image-repeat" to listOf(MaxCountValidator(2)),
|
||||
"border-image-slice" to listOf(MaxCountValidator(4)),
|
||||
@@ -270,122 +259,415 @@ open class Style(
|
||||
|
||||
override fun getValidator(name: String) = validators[name]
|
||||
|
||||
override fun getMapping(): Map<String, Any?> = mapOf(
|
||||
"align-content" to alignContent,
|
||||
"align-items" to alignItems,
|
||||
"align-self" to alignSelf,
|
||||
"all" to all,
|
||||
"animation" to animation,
|
||||
"animation-delay" to animationDelay,
|
||||
"animation-direction" to animationDirection,
|
||||
"animation-duration" to animationDuration,
|
||||
"animation-fill-mode" to animationFillMode,
|
||||
"animation-iteration-count" to animationIterationCount,
|
||||
"animation-frame" to animationFrame,
|
||||
"animation-name" to animationName,
|
||||
"animation-play-state" to animationPlayState,
|
||||
"animation-timing-function" to animationTimingFunction,
|
||||
"backface-visibility" to backfaceVisibility,
|
||||
"background" to background,
|
||||
"background-attachment" to backgroundAttachment,
|
||||
"background-blend-mode" to backgroundBlendMode,
|
||||
"background-clip" to backgroundClip,
|
||||
"background-color" to backgroundColor,
|
||||
"background-image" to backgroundImage,
|
||||
"background-origin" to backgroundOrigin,
|
||||
"background-position" to backgroundPosition,
|
||||
"background-repeat" to backgroundRepeat,
|
||||
"background-size" to backgroundSize,
|
||||
"border" to border,
|
||||
"border-bottom" to borderBottom,
|
||||
"border-bottom-color" to borderBottomColor,
|
||||
"border-bottom-left-radius" to borderBottomLeftRadius,
|
||||
"border-bottom-right-radius" to borderBottomRightRadius,
|
||||
"border-bottom-style" to borderBottomStyle,
|
||||
"border-bottom-width" to borderBottomWidth,
|
||||
"border-collapse" to borderCollapse,
|
||||
"border-color" to borderColor,
|
||||
"border-image" to borderImage,
|
||||
"border-image-outset" to borderImageOutset,
|
||||
"border-image-repeat" to borderImageRepeat,
|
||||
"border-image-slice" to borderImageSlice,
|
||||
"border-image-source" to borderImageSource,
|
||||
"border-image-width" to borderImageWidth,
|
||||
"border-left" to borderLeft,
|
||||
"border-left-color" to borderLeftColor,
|
||||
"border-left-style" to borderLeftStyle,
|
||||
"border-left-width" to borderLeftWidth,
|
||||
"border-radius" to borderRadius,
|
||||
"border-right" to borderRight,
|
||||
"border-right-color" to borderRightColor,
|
||||
"border-right-style" to borderRightStyle,
|
||||
"border-right-width" to borderRightWidth,
|
||||
"border-spacing" to borderSpacing,
|
||||
"border-style" to borderStyle,
|
||||
"border-top" to borderTop,
|
||||
"border-top-color" to borderTopColor,
|
||||
"border-top-left-radius" to borderTopLeftRadius,
|
||||
"border-top-right-radius" to borderTopRightRadius,
|
||||
"border-top-style" to borderTopStyle,
|
||||
"border-top-width" to borderTopWidth,
|
||||
"bottom" to bottom,
|
||||
"box-decoration-break" to boxDecorationBreak,
|
||||
"box-shadow" to boxShadow,
|
||||
"box-sizing" to boxSizing,
|
||||
"break-after" to breakAfter,
|
||||
"break-before" to breakBefore,
|
||||
"break-inside" to breakInside,
|
||||
"caption-side" to captionSide,
|
||||
"caret-color" to caretColor,
|
||||
//"@charset" to charset,
|
||||
"clear" to clear,
|
||||
"clip" to clip,
|
||||
"clip-path" to clipPath,
|
||||
"color" to color,
|
||||
"column-count" to columnCount,
|
||||
"column-fill" to columnFill,
|
||||
"column-gap" to columnGap,
|
||||
"column-rule" to columnRule,
|
||||
"column-rule-color" to columnRuleColor,
|
||||
"column-rule-style" to columnRuleStyle,
|
||||
"column-rule-width" to columnRuleWidth,
|
||||
"column-span" to columnSpan,
|
||||
"column-width" to columnWidth,
|
||||
"columns" to columns,
|
||||
"content" to content,
|
||||
"counter-increment" to counterIncrement,
|
||||
"counter-reset" to counterReset,
|
||||
"cursor" to cursor,
|
||||
"direction" to direction,
|
||||
"display" to display,
|
||||
"empty-cells" to emptyCells,
|
||||
"filter" to filter,
|
||||
"flex" to flex,
|
||||
"float" to float,
|
||||
"font" to font,
|
||||
private fun addStyle(selector: String, style: Css) {
|
||||
definitions[selector] = definitions[selector] ?: mutableListOf()
|
||||
definitions[selector]?.add(style)
|
||||
}
|
||||
|
||||
/**
|
||||
* like the scss &
|
||||
* @param selector blabla
|
||||
*/
|
||||
fun and(selector: DescriptionProvider, style: Css) {
|
||||
addStyle(selector.description(), style)
|
||||
}
|
||||
|
||||
"font-family" to fontFamily,
|
||||
"font-size" to fontSize,
|
||||
"height" to height,
|
||||
"left" to left,
|
||||
"top" to top,
|
||||
"transition-delay" to transitionDelay,
|
||||
"transition-duration" to transitionDuration,
|
||||
"width" to width
|
||||
)
|
||||
fun and(selector: String, style: Css) {
|
||||
addStyle(selector, style)
|
||||
}
|
||||
|
||||
fun select(selector: DescriptionProvider, style: Css) {
|
||||
addStyle(" ${selector.description()}", style)
|
||||
}
|
||||
|
||||
fun select(selector: String, style: Css) {
|
||||
definitions[selector] = style
|
||||
addStyle(" $selector", style)
|
||||
}
|
||||
|
||||
fun apply(style: Css) {
|
||||
style(this)
|
||||
fun descendant(descName: DescriptionProvider, style: Css) {
|
||||
addStyle(" ${descName.description()}", style)
|
||||
}
|
||||
|
||||
fun descendant(descName: String, style: Css) {
|
||||
addStyle(" $descName", style)
|
||||
}
|
||||
|
||||
fun child(childName: DescriptionProvider, style: Css) {
|
||||
addStyle(" > ${childName.description()}", style)
|
||||
}
|
||||
|
||||
fun child(childName: String, style: Css) {
|
||||
addStyle(" > $childName", style)
|
||||
}
|
||||
|
||||
fun sibling(childName: DescriptionProvider, style: Css) {
|
||||
addStyle(" ~ ${childName.description()}", style)
|
||||
}
|
||||
|
||||
fun sibling(childName: String, style: Css) {
|
||||
addStyle(" ~ $childName", style)
|
||||
}
|
||||
|
||||
fun adjSibling(childName: DescriptionProvider, style: Css) {
|
||||
addStyle(" + ${childName.description()}", style)
|
||||
}
|
||||
|
||||
fun adjSibling(childName: String, style: Css) {
|
||||
addStyle(" + $childName", style)
|
||||
}
|
||||
|
||||
fun active(style: Css) {
|
||||
addStyle(":active", style)
|
||||
}
|
||||
|
||||
fun focus(style: Css) {
|
||||
addStyle(":focus", style)
|
||||
}
|
||||
|
||||
fun focusWithin(style: Css) {
|
||||
addStyle(":focus-within", style)
|
||||
}
|
||||
|
||||
fun hover(style: Css) {
|
||||
addStyle(":hover", 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)
|
||||
}
|
||||
|
||||
fun plain(name: String, value: CssProperty) {
|
||||
props[name] = prp(value)
|
||||
}
|
||||
|
||||
fun alignContent(value: AlignContent) { props["align-content"] = prp(value) }
|
||||
fun alignItems(alignItems: AlignItems) { props["align-items"] = prp(alignItems) }
|
||||
fun all(all: All) { props["all"] = prp(all) }
|
||||
fun alignSelf(alignSelf: AlignSelf) { props["align-self"] = prp(alignSelf) }
|
||||
fun animation(text: String) { props["animation"] = prp(text) }
|
||||
fun animationDelay(delay: DelayDuration) { props["animation-delay"] = prp(delay) }
|
||||
fun animationDirection(direction: AnimationDirection) { props["animation-direction"] = prp(direction) }
|
||||
fun animationDuration(duration: DelayDuration) { props["animation-duration"] = prp(duration) }
|
||||
fun animationFillMode(fillMode: AnimationFillMode) { props["animation-fill-mode"] = prp(fillMode) }
|
||||
fun animationIterationMode(vararg iterationMode: Count) { props["animation-iteration-mode"] = prp(*iterationMode) }
|
||||
fun animationFrame(frame: AnimationFrame) { props["animation-frame"] = prp(frame) }
|
||||
fun animationName(vararg name: String) { props["animation-name"] = prp(*name) }
|
||||
fun animationPlayState(vararg state : AnimationPlayState) {
|
||||
props["animation-play-state"] = prp(*state)
|
||||
}
|
||||
fun animationTimingFunction(vararg timingFunction: TimingFunction) {
|
||||
props["animation-timing-function"] = prp(*timingFunction)
|
||||
}
|
||||
fun backfaceVisibility(backfaceVisibility: BackfaceVisibility) { props[""] = prp(backfaceVisibility) }
|
||||
fun background(background: String) { props["background"] = prp(background) }
|
||||
fun backgroundAttachment(attachment: BackgroundAttachment) { props["background-attachment"] = prp(attachment) }
|
||||
fun backgroundBlendMode(blendMode: BackgroundBlendMode) { props["background-blend-mode"] = prp(blendMode) }
|
||||
fun backgroundClip(clip: ClipOrigin) { props["background-clip"] = prp(clip) }
|
||||
fun backgroundColor(color: Color) { props["background-color"] = prp(color) }
|
||||
fun backgroundImage(image: Image) { props["background-image"] = prp(image) }
|
||||
fun backgroundOrigin(origin: ClipOrigin) { props["background-origin"] = prp(origin) }
|
||||
fun backgroundPosition(position: BackgroundPosition) { props["background-position"] = prp(position) }
|
||||
fun backgroundRepeat(repeat: BackgroundRepeat) { props["background-repeat"] = prp(repeat) }
|
||||
fun backgroundSize(vararg size: BackgroundSize) { props["background-size"] = prp(*size) }
|
||||
fun border(border: String) { props["border"] = prp(border) }
|
||||
fun borderBottom(borderBottom: String) { props["border-bottom"] = prp(borderBottom) }
|
||||
fun borderBottomColor(color: Color) { props["border-bottom-color"] = prp(color) }
|
||||
fun borderBottomLeftRadius(vararg radius: BorderRadius) { props["border-bottom-left-radius"] = prp(*radius) }
|
||||
fun borderBottomRightRadius(vararg radius: BorderRadius) { props["border-bottom-right-radius"] = prp(*radius) }
|
||||
fun borderBottomStyle(style: BorderStyle) { props["border-bottom-style"] = prp(style) }
|
||||
fun borderBottomWidth(width: BorderWidth) { props["border-bottom-width"] = prp(width) }
|
||||
fun borderBottomWidth(width: Measurement) { props["border-bottom-width"] = prp(width) }
|
||||
fun borderCollapse(collapse: BorderCollapse) { props["border-collapse"] = prp(collapse) }
|
||||
fun borderColor(vararg color: Color) { props["border-color"] = prp(*color) }
|
||||
fun borderImage(image: String) { props["border-image"] = prp(image) }
|
||||
fun borderImageOutset(imageOutset: Length) { props["border-image-outset"] = prp(imageOutset) }
|
||||
fun borderImageRepeat(vararg repeat: ImageRepeat) { props["border-image-repeat"] = prp(*repeat) }
|
||||
fun borderImageSlice(vararg slice: ImageSlice) { props["border-image-slice"] = prp(*slice) }
|
||||
fun borderImageSource(vararg source: ImageSource) { props["border-image-source"] = prp(*source) }
|
||||
fun borderImageWidth(vararg width: BorderImageWidth) { props["border-image-width"] = prp(*width) }
|
||||
fun borderLeft(left: String) { props["border-left"] = prp(left) }
|
||||
fun borderLeftColor(color: Color) { props["border-left-color"] = prp(color) }
|
||||
fun borderLeftStyle(style: BorderStyle) { props["border-left-style"] = prp(style) }
|
||||
fun borderLeftWidth(width: BorderWidth) { props["border-left-width"] = prp(width) }
|
||||
fun borderLeftWidth(width: Measurement) { props["border-left-width"] = prp(width) }
|
||||
fun borderRadius(radius: Measurement) { props["border-radius"] = prp(radius) }
|
||||
fun borderRadius(
|
||||
topLeftBottomRight: Measurement,
|
||||
topRightBottomLeft: Measurement
|
||||
) {
|
||||
props["border-radius"] = listOf(
|
||||
topLeftBottomRight, topRightBottomLeft
|
||||
)
|
||||
}
|
||||
|
||||
fun borderRadius(
|
||||
topLeft: Measurement,
|
||||
topRightBottomLeft: Measurement,
|
||||
bottomRight: Measurement
|
||||
) {
|
||||
props["border-radius"] = listOf(
|
||||
topLeft, topRightBottomLeft, bottomRight
|
||||
)
|
||||
}
|
||||
|
||||
fun borderRadius(
|
||||
topLeft: Measurement,
|
||||
topRight: Measurement,
|
||||
bottomRight: Measurement,
|
||||
bottomLeft: Measurement
|
||||
) {
|
||||
props["border-radius"] = listOf(
|
||||
topLeft, topRight, bottomRight, bottomLeft
|
||||
)
|
||||
}
|
||||
fun borderRight(border: String) { props["border-right"] = prp(border) }
|
||||
fun borderRightColor(color: Color) { props["border-right-color"] = prp(color) }
|
||||
fun borderRightStyle(style: BorderStyle) { props["border-right-style"] = prp(style) }
|
||||
fun borderRightWidth(width: BorderWidth) { props["border-right-width"] = prp(width) }
|
||||
fun borderRightWidth(width: Measurement) { props["border-right-width"] = prp(width) }
|
||||
fun borderSpacing(vararg spacing: BorderSpacing) { props["border-spacing"] = prp(*spacing) }
|
||||
fun borderStyle(vararg style: BorderStyle) { props["border-style"] = prp(*style) }
|
||||
fun borderTop(border: String) { props["border-top"] = prp(border) }
|
||||
fun borderTopColor(color: Color) { props["border-top-color"] = prp(color) }
|
||||
fun borderTopLeftRadius(radius: BorderRadius) { props["border-top-left-radius"] = prp(radius) }
|
||||
fun borderTopRightRadius(radius: BorderRadius) { props["border-top-right-radius"] = prp(radius) }
|
||||
fun borderTopStyle(style: BorderStyle) { props["border-top-style"] = prp(style) }
|
||||
fun borderTopWidth(width: BorderWidth) { props["border-top-width"] = prp(width) }
|
||||
fun borderTopWidth(width: Measurement) { props["border-top-width"] = prp(width) }
|
||||
fun borderWidth(width: Measurement) { props["border-width"] = prp(width) }
|
||||
fun borderWidth(width: BorderWidth) { props["border-width"] = prp(width) }
|
||||
fun bottom(measurement: Measurement) { props["bottom"] = prp(measurement) }
|
||||
fun boxDecorationBreak(brk: BoxDecorationBreak) { props["box-decoration-break"] = prp(brk) }
|
||||
fun boxShadow(shadow: BoxShadow) { props["box-shadow"] = prp(shadow) }
|
||||
fun boxSizing(sizing: BoxSizing) { props["box-sizing"] = prp(sizing) }
|
||||
fun breakAfter(brk: Break) { props["break-after"] = prp(brk) }
|
||||
fun breakBefore(brk: Break) { props["break-before"] = prp(brk) }
|
||||
fun breakInside(brk: Break) { props["break-inside"] = prp(brk) }
|
||||
fun captionSide(side: CaptionSide) { props["caption-side"] = prp(side) }
|
||||
fun caretColor(color: Color) { props["caret-color"] = prp(color) }
|
||||
fun clear(clear: Clear) { props["clear"] = prp(clear) }
|
||||
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) }
|
||||
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) }
|
||||
fun columnRule(rule: String) { props["column-rule"] = prp(rule) }
|
||||
fun columnRuleColor(color: Color) { props["column-rule-color"] = prp(color) }
|
||||
fun columnRuleStyle(style: BorderStyle) { props["column-rule-style"] = prp(style) }
|
||||
fun columnRuleWidth(width: Measurement) { props["column-rule-width"] = prp(width) }
|
||||
fun columnSpan(span: Span) { props["column-span"] = prp(span) }
|
||||
fun columnWidth(width: Measurement) { props["column-width"] = prp(width) }
|
||||
fun column(column: String) { props["column"] = prp(column) }
|
||||
fun content(content: Content) { props["content"] = prp(content) }
|
||||
fun counterIncrement(increment: String) { props["counter-increment"] = prp(increment) }
|
||||
fun counterReset(reset: String) { props["counter-reset"] = prp(reset) }
|
||||
fun cursor(cursor: String) { props["cursor"] = prp(cursor) }
|
||||
fun direction(direction: Direction) { props["direction"] = prp(direction) }
|
||||
fun display(display: Display) { props["display"] = prp(display) }
|
||||
fun emptyCells(cells: EmptyCells) { props["empty-cells"] = prp(cells) }
|
||||
fun filter(filter: String) { props["filter"] = prp(filter) }
|
||||
fun flex(flex: String) { props["flex"] = prp(flex) }
|
||||
fun flexBasis(basis: Measurement) { props["flex-basis"] = prp(basis) }
|
||||
fun flexDirection(direction: FlexDirection) { props["flex-direction"] = prp(direction) }
|
||||
fun flexFlow(flow: String) { props["flex-flow"] = prp(flow) }
|
||||
fun flexGrow(grow: FlexGrowShrink) { props["flex-grow"] = prp(grow) }
|
||||
fun flexShrink(shrink: FlexGrowShrink) { props["flex-shrink"] = prp(shrink) }
|
||||
fun flexWrap(wrap: FlexWrap) { props["flex-wrap"] = prp(wrap) }
|
||||
fun float(cssFloat: CssFloat) { props["float"] = prp(cssFloat) }
|
||||
fun font(font: String) { props["font"] = prp(font) }
|
||||
fun fontFace(face: FontFace.() -> Unit) {
|
||||
fontFace = FontFace()
|
||||
|
||||
face.invoke(fontFace!!)
|
||||
}
|
||||
fun fontFamily(font: String) { props["font-family"] = prp(font) }
|
||||
fun fontFeatureSettings(vararg setting: String) { props["font-feature-settings"] = prp(*setting) }
|
||||
fun fontKerning(kerning: FontKerning) { props["font-kerking"] = prp(kerning) }
|
||||
fun fontSize(size: FontSize) { props["font-size"] = prp(size) }
|
||||
fun fontSize(size: Measurement) { props["font-size"] = prp(size) }
|
||||
fun fontSizeAdjust(number: Double) { props["font-size-adjust"] = prp(CssProperty("$number")) }
|
||||
fun fontSizeAdjust(adjust: FontSizeAdjust) { props["font-size-adjust"] = prp(adjust) }
|
||||
fun fontStretch(stretch: FontStretch) { props["font-stretch"] = prp(stretch) }
|
||||
fun fontStyle(style: FontStyle) { props["font-style"] = prp(style) }
|
||||
fun fontVariant(variant: FontVariant) { props["font-variant"] = prp(variant) }
|
||||
fun fontVariantCaps(caps: FontVariantCaps) { props["font-variant-caps"] = prp(caps) }
|
||||
fun fontWeight(weight: FontWeight) { props["font-weight"] = prp(weight) }
|
||||
fun grid(grid: String) { props["grid"] = prp(grid) }
|
||||
fun gridArea(area: String) { props["grid-area"] = prp(area) }
|
||||
fun gridAutoColumns(columns: GridAuto) { props["grid-auto-columns"] = prp(columns) }
|
||||
fun gridAutoFlow(flow: GridFlow) { props["grid-auto-flow"] = prp(flow) }
|
||||
fun gridAutoRows(autoRows: GridAuto) { props["grid-auto-rows"] = prp(autoRows) }
|
||||
fun gridAutoRows(size: Measurement) { props["grid-auto-rows"] = prp(size) }
|
||||
fun gridColumn(start: GridValue, end: GridValue) { props["grid-column"] = prp(CssProperty("${start.css()}/${end.css()}")) }
|
||||
fun gridColumnEnd(end: GridValue) { props["grid-column-end"] = prp(end) }
|
||||
fun gridColumnGap(gap: GridValue) { props["grid-column-gap"] = prp(gap) }
|
||||
fun gridColumnStart(start: GridValue) { props["grid-column-start"] = prp(start) }
|
||||
fun gridGap(
|
||||
rowGap: Measurement = Measurement.px(0),
|
||||
columnGap: Measurement = Measurement.px(0)
|
||||
) { props["grid-gap"] = prp(rowGap, columnGap) }
|
||||
fun gridRow(start: GridValue, end: GridValue) { props["grid-row"] = prp(CssProperty("${start.css()}/${end.css()}")) }
|
||||
fun gridRowEnd(end: GridValue) { props["grid-row-end"] = prp(end) }
|
||||
fun gridRowGap(gap: GridValue) { props["grid-row-end"] = prp(gap) }
|
||||
fun gridRowStart(start: GridValue) { props["grid-row-start"] = prp(start) }
|
||||
fun gridTemplate(template: String) { props["grid-template"] = prp(template) }
|
||||
fun gridTemplateAreas(template: String) { props["grid-template-areas"] = prp(template) }
|
||||
@Deprecated(
|
||||
"Fixed type, use gridTemplateColumns instead",
|
||||
ReplaceWith("gridTemplateColumns(columns)")
|
||||
)
|
||||
fun gridTemplateColumn(vararg columns: TemplateRowColumn) { props["grid-template-columns"] = prp(*columns) }
|
||||
fun gridTemplateColumns(vararg columns: TemplateRowColumn) { props["grid-template-columns"] = prp(*columns) }
|
||||
fun gridTemplateColumns(vararg columns: Measurement) { props["grid-template-columns"] = prp(*columns) }
|
||||
fun gridTemplateRows(vararg rows: TemplateRowColumn) { props["grid-template-rows"] = prp(*rows) }
|
||||
fun gridTemplateRows(vararg rows: Measurement) { props["grid-template-rows"] = prp(*rows) }
|
||||
fun hangingPunctuation(punctuation: Isolation) { props["hanging-punctuation"] = prp(punctuation) }
|
||||
fun height(height: Measurement) { props["height"] = prp(height) }
|
||||
fun hyphens(hyphens: Hyphens) { props["hyphens"] = prp(hyphens) }
|
||||
fun import(style: Css) { style(this) }
|
||||
fun isolation(isolation: Isolation) { props["isolation"] = prp(isolation) }
|
||||
fun justifyContent(content: JustifyContent) { 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) }
|
||||
fun letterSpacing(length: Measurement) { props["letter-spacing"] = prp(length) }
|
||||
fun letterSpacing(spacing: LetterSpacing) { props["letter-spacing"] = prp(spacing) }
|
||||
fun lineHeight(number: Double) { props["line-height"] = prp("$number") }
|
||||
fun lineHeight(measurement: Measurement) { props["line-height"] = prp(measurement) }
|
||||
fun lineHeight(height: LineHeight) { props["line-height"] = prp(height) }
|
||||
fun listStyle(style: String) { props["list-style"] = prp(style) }
|
||||
fun listStyleImage(url: String) { props["list-style-image"] = prp("url('$url')")}
|
||||
fun listStylePosition(position: ListStylePosition) { props["list-style-position"] = prp(position) }
|
||||
fun listStyleType(position: ListStyleType) { props["list-style-type"] = prp(position) }
|
||||
fun margin(all: Measurement) { props["margin"] = prp(all) }
|
||||
fun margin(
|
||||
topBottom: Measurement,
|
||||
leftRight: Measurement
|
||||
) { props["margin"] = prp(topBottom, leftRight) }
|
||||
fun margin(top: Measurement, right: Measurement, bottom: Measurement, left: Measurement) {
|
||||
props["margin"] = prp(top, right, bottom, left)
|
||||
}
|
||||
fun marginBottom(bottom: Measurement) { props["margin-bottom"] = prp(bottom) }
|
||||
fun marginLeft(left: Measurement) { props["margin-left"] = prp(left) }
|
||||
fun marginRight(right: Measurement) { props["margin-right"] = prp(right) }
|
||||
fun marginTop(top: Measurement) { props["margin-top"] = prp(top) }
|
||||
fun maxHeight(height: Measurement) { props["max-height"] = prp(height) }
|
||||
fun maxWidth(width: Measurement) { props["max-width"] = prp(width) }
|
||||
fun minHeight(height: Measurement) { props["min-height"] = prp(height) }
|
||||
fun minWidth(width: Measurement) { props["min-width"] = prp(width) }
|
||||
fun mixBlendMode(blendMode: MixBlendMode) { props["mix-blend-mode"] = prp(blendMode) }
|
||||
fun objectFit(fit: ObjectFit) { props["object-fit"] = prp(fit) }
|
||||
fun objectPosition(position: String) { props["object-position"] = prp(position) }
|
||||
fun opacity(opacity: Double) { props["opacity"] = prp(opacity.toString()) }
|
||||
fun opacity(opacity: InitialInherit) { props["opacity"] = prp(opacity.toString()) }
|
||||
fun order(order: Int) { props["order"] = prp(order.toString()) }
|
||||
fun order(order: InitialInherit) { props["order"] = prp(order) }
|
||||
fun outline(outline: String) { props["outline"] = prp(outline) }
|
||||
fun outlineColor(color: Color) { props["outline-color"] = prp(color) }
|
||||
fun outlineOffset(offset: Measurement) { props["outline-offset"] = prp(offset) }
|
||||
fun outlineStyle(style: BorderStyle) { props["outline-style"] = prp(style) }
|
||||
fun outlineWidth(width: OutlineWidth) { props["outline-width"] = prp(width) }
|
||||
fun outlineWidth(width: Measurement) { props["outline-width"] = prp(width) }
|
||||
fun overflow(overflow: Overflow) { props["overflow"] = prp(overflow) }
|
||||
fun overflowX(overflow: Overflow) { props["overflow-x"] = prp(overflow) }
|
||||
fun overflowY(overflow: Overflow) { props["overflow-y"] = prp(overflow) }
|
||||
fun padding(padding: Measurement) { props["padding"] = prp(padding) }
|
||||
fun padding(vertical: Measurement, horizontal: Measurement) {
|
||||
props["padding"] = prp(vertical, horizontal)
|
||||
}
|
||||
fun padding(top: Measurement, right: Measurement, bottom: Measurement, left: Measurement) {
|
||||
props["padding"] = prp(top, right, bottom, left)
|
||||
}
|
||||
fun padding(padding: InitialInherit) { props["padding"] = prp(padding) }
|
||||
fun paddingBottom(padding: Measurement) { props["padding-bottom"] = prp(padding) }
|
||||
fun paddingBottom(padding: InitialInherit) { props["padding-bottom"] = prp(padding) }
|
||||
fun paddingLeft(padding: Measurement) { props["padding-left"] = prp(padding) }
|
||||
fun paddingLeft(padding: InitialInherit) { props["padding-left"] = prp(padding) }
|
||||
fun paddingRight(padding: Measurement) { props["padding-right"] = prp(padding) }
|
||||
fun paddingRight(padding: InitialInherit) { props["padding-right"] = prp(padding) }
|
||||
fun paddingTop(padding: Measurement) { props["padding-top"] = prp(padding) }
|
||||
fun paddingTop(padding: InitialInherit) { props["padding-top"] = prp(padding) }
|
||||
fun pageBreakAfter(pageBreak: PageBreak) { props["page-break-after"] = prp(pageBreak) }
|
||||
fun pageBreakBefore(pageBreak: PageBreak) { props["page-break-before"] = prp(pageBreak) }
|
||||
fun pageBreakInside(pageBreak: PageBreak) { props["page-break-inside"] = prp(pageBreak) }
|
||||
fun perspective(length: Measurement) { props["perspective"] = prp(length) }
|
||||
fun perspective(perspective: Perspective) { props["perspective"] = prp(perspective) }
|
||||
fun perspectiveOrigin(po: String) { props["perspective-origin"] = prp(po) }
|
||||
fun pointerEvents(pe: PointerEvents) { props["pointer-events"] = prp(pe) }
|
||||
fun position(poition: Position) { props["position"] = prp(poition) }
|
||||
fun quotes(value: String) { props["quotes"] = prp(value) }
|
||||
fun resize(resize: Resize) { props["resize"] = prp(resize) }
|
||||
fun right(right: Measurement) { props["right"] = prp(right) }
|
||||
fun scrollBehavior(sb: ScrollBehavior) { props["scroll-behavior"] = prp(sb) }
|
||||
fun tabSize(number: Int) { props["tab-size"] = prp(number.toString()) }
|
||||
fun tabSize(length: Measurement) { props["tab-size"] = prp(length) }
|
||||
fun tabSize(ts: InitialInherit) { props["tab-size"] = prp(ts) }
|
||||
fun tableLayout(tl: TableLayout ) { props["table-layout"] = prp(tl) }
|
||||
fun textAlign(ta: TextAlign) { props["text-align"] = prp(ta) }
|
||||
fun textAlignLast(tal: TextAlignLast) { props["text-align-last"] = prp(tal) }
|
||||
fun textDecoration(decoration: String) { props["text-decoration"] = prp(decoration) }
|
||||
fun textDecorationColor(color: Color) { props["text-decoration-color"] = prp(color) }
|
||||
fun textDecorationLine(tdc: TextDecorationLine) { props["text-decoration-line"] = prp(tdc) }
|
||||
fun textDecorationStyle(tds: TextDecorationStyle) { props["text-decoration-style"] = prp(tds) }
|
||||
fun textIndent(length: Measurement) { props["text-indent"] = prp(length) }
|
||||
fun textIndent(indent: InitialInherit) { props["text-indent"] = prp(indent) }
|
||||
fun textJustify(tj: TextJustify) { props["text-justify"] = prp(tj) }
|
||||
fun textOverflow(to: String) { props["text-overflow"] = prp(to) }
|
||||
fun textShadow(ts: String) { props["text-shadow"] = prp(ts) }
|
||||
fun textTransform(tt: TextTransform) { props["text-transform"] = prp(tt) }
|
||||
fun top(top: Measurement) { props["top"] = prp(top) }
|
||||
fun transform(transform: Transform) { props["transform"] = prp(transform) }
|
||||
fun transformOrigin(origin: String) { props["transform-origin"] = prp(origin) }
|
||||
fun transformStyle(style: TransformStyle) { props["transform-style"] = prp(style) }
|
||||
fun transition(transition: String) { props["transition"] = prp(transition) }
|
||||
fun transitionDelay(timeInSeconds: Double) { props["transition-delay"] = prp("${timeInSeconds}s") }
|
||||
fun transitionDelay(timeInMillis: Int) { props["transition-delay"] = prp("${timeInMillis}ms") }
|
||||
fun transitionDelay(delay: DelayDuration) { props["transition-delay"] = prp(delay) }
|
||||
fun transitionDuration(timeInSeconds: Double) { props["transition-duration"] = prp("${timeInSeconds}s") }
|
||||
fun transitionDuration(timeInMillis: Int) { props["transition-duration"] = prp("${timeInMillis}ms") }
|
||||
fun transitionDuration(td: DelayDuration) { props["transition-duration"] = prp(td) }
|
||||
fun transitionProperty(property: String) { props["transition-property"] = prp(property) }
|
||||
fun transitionTimingFunction(function: TimingFunction) { props["transition-timing-function"] = prp(function) }
|
||||
fun unicodeBidi(ub: UnicodeBidi) { props["unicode-bidi"] = prp(ub) }
|
||||
fun userSelect(us: UserSelect) { props["user-select"] = prp(us) }
|
||||
fun verticalAlign(length: Measurement) { props["vertical-align"] = prp(length) }
|
||||
fun verticalAlign(va: VerticalAlign) { props["vertical-align"] = prp(va) }
|
||||
fun visibility(visibility: Visibility) { props["visibility"] = prp(visibility) }
|
||||
fun whiteSpace(whiteSpace: WhiteSpace) { props["white-space"] = prp(whiteSpace) }
|
||||
fun width(width: Measurement) { props["width"] = prp(width) }
|
||||
fun wordBreak(wordBreak: WordBreak) { props["word-break"] = prp(wordBreak) }
|
||||
fun wordSpacing(wordSpacing: Measurement) { props["word-spacing"] = prp(wordSpacing) }
|
||||
fun wordSpacing(wordSpacing: WordSpacing) { props["word-spacing"] = prp(wordSpacing) }
|
||||
fun wordWrap(wordWrap: WordWrap) { props["word-wrap"] = prp(wordWrap) }
|
||||
fun writingMode(writingMode: WritingMode) { props["writing-mode"] = prp(writingMode) }
|
||||
fun zIndex(zIndex: Int) { props["z-index"] = prp(zIndex.toString()) }
|
||||
fun zIndex(zIndex: ZIndex) { props["z-index"] = prp(zIndex) }
|
||||
}
|
||||
|
||||
@CssTagMarker
|
||||
open class ConditionalStyle : Style() {
|
||||
var media: MutableMap<String, ConditionalCss> = mutableMapOf()
|
||||
var supports: MutableMap<String, ConditionalCss> = mutableMapOf()
|
||||
|
||||
fun media(definition: String, style: ConditionalCss) {
|
||||
media[definition] = style
|
||||
}
|
||||
|
||||
fun supports(query: String, style: ConditionalCss) {
|
||||
supports[query] = style
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user