Reformat code
This commit is contained in:
@@ -2,7 +2,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class AlignItems(
|
class AlignItems(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val stretch = AlignItems("stretch")
|
val stretch = AlignItems("stretch")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class AlignSelf(
|
class AlignSelf(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val auto = AlignSelf("auto")
|
val auto = AlignSelf("auto")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class All(
|
class All(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val unset = All("unset")
|
val unset = All("unset")
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class AnimationFillMode(
|
|||||||
|
|
||||||
class AnimationFrame(
|
class AnimationFrame(
|
||||||
value: String = ""
|
value: String = ""
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun name(name: String) = AnimationFrame(name)
|
fun name(name: String) = AnimationFrame(name)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class BorderRadius(
|
class BorderRadius(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
companion object {
|
companion object {
|
||||||
fun px(nr: Int) = BorderRadius("${nr}px")
|
fun px(nr: Int) = BorderRadius("${nr}px")
|
||||||
fun em(nr: Int) = BorderRadius("${nr}em")
|
fun em(nr: Int) = BorderRadius("${nr}em")
|
||||||
@@ -20,7 +20,7 @@ class BorderRadius(
|
|||||||
|
|
||||||
class BorderStyle(
|
class BorderStyle(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val none = BorderStyle("none")
|
val none = BorderStyle("none")
|
||||||
@@ -40,7 +40,7 @@ class BorderStyle(
|
|||||||
|
|
||||||
class BorderWidth(
|
class BorderWidth(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val thin = BorderWidth("thin")
|
val thin = BorderWidth("thin")
|
||||||
@@ -53,7 +53,7 @@ class BorderWidth(
|
|||||||
|
|
||||||
class BorderCollapse(
|
class BorderCollapse(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val separate = BorderCollapse("separate")
|
val separate = BorderCollapse("separate")
|
||||||
@@ -61,9 +61,9 @@ class BorderCollapse(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BorderImageWidth (
|
class BorderImageWidth(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun px(nr: Int) = BorderImageWidth("${nr}px")
|
fun px(nr: Int) = BorderImageWidth("${nr}px")
|
||||||
@@ -78,7 +78,7 @@ class BorderImageWidth (
|
|||||||
|
|
||||||
class BorderSpacing(
|
class BorderSpacing(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun px(nr: Int) = BorderSpacing("${nr}px")
|
fun px(nr: Int) = BorderSpacing("${nr}px")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class BoxDecorationBreak(
|
class BoxDecorationBreak(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val slice = BoxDecorationBreak("slice")
|
val slice = BoxDecorationBreak("slice")
|
||||||
@@ -15,7 +15,7 @@ class BoxDecorationBreak(
|
|||||||
|
|
||||||
class BoxShadow(
|
class BoxShadow(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val none = BoxShadow("none")
|
val none = BoxShadow("none")
|
||||||
@@ -29,7 +29,7 @@ class BoxShadow(
|
|||||||
|
|
||||||
class BoxSizing(
|
class BoxSizing(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val contextBox = BoxSizing("content-box")
|
val contextBox = BoxSizing("content-box")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class Break(
|
class Break(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val auto = Break("auto")
|
val auto = Break("auto")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class CaptionSide(
|
class CaptionSide(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val top = CaptionSide("top")
|
val top = CaptionSide("top")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class Clear(
|
class Clear(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val none = Clear("none")
|
val none = Clear("none")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package nl.astraeus.css.properties
|
|||||||
|
|
||||||
class Length(
|
class Length(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value) {
|
) : CssProperty(value) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun px(nr: Int) = Length("${nr}px")
|
fun px(nr: Int) = Length("${nr}px")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ interface CssValue {
|
|||||||
|
|
||||||
open class CssProperty(
|
open class CssProperty(
|
||||||
var value: String
|
var value: String
|
||||||
): CssValue {
|
) : CssValue {
|
||||||
|
|
||||||
override fun css(): String = value
|
override fun css(): String = value
|
||||||
|
|
||||||
@@ -16,4 +16,4 @@ fun text(value: String) = TextProperty(value)
|
|||||||
|
|
||||||
class TextProperty(
|
class TextProperty(
|
||||||
value: String
|
value: String
|
||||||
): CssProperty(value)
|
) : CssProperty(value)
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ open class Measurement(
|
|||||||
val inherit = Measurement("inherit")
|
val inherit = Measurement("inherit")
|
||||||
val normal = Measurement("normal")
|
val normal = Measurement("normal")
|
||||||
|
|
||||||
fun px(nr: Int) = if (nr == 0) { Measurement("0") } else { Measurement("${nr}px") }
|
fun px(nr: Int) = if (nr == 0) {
|
||||||
|
Measurement("0")
|
||||||
|
} else {
|
||||||
|
Measurement("${nr}px")
|
||||||
|
}
|
||||||
|
|
||||||
fun px(nr: Double) = nr.px
|
fun px(nr: Double) = nr.px
|
||||||
fun em(nr: Int) = nr.em
|
fun em(nr: Int) = nr.em
|
||||||
fun em(nr: Double) = nr.em
|
fun em(nr: Double) = nr.em
|
||||||
@@ -24,17 +29,42 @@ open class Measurement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val Int.px: Measurement
|
val Int.px: Measurement
|
||||||
get() = Measurement("${this}${if (this == 0) { "" } else { "px"}}")
|
get() = Measurement(
|
||||||
|
"${this}${
|
||||||
|
if (this == 0) {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
"px"
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
)
|
||||||
val Int.em: Measurement
|
val Int.em: Measurement
|
||||||
get() = Measurement("${this}${if (this == 0) { "" } else { "em"}}")
|
get() = Measurement(
|
||||||
|
"${this}${
|
||||||
|
if (this == 0) {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
"em"
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
)
|
||||||
val Int.rem: Measurement
|
val Int.rem: Measurement
|
||||||
get() = Measurement("${this}${if (this == 0) { "" } else { "rem"}}")
|
get() = Measurement(
|
||||||
|
"${this}${
|
||||||
|
if (this == 0) {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
"rem"
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
)
|
||||||
val Int.prc: Measurement
|
val Int.prc: Measurement
|
||||||
get() = Measurement("${this}%")
|
get() = Measurement("${this}%")
|
||||||
val Int.pc: Measurement
|
val Int.pc: Measurement
|
||||||
get() = Measurement("${this}pc")
|
get() = Measurement("${this}pc")
|
||||||
val Int.cm: Measurement
|
val Int.cm: Measurement
|
||||||
get() = Measurement("${this}cm")
|
get() = Measurement("${this}cm")
|
||||||
|
|
||||||
fun Int.px(): Measurement = Measurement.px(this)
|
fun Int.px(): Measurement = Measurement.px(this)
|
||||||
|
|
||||||
val Double.px: Measurement
|
val Double.px: Measurement
|
||||||
@@ -49,6 +79,7 @@ val Double.pc: Measurement
|
|||||||
get() = Measurement("${this}pc")
|
get() = Measurement("${this}pc")
|
||||||
val Double.cm: Measurement
|
val Double.cm: Measurement
|
||||||
get() = Measurement("${this}cm")
|
get() = Measurement("${this}cm")
|
||||||
|
|
||||||
fun Double.px(): Measurement = Measurement.px(this)
|
fun Double.px(): Measurement = Measurement.px(this)
|
||||||
|
|
||||||
open class LineHeight(value: String) : CssProperty(value) {
|
open class LineHeight(value: String) : CssProperty(value) {
|
||||||
|
|||||||
@@ -15,7 +15,16 @@ class TimingFunction(
|
|||||||
val initial = TimingFunction("initial")
|
val initial = TimingFunction("initial")
|
||||||
val inherit = TimingFunction("inherit")
|
val inherit = TimingFunction("inherit")
|
||||||
|
|
||||||
fun steps(steps: Int, start: Boolean) = TimingFunction("steps($steps, ${if (start) { "start" } else { "end" }}")
|
fun steps(steps: Int, start: Boolean) = TimingFunction(
|
||||||
|
"steps($steps, ${
|
||||||
|
if (start) {
|
||||||
|
"start"
|
||||||
|
} else {
|
||||||
|
"end"
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
|
||||||
fun cubicBezier(n1: Double, n2: Double, n3: Double, n4: Double) = TimingFunction("cubic-bezier($n1, $n2, $n3, $n4)")
|
fun cubicBezier(n1: Double, n2: Double, n3: Double, n4: Double) = TimingFunction("cubic-bezier($n1, $n2, $n3, $n4)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Transform(
|
|||||||
n5: Double,
|
n5: Double,
|
||||||
n6: Double
|
n6: Double
|
||||||
) = Transform("matrix($n1, $n2, $n3, $n4, $n5, $n6)")
|
) = Transform("matrix($n1, $n2, $n3, $n4, $n5, $n6)")
|
||||||
|
|
||||||
fun matrix3d(
|
fun matrix3d(
|
||||||
n01: Double, n02: Double, n03: Double, n04: Double,
|
n01: Double, n02: Double, n03: Double, n04: Double,
|
||||||
n05: Double, n06: Double, n07: Double, n08: Double,
|
n05: Double, n06: Double, n07: Double, n08: Double,
|
||||||
@@ -25,6 +26,7 @@ class Transform(
|
|||||||
) = Transform(
|
) = Transform(
|
||||||
"matrix3d($n01, $n02, $n03, $n04, $n05, $n06, $n07, $n08, $n09, $n10, $n11, $n12, $n13, $n14, $n15, $n16)"
|
"matrix3d($n01, $n02, $n03, $n04, $n05, $n06, $n07, $n08, $n09, $n10, $n11, $n12, $n13, $n14, $n15, $n16)"
|
||||||
)
|
)
|
||||||
|
|
||||||
fun translate(x: Double, y: Double) = Transform("translate($x, $y)")
|
fun translate(x: Double, y: Double) = Transform("translate($x, $y)")
|
||||||
fun translate3d(x: Double, y: Double, z: Double) = Transform("translate3d($x, $y, $z)")
|
fun translate3d(x: Double, y: Double, z: Double) = Transform("translate3d($x, $y, $z)")
|
||||||
fun translateX(x: Double) = Transform("translateX($x)")
|
fun translateX(x: Double) = Transform("translateX($x)")
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package nl.astraeus.css.style
|
package nl.astraeus.css.style
|
||||||
|
|
||||||
import nl.astraeus.css.properties.*
|
import nl.astraeus.css.properties.CssProperty
|
||||||
|
import nl.astraeus.css.properties.FontSize
|
||||||
|
import nl.astraeus.css.properties.FontStretch
|
||||||
|
import nl.astraeus.css.properties.FontStyle
|
||||||
|
import nl.astraeus.css.properties.FontWeight
|
||||||
|
|
||||||
@CssTagMarker
|
@CssTagMarker
|
||||||
open class FontFace : CssGenerator() {
|
open class FontFace : CssGenerator() {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,7 @@ abstract class Validator {
|
|||||||
|
|
||||||
class MaxCountValidator(
|
class MaxCountValidator(
|
||||||
val number: Int
|
val number: Int
|
||||||
): Validator() {
|
) : Validator() {
|
||||||
|
|
||||||
override fun validate(property: List<CssProperty>): Boolean = property.size <= number
|
override fun validate(property: List<CssProperty>): Boolean = property.size <= number
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class MaxCountValidator(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class InitialInheritSingleValue: Validator() {
|
class InitialInheritSingleValue : Validator() {
|
||||||
|
|
||||||
override fun validate(properties: List<CssProperty>): Boolean {
|
override fun validate(properties: List<CssProperty>): Boolean {
|
||||||
for (prop in properties) {
|
for (prop in properties) {
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package nl.astraeus.css
|
package nl.astraeus.css
|
||||||
|
|
||||||
import nl.astraeus.css.properties.*
|
import nl.astraeus.css.properties.AlignContent
|
||||||
|
import nl.astraeus.css.properties.DelayDuration
|
||||||
|
import nl.astraeus.css.properties.TimingFunction
|
||||||
|
import nl.astraeus.css.properties.hex
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val sd = style {
|
val sd = style {
|
||||||
select("#pipo") {
|
select("#pipo") {
|
||||||
|
|||||||
Reference in New Issue
Block a user