Agent: components 261-280
This commit is contained in:
108 files changed
+6363
-7
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package mujica
|
||||
|
||||
import (
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"mujicaui/theme"
|
||||
)
|
||||
|
||||
// AgentStatusOptions configure an AgentStatus.
|
||||
type AgentStatusOptions struct {
|
||||
// Label replaces the built-in word, as "Writing the report".
|
||||
Label string
|
||||
// Still stops the running animation.
|
||||
Still bool
|
||||
}
|
||||
|
||||
// AgentStatus shows a state by icon shape and word.
|
||||
func AgentStatus(c *ui.Context, state AgentState, opts AgentStatusOptions) *ui.Element {
|
||||
label := opts.Label
|
||||
if label == "" {
|
||||
label = agentWord(c, state) // panics on an unknown state
|
||||
}
|
||||
k := Tokens(c)
|
||||
u := Density(c).Unit()
|
||||
tone, _ := agentTone(k, state)
|
||||
pill := ui.Row(c).Shrink(0).AlignSelf(ui.Start).AlignItems(ui.Center).Gap(u*1.5).Padding(u, u*2.5).
|
||||
Radius(theme.CardRadius).Border(theme.BorderWidth, tone).Background(k.Surface).
|
||||
Role(ui.RoleStatus).Label(label)
|
||||
pill.Children(func() {
|
||||
agentMark(c, state, 14, opts.Still)
|
||||
ui.Text(c, label).FontSize(FontSize(c, theme.CaptionSize+1)).TextColor(k.Text).SingleLine()
|
||||
})
|
||||
return pill
|
||||
}
|
||||
Reference in new issue
Block a user