summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/moe/nea89/website/KConsole.kt2
-rw-r--r--src/main/kotlin/moe/nea89/website/Styles.kt22
-rw-r--r--src/main/kotlin/moe/nea89/website/index.kt4
3 files changed, 27 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea89/website/KConsole.kt b/src/main/kotlin/moe/nea89/website/KConsole.kt
index 4814bf5..89617b8 100644
--- a/src/main/kotlin/moe/nea89/website/KConsole.kt
+++ b/src/main/kotlin/moe/nea89/website/KConsole.kt
@@ -1,6 +1,7 @@
package moe.nea89.website
import kotlinx.browser.document
+import kotlinx.dom.addClass
import kotlinx.html.dom.append
import kotlinx.html.dom.create
import kotlinx.html.js.p
@@ -28,6 +29,7 @@ class KConsole(
fun createFor(element: HTMLElement, fileSystem: KFileSystem? = null): KConsole {
val text = element.append.pre()
val prompt = text.append.p()
+ prompt.addClass(Styles.promptClass)
element.classList.add(Styles.consoleClass)
val console = KConsole(element, text, prompt, fileSystem)
document.body!!.onkeydown = console::keydown
diff --git a/src/main/kotlin/moe/nea89/website/Styles.kt b/src/main/kotlin/moe/nea89/website/Styles.kt
index 71aa733..a6d7c1f 100644
--- a/src/main/kotlin/moe/nea89/website/Styles.kt
+++ b/src/main/kotlin/moe/nea89/website/Styles.kt
@@ -1,11 +1,16 @@
package moe.nea89.website
import kotlinx.css.*
+import kotlinx.css.properties.IterationCount
+import kotlinx.css.properties.Timing
+import kotlinx.css.properties.s
import styled.StyleSheet
+import styled.animation
object Styles : StyleSheet("Styles") {
val consoleClass = "Console"
+ val promptClass = "prompt"
val bgColor = CustomColor.BLACK.color
val fgColor = CustomColor.WHITE.color
@@ -24,6 +29,23 @@ object Styles : StyleSheet("Styles") {
color = fgColor
fontFamily = comicMono
}
+
+ ".$promptClass" {
+ width = LinearDimension.fitContent
+ borderRightColor = fgColor
+ borderRightWidth = 2.px
+ paddingRight = 2.px
+ borderRightStyle = BorderStyle.solid
+ animation(1.s, Timing.stepStart, iterationCount = IterationCount.infinite) {
+ 0 {
+ borderRightStyle = BorderStyle.solid
+ }
+ 50 {
+ borderRightStyle = BorderStyle.none
+ }
+ }
+ }
+
".$consoleClass" {
width = 100.pct
height = 100.pct
diff --git a/src/main/kotlin/moe/nea89/website/index.kt b/src/main/kotlin/moe/nea89/website/index.kt
index d347364..edc1add 100644
--- a/src/main/kotlin/moe/nea89/website/index.kt
+++ b/src/main/kotlin/moe/nea89/website/index.kt
@@ -74,7 +74,8 @@ fun main() {
console.rerender()
}
}
- else -> "is a ${file.fileType}"
+
+ else -> console.addLine("ls: is a ${file.fileType}")
}
})
console.registerCommand(command("color") {
@@ -100,6 +101,7 @@ fun main() {
is KFile.Image -> console.addLine(document.create.p {
img(src = file.url)
})
+
is KFile.Download -> {
val link = document.create.a(file.url)
link.download = file.name.last()