Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernasss12 committed Jul 20, 2023
1 parent c025171 commit 32aef85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/main/kotlin/dev/bernasss12/SvgDslExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package dev.bernasss12
import kotlinx.html.*
import kotlinx.html.SVG

open class SVGTag(tagName: String, initialAttributes : Map<String, String>, override val consumer : TagConsumer<*>) : HTMLTag(tagName, consumer, initialAttributes, "http://www.w3.org/2000/svg", false, false), HtmlBlockInlineTag {
}
open class SVGTag(tagName: String, initialAttributes : Map<String, String>, override val consumer : TagConsumer<*>) : HTMLTag(tagName, consumer, initialAttributes, "http://www.w3.org/2000/svg", false, false), HtmlBlockInlineTag

inline fun HTMLTag.newSvg(classes: String? = null, crossinline block: SVGTag.() -> Unit) : Unit = SVGTag("svg", attributesMapOf("class", classes), consumer).visit(block)

Expand All @@ -18,7 +17,7 @@ open class G(
tagName = "g",
consumer = consumer,
initialAttributes = initialAttributes,
), HtmlBlockInlineTag {}
), HtmlBlockInlineTag

open class Path(
initialAttributes: Map<String, String>,
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/dev/bernasss12/util/DataFormatter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ object DataFormatter {

private val suffixes = listOf('k', 'M', 'G', 'T')

public fun formatNumberWithSeparators(number: UInt, separator: String): String =
fun formatNumberWithSeparators(number: UInt, separator: String): String =
number.toString().reversed().chunked(3).reversed().joinToString(separator)

public fun formatNumberShorten(number: UInt, decimal: Boolean): String =
fun formatNumberShorten(number: UInt, decimal: Boolean): String =
number.toString().reversed().chunked(3).reversed().let { splitNumber ->
val result = StringBuilder(splitNumber.first())
if (decimal && splitNumber.size >= 2) result.append(".${splitNumber[1]}")
if (splitNumber.size >= 2) result.append(suffixes[splitNumber.size - 2])
return result.toString()
}

public suspend fun getComputedLength(model: Template, text: String): Int {
suspend fun getComputedLength(model: Template, text: String): Int {
val tempFolder = File("temp")

if (!tempFolder.exists()) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/kotlin/dev/bernasss12/ApplicationTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package dev.bernasss12


class ApplicationTest {
}
class ApplicationTest

0 comments on commit 32aef85

Please sign in to comment.