![JAR search and dependency download from the Maven repository](/logo.png)
io.docops.asciidoc.buttons.LargeCardNext.kt Maven / Gradle / Ivy
package io.docops.asciidoc.buttons
import io.docops.asciidoc.buttons.models.Button
import io.docops.asciidoc.buttons.theme.Theme
import io.docops.asciidoc.utils.addLinebreaks
import io.docops.asciidoc.utils.escapeXml
class LargeCardNext {
fun makeButtons(buttons: MutableList>, theme: Theme): String {
val svgBuilder = StringBuilder()
svgBuilder.append(startSvg(height = height(buttons), width = width(theme), theme = theme))
svgBuilder.append(makeDefs(buttons = buttons, theme = theme))
svgBuilder.append("")
svgBuilder.append(drawButtons(buttonList = buttons, theme = theme))
svgBuilder.append(" ")
svgBuilder.append(endSvg())
return svgBuilder.toString()
}
private fun startSvg(height: Int, width: Int, theme: Theme): String {
return """"
}
private fun makeDefs(buttons: MutableList>, theme: Theme): String {
val filters = """
"""
val btnGrad = StringBuilder()
buttons.forEach { button ->
button.forEach { item ->
theme.buttonTextColor(item)
btnGrad.append(theme.buildGradientStyle(item))
}
}
//language="html"
val style = """
"""
var linear = ""
theme.gradientStyle?.let { linear = it.gradientIdToXml() }
val btnDef = StringBuilder("")
buttons.forEach { btn ->
btn.forEach {
btnDef.append(theme.buildGradientDef(it))
}
}
val uses = """
Title
"""
return """
$filters
$linear
$btnDef
${theme.defs}
$uses
$style
"""
}
private fun drawButtons(buttonList: MutableList>, theme: Theme): String {
val sb = StringBuilder()
buttonList.forEachIndexed { index, buttons ->
sb.append(drawButtonRow(index, buttons, theme))
}
return sb.toString()
}
private fun drawButtonRow(index: Int, buttons: MutableList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy