More properties

This commit is contained in:
2020-02-10 20:28:57 +01:00
parent 1b83f88c8f
commit 1c3ac8f0d0
14 changed files with 229 additions and 27 deletions

View File

@@ -3,11 +3,13 @@ package nl.astraeus.css
fun px(nr: Int): Measurement = Measurement(MeasurementType.PX, nr)
fun em(nr: Int): Measurement = Measurement(MeasurementType.EM, nr)
fun perc(nr: Int): Measurement = Measurement(MeasurementType.PERCENTAGE, nr)
fun pc(nr: Int): Measurement = Measurement(MeasurementType.PICAS, nr)
enum class MeasurementType {
PX,
EM,
PERCENTAGE,
PICAS,
OTHER
}
@@ -15,7 +17,7 @@ open class Measurement(
val type: MeasurementType,
val intValue: Int = 0,
val stringValue: String = ""
) : CssProperty() {
) : CssProperty {
override fun css(): String = when(type) {
MeasurementType.PX -> {
@@ -27,6 +29,9 @@ open class Measurement(
MeasurementType.PERCENTAGE -> {
"${stringValue}%"
}
MeasurementType.PICAS -> {
"${stringValue}pc"
}
else -> {
error("Unhandled type $type")
}
@@ -38,7 +43,6 @@ enum class FontSizeType {
PX,
EM,
PERCENTAGE,
}
class FontSize(