godash/components/system.templ
2024-03-12 15:49:08 +01:00

23 lines
779 B
Text

package components
import "html/template"
var barTemplate = template.Must(template.New("bar").Parse("<div id=\"{{ .Id }}\" class=\"progress-bar\" style=\"width: {{ .Percentage }}%\"></div>"))
type Bar struct {
Id string
Percentage float64
}
templ System(icon string, infoPre string, infoPost string, extraInfo string, percentageId string, valueId string, percentage float64) {
<div class="flex items-center">
<span class={ "system-icon", icon }></span>
<div class="w-full truncate">
<div class="extra-info">{ extraInfo }</div>
<div class="truncate"><span id={ valueId }>{ infoPre }</span>{ infoPost }</div>
<div class="progress-bar-wrapper">
@templ.FromGoHTML(barTemplate, Bar{Id:percentageId, Percentage:percentage})
</div>
</div>
</div>
}