diff --git a/settings.gradle.kts b/settings.gradle.kts index 48990df..ed28a67 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,4 +8,3 @@ pluginManagement { } } rootProject.name = "kotlin-css-generator" - diff --git a/src/commonMain/kotlin/nl/astraeus/css/AlignContent.kt b/src/commonMain/kotlin/nl/astraeus/css/AlignContent.kt deleted file mode 100644 index 9edefc5..0000000 --- a/src/commonMain/kotlin/nl/astraeus/css/AlignContent.kt +++ /dev/null @@ -1,17 +0,0 @@ -package nl.astraeus.css - -enum class AlignContent( - val value: String -) : CssProperty { - STRETCH("stretch"), - CENTER("center"), - FLEX_START("flex-start"), - FLEX_END("flex-end"), - SPACE_BETWEEN("space-between"), - SPACE_AROUND("space-around"), - INITIAL("initial"), - INHERIT("inherit"), - ; - - override fun css(): String = value -} diff --git a/src/commonMain/kotlin/nl/astraeus/css/AlignItems.kt b/src/commonMain/kotlin/nl/astraeus/css/AlignItems.kt deleted file mode 100644 index d065e3a..0000000 --- a/src/commonMain/kotlin/nl/astraeus/css/AlignItems.kt +++ /dev/null @@ -1,16 +0,0 @@ -package nl.astraeus.css - -enum class AlignItems( - val value: String -) : CssProperty { - STRETCH("stretch"), - CENTER("center"), - FLEX_START("flex-start"), - FLEX_END("flex-end"), - BASELINE("baseline"), - INITIAL("initial"), - INHERIT("inherit"), - ; - - override fun css(): String = value -} diff --git a/src/commonMain/kotlin/nl/astraeus/css/AlignSelf.kt b/src/commonMain/kotlin/nl/astraeus/css/AlignSelf.kt deleted file mode 100644 index abbedc8..0000000 --- a/src/commonMain/kotlin/nl/astraeus/css/AlignSelf.kt +++ /dev/null @@ -1,17 +0,0 @@ -package nl.astraeus.css - -enum class AlignSelf( - val value: String -) : CssProperty { - AUTO("auto"), - STRETCH("stretch"), - CENTER("center"), - FLEX_START("flex-start"), - FLEX_END("flex-end"), - BASELINE("baseline"), - INITIAL("initial"), - INHERIT("inherit"), - ; - - override fun css(): String = value -} diff --git a/src/commonMain/kotlin/nl/astraeus/css/All.kt b/src/commonMain/kotlin/nl/astraeus/css/All.kt deleted file mode 100644 index 6ce843a..0000000 --- a/src/commonMain/kotlin/nl/astraeus/css/All.kt +++ /dev/null @@ -1,12 +0,0 @@ -package nl.astraeus.css - -enum class All( - val value: String -) : CssProperty { - INITIAL("initial"), - INHERIT("inherit"), - UNSET("unset"), - ; - - override fun css(): String = value -} diff --git a/src/commonMain/kotlin/nl/astraeus/css/Animation.kt b/src/commonMain/kotlin/nl/astraeus/css/Animation.kt deleted file mode 100644 index 70daa18..0000000 --- a/src/commonMain/kotlin/nl/astraeus/css/Animation.kt +++ /dev/null @@ -1,29 +0,0 @@ -package nl.astraeus.css - -enum class AnimationDirection( - val value: String -) : CssProperty { - NORMAL("normal"), - REVERSE("reverse"), - ALTERNATE("alternate"), - ALTERNATE_REVERSE("alternate-reverse"), - INITIAL("initial"), - INHERIT("inherit"), - ; - - override fun css(): String = value -} - -enum class AnimationFillMode( - val value: String -) : CssProperty { - NONE("none"), - FORWARDS("forwards"), - BACKWARDS("backwards"), - BOTH("both"), - INITIAL("initial"), - INHERIT("inherit"), - ; - - override fun css(): String = value -} diff --git a/src/commonMain/kotlin/nl/astraeus/css/Color.kt b/src/commonMain/kotlin/nl/astraeus/css/Color.kt deleted file mode 100644 index b5bdafc..0000000 --- a/src/commonMain/kotlin/nl/astraeus/css/Color.kt +++ /dev/null @@ -1,63 +0,0 @@ -package nl.astraeus.css - -fun hex(hex: String): Color = HexColor(hex) -fun rgb(red: Int, green: Int, blue: Int): Color = RGBColor(red, green, blue) -fun rgba(red: Int, green: Int, blue: Int, alpha: Double): Color = RGBAColor(red, green, blue, alpha) -fun hsl(hue: Int, saturation: Int, lightness: Int): Color = HSLColor(hue, saturation, lightness) -fun hsla(hue: Int, saturation: Int, lightness: Int, alpha: Double): Color = HSLAColor(hue, saturation, lightness, alpha) - -open class Color : CssProperty { - - override fun css(): String = "#xxxxxx" - -} - -class HexColor( - val hex: String -) : Color() { - - override fun css(): String = "#$hex" - -} - -class RGBColor( - val red: Int, - val green: Int, - val blue: Int -) : Color() { - - override fun css(): String = "rgb($red, $green, $blue)" - -} - -class RGBAColor( - val red: Int, - val green: Int, - val blue: Int, - val alpha: Double -) : Color() { - - override fun css(): String = "rgba($red, $green, $blue, $alpha)" - -} - -class HSLColor( - val hue: Int, - val saturation: Int, - val lightness: Int -) : Color() { - - override fun css(): String = "hsl($hue, $saturation, $lightness)" - -} - -class HSLAColor( - val hue: Int, - val saturation: Int, - val lightness: Int, - val alpha: Double -) : Color() { - - override fun css(): String = "hsla($hue, $saturation, $lightness, $alpha)" - -} diff --git a/src/commonMain/kotlin/nl/astraeus/css/Count.kt b/src/commonMain/kotlin/nl/astraeus/css/Count.kt deleted file mode 100644 index 4505796..0000000 --- a/src/commonMain/kotlin/nl/astraeus/css/Count.kt +++ /dev/null @@ -1,30 +0,0 @@ -package nl.astraeus.css - - -enum class CountType { - NUMBER, - INFINITE, - INITIAL, - INHERIT -} - -class Count( - val type: CountType, - val number: Int -) : CssProperty { - - override fun css(): String = when(type) { - CountType.NUMBER -> "$number" - CountType.INFINITE -> "infinite" - CountType.INITIAL -> "initial" - CountType.INHERIT -> "inherit" - } - - companion object { - fun count(number: Int): Count = Count(CountType.NUMBER, number) - fun infinite(): Count = Count(CountType.INFINITE, 0) - fun initial(): Count = Count(CountType.INITIAL, 0) - fun inherit(): Count = Count(CountType.INHERIT, 0) - } -} - diff --git a/src/commonMain/kotlin/nl/astraeus/css/CssBuilder.kt b/src/commonMain/kotlin/nl/astraeus/css/CssBuilder.kt index 2b51a9a..fe4cebd 100644 --- a/src/commonMain/kotlin/nl/astraeus/css/CssBuilder.kt +++ b/src/commonMain/kotlin/nl/astraeus/css/CssBuilder.kt @@ -1,113 +1,6 @@ package nl.astraeus.css -@DslMarker -annotation class CssTagMarker - -@CssTagMarker -open class Style( - var alignContent: AlignContent? = null, - var alignItems: AlignItems? = null, - var alignSelf: AlignSelf? = null, - var all: All? = null, - var animation: TextProperty? = null, - var animationDelay: DelayDuration? = null, - var animationDirection: AnimationDirection? = null, - var animationDuration: DelayDuration? = null, - var animationFillMode: AnimationFillMode? = null, - var animationIterationCount: Count? = null, - var backgroundColor: Color? = null, - var color: Color? = null, - var fontFamily: TextProperty? = null, - var fontSize: FontSize? = null, - var height: Measurement? = null, - var left: Measurement? = null, - var top: Measurement? = null, - var transitionDelay: DelayDuration? = null, - var transitionDuration: DelayDuration? = null, - var width: Measurement? = null -) { - - fun getMapping() = mapOf( - "align-content" to alignContent, - "align-items" to alignItems, - "align-self" to alignSelf, - "all" to all, - "animation" to animation, - "animation-delay" to animationDelay, - "animation-direction" to animationDirection, - "animation-duration" to animationDuration, - "animation-fill-mode" to animationFillMode, - "animation-iteration-count" to animationIterationCount, - "background-color" to backgroundColor, - "color" to color, - "font-family" to fontFamily, - "font-size" to fontSize, - "height" to height, - "left" to left, - "top" to top, - "transition-delay" to transitionDelay, - "transition-duration" to transitionDuration, - "width" to width - ) - - fun propertyCss(indent: String, name: String, prop: CssProperty?): String = if (prop != null) { - "$indent$name: ${prop.css()};\n" - } else { - "" - } - - fun generatePropertyCss(indent: String): String { - val builder = StringBuilder() - - for ((name, prop) in getMapping()) { - builder.append(propertyCss(indent, name, prop)) - } - - return builder.toString() - } - -} - -@CssTagMarker -open class StyleDefinition : Style() { - val definitions: MutableMap = mutableMapOf() - val includes: MutableList