some styling changes
This commit is contained in:
parent
7bc95bdf62
commit
4e9d5b010f
4 changed files with 72 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
|||
package scenes
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
|
@ -14,14 +15,46 @@ import (
|
|||
var _ tea.Model = (*mainMenu)(nil)
|
||||
|
||||
type mainMenu struct {
|
||||
root components.RootModel
|
||||
list list.Model
|
||||
error *components.ErrorComponent
|
||||
root components.RootModel
|
||||
list list.Model
|
||||
error *components.ErrorComponent
|
||||
banner string
|
||||
}
|
||||
|
||||
const logoBanner = `
|
||||
███████╗██╗ ██████╗███████╗██╗████████╗
|
||||
██╔════╝██║██╔════╝██╔════╝██║╚══██╔══╝
|
||||
█████╗ ██║██║ ███████╗██║ ██║
|
||||
██╔══╝ ██║██║ ╚════██║██║ ██║
|
||||
██║ ██║╚██████╗███████║██║ ██║
|
||||
╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝`
|
||||
|
||||
func NewMainMenu(root components.RootModel) tea.Model {
|
||||
trimmedBanner := strings.TrimSpace(logoBanner)
|
||||
var finalBanner strings.Builder
|
||||
|
||||
for i, s := range strings.Split(trimmedBanner, "\n") {
|
||||
if i > 0 {
|
||||
finalBanner.WriteRune('\n')
|
||||
}
|
||||
|
||||
foreground := utils.LogoForegroundStyles[i]
|
||||
background := utils.LogoBackgroundStyles[i]
|
||||
|
||||
for _, c := range s {
|
||||
if c == '█' {
|
||||
finalBanner.WriteString(foreground.Render("█"))
|
||||
} else if c != ' ' {
|
||||
finalBanner.WriteString(background.Render(string(c)))
|
||||
} else {
|
||||
finalBanner.WriteRune(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model := mainMenu{
|
||||
root: root,
|
||||
root: root,
|
||||
banner: finalBanner.String(),
|
||||
}
|
||||
|
||||
items := []list.Item{
|
||||
|
@ -134,12 +167,16 @@ func (m mainMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
|
||||
func (m mainMenu) View() string {
|
||||
banner := lipgloss.NewStyle().Margin(2, 0, 0, 2).Render(m.banner)
|
||||
|
||||
header := lipgloss.JoinVertical(lipgloss.Left, banner, m.root.View())
|
||||
|
||||
if m.error != nil {
|
||||
err := (*m.error).View()
|
||||
m.list.SetSize(m.list.Width(), m.root.Size().Height-m.root.Height()-lipgloss.Height(err))
|
||||
return lipgloss.JoinVertical(lipgloss.Left, m.root.View(), err, m.list.View())
|
||||
m.list.SetSize(m.list.Width(), m.root.Size().Height-lipgloss.Height(header)-lipgloss.Height(err))
|
||||
return lipgloss.JoinVertical(lipgloss.Left, header, err, m.list.View())
|
||||
}
|
||||
|
||||
m.list.SetSize(m.list.Width(), m.root.Size().Height-m.root.Height())
|
||||
return lipgloss.JoinVertical(lipgloss.Left, m.root.View(), m.list.View())
|
||||
m.list.SetSize(m.list.Width(), m.root.Size().Height-lipgloss.Height(header))
|
||||
return lipgloss.JoinVertical(lipgloss.Left, header, m.list.View())
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func (n SimpleItemMod[any]) Title() string {
|
|||
profile := n.Context.Profiles.Profiles[n.Context.Profiles.SelectedProfile]
|
||||
if profile != nil {
|
||||
if profile.HasMod(n.Mod.Mod_reference) {
|
||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("34")).Render("✓ " + n.ItemTitle)
|
||||
return lipgloss.NewStyle().Foreground(lipgloss.Color("40")).Render("✓ " + n.ItemTitle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,12 +143,12 @@ func (m newInstallation) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
func (m newInstallation) View() string {
|
||||
inputView := lipgloss.NewStyle().Padding(1, 2).Render(m.input.View())
|
||||
|
||||
if m.error != nil {
|
||||
return lipgloss.JoinVertical(lipgloss.Left, m.root.View(), m.title, (*m.error).View(), inputView)
|
||||
}
|
||||
|
||||
mandatory := lipgloss.JoinVertical(lipgloss.Left, m.root.View(), m.title, inputView)
|
||||
|
||||
if m.error != nil {
|
||||
return lipgloss.JoinVertical(lipgloss.Left, mandatory, (*m.error).View())
|
||||
}
|
||||
|
||||
if len(m.dirList.Items()) > 0 {
|
||||
m.dirList.SetSize(m.dirList.Width(), m.root.Size().Height-lipgloss.Height(mandatory))
|
||||
|
||||
|
|
|
@ -6,14 +6,32 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
ListStyles list.Styles
|
||||
ListStyles = list.DefaultStyles()
|
||||
LabelStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(lipgloss.Color("202"))
|
||||
TitleStyle = list.DefaultStyles().Title.Background(lipgloss.Color("22"))
|
||||
NonListTitleStyle = TitleStyle.Copy().MarginLeft(2).Background(lipgloss.Color("22"))
|
||||
TitleStyle = list.DefaultStyles().Title.Background(lipgloss.Color("#b34100"))
|
||||
NonListTitleStyle = TitleStyle.Copy().MarginLeft(2).Background(lipgloss.Color("#b34100"))
|
||||
)
|
||||
|
||||
var (
|
||||
LogoForegroundStyles = []lipgloss.Style{
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("#ff5f00")).Background(lipgloss.Color("#ff5f00")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("#e65400")).Background(lipgloss.Color("#e65400")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("#cc4b00")).Background(lipgloss.Color("#cc4b00")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("#b34100")).Background(lipgloss.Color("#b34100")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("#993800")).Background(lipgloss.Color("#993800")),
|
||||
lipgloss.NewStyle(),
|
||||
}
|
||||
LogoBackgroundStyles = []lipgloss.Style{
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("255")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("252")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("249")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("246")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("243")),
|
||||
lipgloss.NewStyle().Foreground(lipgloss.Color("240")),
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
ListStyles = list.DefaultStyles()
|
||||
ListStyles.Title = TitleStyle
|
||||
ListStyles.HelpStyle = list.DefaultStyles().HelpStyle.PaddingLeft(2).PaddingBottom(1)
|
||||
ListStyles.PaginationStyle = list.DefaultStyles().PaginationStyle.PaddingLeft(2)
|
||||
|
|
Loading…
Reference in a new issue