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