initial port of the UI kit
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
chart "github.com/wcharczuk/go-chart/v2"
|
||||
|
||||
. "kjol/vdom"
|
||||
ui "kjol/webui"
|
||||
)
|
||||
|
||||
// ServerCounter is a SERVER component — note it's written exactly like a client
|
||||
@@ -34,19 +35,17 @@ func ServerCounter() func() *VNode {
|
||||
points.Set(append(points.Get(), clickPoint{T: time.Now().UnixMilli(), V: count.Get()}))
|
||||
}
|
||||
return func() *VNode {
|
||||
return Div(Attr("class", "card"),
|
||||
Div(Attr("class", "card-body"),
|
||||
Div(Attr("class", "d-flex align-items-center gap-2 mb-2"),
|
||||
Span(Text("Server counter: ")),
|
||||
Strong(Attr("class", "badge text-bg-success fs-6"), Text(strconv.Itoa(count.Get()))),
|
||||
Button(Attr("class", "btn btn-sm btn-outline-secondary"),
|
||||
On(EVENT_CLICK, func() { bump(-1) }), Text("−")),
|
||||
Button(Attr("class", "btn btn-sm btn-success"),
|
||||
On(EVENT_CLICK, func() { bump(1) }), Text("+")),
|
||||
return ui.Card("",
|
||||
Div(Attr("class", "flex items-center gap-2 mb-3"),
|
||||
Span(Attr("class", "text-neutral-700"), Text("Server counter: ")),
|
||||
Strong(Attr("class", "badge inline-flex items-center rounded-full bg-green-700 px-2.5 py-0.5 text-sm font-semibold text-white"), Text(strconv.Itoa(count.Get()))),
|
||||
Div(Attr("class", "ml-auto flex gap-1"),
|
||||
ui.Button(ui.ButtonProps{Color: ui.ButtonSecondary, Small: true, Text: "−", OnClick: func() { bump(-1) }}),
|
||||
ui.Button(ui.ButtonProps{Color: ui.ButtonGreen, Small: true, Text: "+", OnClick: func() { bump(1) }}),
|
||||
),
|
||||
Div(Attr("class", "border rounded p-2 bg-white overflow-auto"),
|
||||
Raw(clickChartSVG(points.Get()))),
|
||||
),
|
||||
Div(Attr("class", "rounded-default border border-neutral-200 bg-white p-2 overflow-auto"),
|
||||
Raw(clickChartSVG(points.Get()))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user