-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
artifact.go
37 lines (29 loc) · 1.08 KB
/
artifact.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package components
import (
"fmt"
"github.com/BigJk/end_of_eden/game"
"github.com/BigJk/end_of_eden/ui"
"github.com/BigJk/end_of_eden/ui/style"
"github.com/charmbracelet/lipgloss"
"strings"
)
var (
artifactStyle = lipgloss.NewStyle().Padding(1, 2).Margin(0, 2)
)
func ArtifactCard(session *game.Session, guid string, baseHeight int, width int) string {
art, _ := session.GetArtifact(guid)
if width <= 0 {
width = 30
}
artifactStyle := artifactStyle.Copy().
Width(width).
Border(lipgloss.ThickBorder(), true, false, false, false).
BorderBackground(lipgloss.Color("#495057")).
BorderForeground(lipgloss.Color("#495057")).
Background(lipgloss.Color("#343a40")).
Foreground(style.BaseWhite)
tagsText := strings.Join(art.PublicTags(), ", ")
return artifactStyle.
Height(baseHeight).
Render(fmt.Sprintf("%s\n\n%s\n\n%s", style.BoldStyle.Render(art.Name, strings.Repeat(" ", ui.Max(width-6-lipgloss.Width(art.Name)-lipgloss.Width(tagsText), 0)), tagsText), art.Description, lipgloss.NewStyle().Bold(true).Foreground(style.BaseYellow).Render(fmt.Sprintf("%d$", art.Price))))
}