Browse Source

Rename unit subtypes to make their usage more intuitive

pull/761/head
Shagen Ogandzhanian 4 years ago
parent
commit
693dae096a
  1. 90
      web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSUnits.kt

90
web/core/src/jsMain/kotlin/androidx/compose/web/css/CSSUnits.kt

@ -8,175 +8,175 @@ interface CSSUnitValueTyped<T : CSSUnit> : CSSNumericValue {
interface CSSUnitValue : CSSUnitValueTyped<CSSUnit> interface CSSUnitValue : CSSUnitValueTyped<CSSUnit>
interface CSSUnitRelValue : CSSUnit interface CSSUnitRel : CSSUnit
interface CSSUnitAbsValue: CSSUnit interface CSSUnitAbs: CSSUnit
interface CSSUnitAngleValue: CSSUnit interface CSSUnitAngle: CSSUnit
interface CSSUnitTimeValue: CSSUnit interface CSSUnitTime: CSSUnit
interface CSSUnitFrequencyValue: CSSUnit interface CSSUnitFrequency: CSSUnit
interface CSSUnitResolutionValue: CSSUnit interface CSSUnitResolution: CSSUnit
interface CSSUnitFlexValue: CSSUnit interface CSSUnitFlex: CSSUnit
interface CSSAngleValue : CSSUnitValueTyped<CSSUnitAngleValue> interface CSSAngleValue : CSSUnitValueTyped<CSSUnitAngle>
sealed interface CSSUnit { sealed interface CSSUnit {
val value: String val value: String
object percent: CSSUnitRelValue { object percent: CSSUnitRel {
override val value: String override val value: String
get() = "percent" get() = "percent"
} }
object em: CSSUnitRelValue { object em: CSSUnitRel {
override val value: String override val value: String
get() = "em" get() = "em"
} }
object ex: CSSUnitRelValue { object ex: CSSUnitRel {
override val value: String override val value: String
get() = "ex" get() = "ex"
} }
object ch: CSSUnitRelValue { object ch: CSSUnitRel {
override val value: String override val value: String
get() = "ch" get() = "ch"
} }
object ic: CSSUnitRelValue { object ic: CSSUnitRel {
override val value: String override val value: String
get() = "ic" get() = "ic"
} }
object rem: CSSUnitRelValue { object rem: CSSUnitRel {
override val value: String override val value: String
get() = "rem" get() = "rem"
} }
object lh: CSSUnitRelValue { object lh: CSSUnitRel {
override val value: String override val value: String
get() = "lh" get() = "lh"
} }
object rlh: CSSUnitRelValue { object rlh: CSSUnitRel {
override val value: String override val value: String
get() = "rlh" get() = "rlh"
} }
object vw: CSSUnitRelValue { object vw: CSSUnitRel {
override val value: String override val value: String
get() = "vw" get() = "vw"
} }
object vh: CSSUnitRelValue { object vh: CSSUnitRel {
override val value: String override val value: String
get() = "vh" get() = "vh"
} }
object vi: CSSUnitRelValue { object vi: CSSUnitRel {
override val value: String override val value: String
get() = "vi" get() = "vi"
} }
object vb: CSSUnitRelValue { object vb: CSSUnitRel {
override val value: String override val value: String
get() = "vb" get() = "vb"
} }
object vmin: CSSUnitRelValue { object vmin: CSSUnitRel {
override val value: String override val value: String
get() = "vmin" get() = "vmin"
} }
object vmax: CSSUnitRelValue { object vmax: CSSUnitRel {
override val value: String override val value: String
get() = "vmax" get() = "vmax"
} }
object cm: CSSUnitRelValue { object cm: CSSUnitRel {
override val value: String override val value: String
get() = "cm" get() = "cm"
} }
object mm: CSSUnitRelValue { object mm: CSSUnitRel {
override val value: String override val value: String
get() = "mm" get() = "mm"
} }
object q: CSSUnitRelValue { object q: CSSUnitRel {
override val value: String override val value: String
get() = "q" get() = "q"
} }
object pt: CSSUnitAbsValue { object pt: CSSUnitAbs {
override val value: String override val value: String
get() = "pt" get() = "pt"
} }
object pc: CSSUnitAbsValue { object pc: CSSUnitAbs {
override val value: String override val value: String
get() = "pc" get() = "pc"
} }
object px: CSSUnitAbsValue { object px: CSSUnitAbs {
override val value: String override val value: String
get() = "px" get() = "px"
} }
object deg: CSSUnitAngleValue { object deg: CSSUnitAngle {
override val value: String override val value: String
get() = "deg" get() = "deg"
} }
object grad: CSSUnitAngleValue { object grad: CSSUnitAngle {
override val value: String override val value: String
get() = "grad" get() = "grad"
} }
object rad: CSSUnitAngleValue { object rad: CSSUnitAngle {
override val value: String override val value: String
get() = "rad" get() = "rad"
} }
object turn: CSSUnitAngleValue { object turn: CSSUnitAngle {
override val value: String override val value: String
get() = "turn" get() = "turn"
} }
object s: CSSUnitTimeValue { object s: CSSUnitTime {
override val value: String override val value: String
get() = "s" get() = "s"
} }
object ms: CSSUnitTimeValue { object ms: CSSUnitTime {
override val value: String override val value: String
get() = "ms" get() = "ms"
} }
object hz: CSSUnitFrequencyValue { object hz: CSSUnitFrequency {
override val value: String override val value: String
get() = "hz" get() = "hz"
} }
object khz: CSSUnitFrequencyValue { object khz: CSSUnitFrequency {
override val value: String override val value: String
get() = "khz" get() = "khz"
} }
object dpi: CSSUnitResolutionValue { object dpi: CSSUnitResolution {
override val value: String override val value: String
get() = "dpi" get() = "dpi"
} }
object dpcm: CSSUnitResolutionValue { object dpcm: CSSUnitResolution {
override val value: String override val value: String
get() = "dpcm" get() = "dpcm"
} }
object dppx: CSSUnitResolutionValue { object dppx: CSSUnitResolution {
override val value: String override val value: String
get() = "dppx" get() = "dppx"
} }
object fr: CSSUnitFlexValue { object fr: CSSUnitFlex {
override val value: String override val value: String
get() = "fr" get() = "fr"
} }
@ -288,22 +288,22 @@ value class CSSpxValue(override val value: Float) : CSSUnitValue {
} }
value class CSSdegValue(override val value: Float) : CSSAngleValue { value class CSSdegValue(override val value: Float) : CSSAngleValue {
override val unit: CSSUnitAngleValue override val unit: CSSUnitAngle
get() = CSSUnit.deg get() = CSSUnit.deg
} }
value class CSSgradValue(override val value: Float) : CSSAngleValue { value class CSSgradValue(override val value: Float) : CSSAngleValue {
override val unit: CSSUnitAngleValue override val unit: CSSUnitAngle
get() = CSSUnit.grad get() = CSSUnit.grad
} }
value class CSSradValue(override val value: Float) : CSSAngleValue { value class CSSradValue(override val value: Float) : CSSAngleValue {
override val unit: CSSUnitAngleValue override val unit: CSSUnitAngle
get() = CSSUnit.rad get() = CSSUnit.rad
} }
value class CSSturnValue(override val value: Float) : CSSAngleValue { value class CSSturnValue(override val value: Float) : CSSAngleValue {
override val unit: CSSUnitAngleValue override val unit: CSSUnitAngle
get() = CSSUnit.turn get() = CSSUnit.turn
} }
@ -353,7 +353,7 @@ value class CSSnumberValue(override val value: Float) : CSSUnitValue {
} }
val Number.number val Number.number
get(): CSSUnitValue = CSSnumberValue(this.toFloat()) get(): CSSnumberValue = CSSnumberValue(this.toFloat())
val Number.percent val Number.percent
get(): CSSpercentValue = CSSpercentValue(this.toFloat()) get(): CSSpercentValue = CSSpercentValue(this.toFloat())

Loading…
Cancel
Save