More properties, cleanup
This commit is contained in:
@@ -72,3 +72,37 @@ class BorderCollapse(
|
||||
fun collapse() = BorderWidth("collapse")
|
||||
}
|
||||
}
|
||||
|
||||
class BorderImageWidth (
|
||||
value: String
|
||||
): CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun px(nr: Int) = BorderRadius("${nr}px")
|
||||
fun nr(nr: Int) = Image("$nr")
|
||||
fun perc(nr: Int) = BorderRadius("${nr}%")
|
||||
fun perc(nr: Double) = BorderRadius("${nr}%")
|
||||
fun auto() = BorderWidth("auto")
|
||||
fun initial() = BorderWidth("initial")
|
||||
fun inherit() = BorderWidth("inherit")
|
||||
}
|
||||
}
|
||||
|
||||
class BorderSpacing(
|
||||
value: String
|
||||
): CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun px(nr: Int) = BorderRadius("${nr}px")
|
||||
fun em(nr: Int) = BorderRadius("${nr}em")
|
||||
fun em(nr: Double) = BorderRadius("${nr}em")
|
||||
fun perc(nr: Int) = BorderRadius("${nr}%")
|
||||
fun perc(nr: Double) = BorderRadius("${nr}%")
|
||||
fun pc(nr: Int) = BorderRadius("${nr}pc")
|
||||
fun pc(nr: Double) = BorderRadius("${nr}pc")
|
||||
fun cm(nr: Int) = BorderRadius("${nr}cm")
|
||||
fun cm(nr: Double) = BorderRadius("${nr}cm")
|
||||
fun initial() = BorderRadius("initial")
|
||||
fun inherit() = BorderRadius("inherit")
|
||||
}
|
||||
}
|
||||
|
||||
39
src/commonMain/kotlin/nl/astraeus/css/properties/Box.kt
Normal file
39
src/commonMain/kotlin/nl/astraeus/css/properties/Box.kt
Normal file
@@ -0,0 +1,39 @@
|
||||
package nl.astraeus.css.properties
|
||||
|
||||
class BoxDecorationBreak(
|
||||
value: String
|
||||
): CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun slice() = BorderWidth("slice")
|
||||
fun clone() = BorderWidth("clone")
|
||||
fun initial() = BorderWidth("initial")
|
||||
fun inherit() = BorderWidth("inherit")
|
||||
fun unset() = BorderWidth("unset")
|
||||
}
|
||||
}
|
||||
|
||||
class BoxShadow(
|
||||
value: String
|
||||
): CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun none() = BoxShadow("none")
|
||||
fun text(txt: String) = BoxShadow(txt)
|
||||
fun inset() = BoxShadow("inset")
|
||||
fun initial() = BoxShadow("initial")
|
||||
fun inherit() = BoxShadow("inherit")
|
||||
}
|
||||
}
|
||||
|
||||
class BoxSizing(
|
||||
value: String
|
||||
): CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun contextBox() = BoxSizing("content-box")
|
||||
fun borderBox() = BoxSizing("border-box")
|
||||
fun initial() = BoxShadow("initial")
|
||||
fun inherit() = BoxShadow("inherit")
|
||||
}
|
||||
}
|
||||
27
src/commonMain/kotlin/nl/astraeus/css/properties/Break.kt
Normal file
27
src/commonMain/kotlin/nl/astraeus/css/properties/Break.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package nl.astraeus.css.properties
|
||||
|
||||
|
||||
class Break(
|
||||
value: String
|
||||
): CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun auto() = Break("auto")
|
||||
fun all() = Break("all")
|
||||
fun always() = Break("always")
|
||||
fun avoid() = Break("avoid")
|
||||
fun avoidColumn() = Break("avoid-column")
|
||||
fun avoidPage() = Break("avoid-page")
|
||||
fun avoidRegion() = Break("avoid-region")
|
||||
fun column() = Break("column")
|
||||
fun left() = Break("left")
|
||||
fun page() = Break("page")
|
||||
fun recto() = Break("recto")
|
||||
fun region() = Break("region")
|
||||
fun right() = Break("right")
|
||||
fun verso() = Break("verso")
|
||||
fun initial() = Break("initial")
|
||||
fun inherit() = Break("inherit")
|
||||
}
|
||||
|
||||
}
|
||||
14
src/commonMain/kotlin/nl/astraeus/css/properties/Caption.kt
Normal file
14
src/commonMain/kotlin/nl/astraeus/css/properties/Caption.kt
Normal file
@@ -0,0 +1,14 @@
|
||||
package nl.astraeus.css.properties
|
||||
|
||||
class CaptionSide(
|
||||
value: String
|
||||
): CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun top() = BoxSizing("top")
|
||||
fun bottom() = BoxSizing("bottom")
|
||||
fun initial() = BoxShadow("initial")
|
||||
fun inherit() = BoxShadow("inherit")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ class Color(
|
||||
) : CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun auto() = Color("auto")
|
||||
fun transparant() = Color("transparant")
|
||||
fun initial() = Color("initial")
|
||||
fun inherit() = Color("inherit")
|
||||
|
||||
@@ -11,3 +11,48 @@ class Image(
|
||||
fun inherit() = Image("inherit")
|
||||
}
|
||||
}
|
||||
|
||||
class ImageRepeat(
|
||||
value: String
|
||||
) : CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun stretch(url: String) = Image("stretch")
|
||||
fun repeat() = Image("repeat")
|
||||
fun round() = Image("round")
|
||||
fun initial() = Image("initial")
|
||||
fun inherit() = Image("inherit")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ImageSlice(
|
||||
value: String
|
||||
) : CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun nr(nr: Int) = Image("$nr")
|
||||
fun perc(perc: Int) = Image("$perc%")
|
||||
fun perc(perc: Double) = Image("$perc%")
|
||||
fun stretch(url: String) = Image("stretch")
|
||||
fun repeat() = Image("repeat")
|
||||
fun fill() = Image("fill")
|
||||
fun initial() = Image("initial")
|
||||
fun inherit() = Image("inherit")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ImageSource(
|
||||
value: String
|
||||
) : CssProperty(value) {
|
||||
|
||||
companion object {
|
||||
fun none() = ImageSource("none")
|
||||
fun text(txt: String) = ImageSource(txt)
|
||||
fun image(url: String) = ImageSource("'$url'")
|
||||
fun initial() = ImageSource("initial")
|
||||
fun inherit() = ImageSource("inherit")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,13 +44,37 @@ open class Style(
|
||||
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: BorderStyle? = null,
|
||||
var borderLeftWidth: BorderWidth? = null,
|
||||
var borderRadius: List<BorderRadius>? = null,
|
||||
var borderRight: TextProperty? = null,
|
||||
var borderRightColor: Color? = null,
|
||||
var borderRightStyle: BorderStyle? = null,
|
||||
var borderRightWidth: BorderWidth? = null,
|
||||
var borderSpacing: List<BorderSpacing>? = null,
|
||||
var borderStyle: List<BorderStyle>? = null,
|
||||
var borderTop: TextProperty? = null,
|
||||
var borderTopColor: Color? = null,
|
||||
var borderTopLeftRadius: BorderRadius? = null,
|
||||
var borderTopRightRadius: BorderRadius? = null,
|
||||
var borderTopStyle: BorderStyle? = 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 color: Color? = null,
|
||||
var fontFamily: TextProperty? = null,
|
||||
var fontSize: FontSize? = null,
|
||||
@@ -68,7 +92,11 @@ open class Style(
|
||||
MaxCountValidator(4),
|
||||
InitialInheritSingleValue()
|
||||
),
|
||||
"animation-timing-function" 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)),
|
||||
"border-spacing" to listOf(MaxCountValidator(4)),
|
||||
"border-style" to listOf(MaxCountValidator(4))
|
||||
)
|
||||
|
||||
fun getMapping(): Map<String, Any?> = mapOf(
|
||||
@@ -108,13 +136,37 @@ open class Style(
|
||||
"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,
|
||||
"color" to color,
|
||||
"font-family" to fontFamily,
|
||||
"font-size" to fontSize,
|
||||
|
||||
@@ -85,10 +85,18 @@ fun main() {
|
||||
css("div") {
|
||||
color = Color.hex("1b1b1b1")
|
||||
alignContent = flexStart()
|
||||
animationName = listOf(text("foo"), text("bar"))
|
||||
animationName = listOf(
|
||||
text("foo"),
|
||||
text("bar")
|
||||
)
|
||||
animationIterationCount = listOf(
|
||||
Count.count(3), Count.infinite())
|
||||
animationTimingFunction = listOf(AnimationTimingFunction.cubicBezier(0.1, 0.2, 0.3, 0.4), AnimationTimingFunction.easeInOut())
|
||||
Count.count(3),
|
||||
Count.infinite()
|
||||
)
|
||||
animationTimingFunction = listOf(
|
||||
AnimationTimingFunction.cubicBezier(0.1, 0.2, 0.3, 0.4),
|
||||
AnimationTimingFunction.easeInOut()
|
||||
)
|
||||
borderRadius = listOf(
|
||||
BorderRadius.px(4),
|
||||
BorderRadius.px(5),
|
||||
|
||||
Reference in New Issue
Block a user