Initial commit

This commit is contained in:
2020-02-10 19:31:44 +01:00
commit 1b83f88c8f
14 changed files with 685 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
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)
enum class MeasurementType {
PX,
EM,
PERCENTAGE,
OTHER
}
open class Measurement(
val type: MeasurementType,
val intValue: Int = 0,
val stringValue: String = ""
) : CssProperty() {
override fun css(): String = when(type) {
MeasurementType.PX -> {
"${intValue}px"
}
MeasurementType.EM -> {
"${intValue}em"
}
MeasurementType.PERCENTAGE -> {
"${stringValue}%"
}
else -> {
error("Unhandled type $type")
}
}
}
enum class FontSizeType {
PX,
EM,
PERCENTAGE,
}
class FontSize(
val fontType: FontSizeType,
intValue: Int = 0,
stringValue: String = ""
) : Measurement(
MeasurementType.PX,
intValue,
stringValue
) {
override fun css(): String = "12px"
}