Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .run/renlin_sample [allTests].run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="renlin:sample [allTests]" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/sample" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="allTests" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
24 changes: 24 additions & 0 deletions .run/renlin_sample [jsBrowserDevelopmentRun].run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="renlin:sample [jsBrowserDevelopmentRun]" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/sample" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-t" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="jsBrowserDevelopmentRun" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package net.kigawa.renlin.css

/**
* Background Repeat プロパティ
*/
@Suppress("unused")
enum class BackgroundRepeat(private val value: String) : CssValue {
REPEAT("repeat"),
REPEAT_X("repeat-x"),
REPEAT_Y("repeat-y"),
NO_REPEAT("no-repeat"),
SPACE("space"),
ROUND("round");

override fun toCssString(): String = value
}

/**
* Background Position プロパティ
*/
@Suppress("unused")
enum class BackgroundPosition(private val value: String) : CssValue {
LEFT("left"),
CENTER("center"),
RIGHT("right"),
TOP("top"),
BOTTOM("bottom"),
LEFT_TOP("left top"),
LEFT_CENTER("left center"),
LEFT_BOTTOM("left bottom"),
CENTER_TOP("center top"),
CENTER_CENTER("center center"),
CENTER_BOTTOM("center bottom"),
RIGHT_TOP("right top"),
RIGHT_CENTER("right center"),
RIGHT_BOTTOM("right bottom");

override fun toCssString(): String = value
}

/**
* Background Size プロパティ
*/
@Suppress("unused")
enum class BackgroundSize(private val value: String) : CssValue {
AUTO("auto"),
COVER("cover"),
CONTAIN("contain");

override fun toCssString(): String = value
}

/**
* Background Attachment プロパティ
*/
@Suppress("unused")
enum class BackgroundAttachment(private val value: String) : CssValue {
SCROLL("scroll"),
FIXED("fixed"),
LOCAL("local");

override fun toCssString(): String = value
}
31 changes: 31 additions & 0 deletions renlin/src/commonMain/kotlin/net/kigawa/renlin/css/CssBorder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.kigawa.renlin.css

/**
* Border Style プロパティ
*/
@Suppress("unused")
enum class BorderStyle(private val value: String) : CssValue {
NONE("none"),
HIDDEN("hidden"),
DOTTED("dotted"),
DASHED("dashed"),
SOLID("solid"),
DOUBLE("double"),
GROOVE("groove"),
RIDGE("ridge"),
INSET("inset"),
OUTSET("outset");

override fun toCssString(): String = value
}

/**
* Box Sizing プロパティ
*/
@Suppress("unused")
enum class BoxSizing(private val value: String) : CssValue {
CONTENT_BOX("content-box"),
BORDER_BOX("border-box");

override fun toCssString(): String = value
}
107 changes: 107 additions & 0 deletions renlin/src/commonMain/kotlin/net/kigawa/renlin/css/CssColor.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package net.kigawa.renlin.css

/**
* CSS色の基底インターフェース
*/
sealed interface CssColor : CssValue

/**
* 名前付きの色
*/
@Suppress("unused")
enum class NamedColor(private val colorName: String) : CssColor {
RED("red"),
GREEN("green"),
BLUE("blue"),
BLACK("black"),
WHITE("white"),
TRANSPARENT("transparent"),
GRAY("gray"),
LIGHTGRAY("lightgray"),
DARKGRAY("darkgray"),
YELLOW("yellow"),
ORANGE("orange"),
PURPLE("purple"),
PINK("pink"),
BROWN("brown"),
CYAN("cyan"),
MAGENTA("magenta");

override fun toCssString(): String = colorName
}

/**
* 16進数表記
*/
data class HexColor(val hex: String) : CssColor {
init {
require(hex.matches(Regex("^#[0-9A-Fa-f]{3}$|^#[0-9A-Fa-f]{6}$"))) {
"Invalid hex color format: $hex"
}
}

override fun toCssString(): String = hex
}

/**
* RGB表記
*/
data class RgbColor(val r: Int, val g: Int, val b: Int) : CssColor {
init {
require(r in 0..255 && g in 0..255 && b in 0..255) {
"RGB values must be between 0 and 255"
}
}

override fun toCssString(): String = "rgb($r, $g, $b)"
}

/**
* RGBA表記(透明度付き)
*/
data class RgbaColor(val r: Int, val g: Int, val b: Int, val a: Double) : CssColor {
init {
require(r in 0..255 && g in 0..255 && b in 0..255) {
"RGB values must be between 0 and 255"
}
require(a in 0.0..1.0) {
"Alpha value must be between 0.0 and 1.0"
}
}

override fun toCssString(): String = "rgba($r, $g, $b, $a)"
}

/**
* 色のファクトリオブジェクト
*/
@Suppress("unused")
object Color {
// よく使う色の定数
val RED = NamedColor.RED
val GREEN = NamedColor.GREEN
val BLUE = NamedColor.BLUE
val BLACK = NamedColor.BLACK
val WHITE = NamedColor.WHITE
val TRANSPARENT = NamedColor.TRANSPARENT
val GRAY = NamedColor.GRAY
val LIGHTGRAY = NamedColor.LIGHTGRAY
val DARKGRAY = NamedColor.DARKGRAY
val YELLOW = NamedColor.YELLOW
val ORANGE = NamedColor.ORANGE
val PURPLE = NamedColor.PURPLE
val PINK = NamedColor.PINK
val BROWN = NamedColor.BROWN
val CYAN = NamedColor.CYAN
val MAGENTA = NamedColor.MAGENTA

// ファクトリメソッド
fun hex(hex: String): HexColor = HexColor(hex)
fun rgb(r: Int, g: Int, b: Int): RgbColor = RgbColor(r, g, b)
fun rgba(r: Int, g: Int, b: Int, a: Double): RgbaColor = RgbaColor(r, g, b, a)
}

// 文字列からの便利な変換
@Suppress("unused")
val String.color: HexColor
get() = HexColor(if (startsWith("#")) this else "#$this")
Loading
Loading