mirror of
https://github.com/charmbracelet/gum.git
synced 2024-09-11 06:16:03 +03:00
* refactor: hide style flags on error to not clutter usage * docs(style): add comment regarding dynamically hiding flags
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package style
|
|
|
|
import (
|
|
"github.com/charmbracelet/lipgloss"
|
|
|
|
"github.com/charmbracelet/gum/internal/decode"
|
|
)
|
|
|
|
// ToLipgloss takes a Styles flag set and returns the corresponding
|
|
// lipgloss.Style.
|
|
func (s Styles) ToLipgloss() lipgloss.Style {
|
|
return lipgloss.NewStyle().
|
|
Background(lipgloss.Color(s.Background)).
|
|
Foreground(lipgloss.Color(s.Foreground)).
|
|
BorderBackground(lipgloss.Color(s.BorderBackground)).
|
|
BorderForeground(lipgloss.Color(s.BorderForeground)).
|
|
Align(decode.Align[s.Align]).
|
|
Border(Border[s.Border]).
|
|
Height(s.Height).
|
|
Width(s.Width).
|
|
Margin(parseMargin(s.Margin)).
|
|
Padding(parsePadding(s.Padding)).
|
|
Bold(s.Bold).
|
|
Faint(s.Faint).
|
|
Italic(s.Italic).
|
|
Strikethrough(s.Strikethrough).
|
|
Underline(s.Underline)
|
|
}
|
|
|
|
// ToLipgloss takes a Styles flag set and returns the corresponding
|
|
// lipgloss.Style.
|
|
func (s StylesNotHidden) ToLipgloss() lipgloss.Style {
|
|
return lipgloss.NewStyle().
|
|
Background(lipgloss.Color(s.Background)).
|
|
Foreground(lipgloss.Color(s.Foreground)).
|
|
BorderBackground(lipgloss.Color(s.BorderBackground)).
|
|
BorderForeground(lipgloss.Color(s.BorderForeground)).
|
|
Align(decode.Align[s.Align]).
|
|
Border(Border[s.Border]).
|
|
Height(s.Height).
|
|
Width(s.Width).
|
|
Margin(parseMargin(s.Margin)).
|
|
Padding(parsePadding(s.Padding)).
|
|
Bold(s.Bold).
|
|
Faint(s.Faint).
|
|
Italic(s.Italic).
|
|
Strikethrough(s.Strikethrough).
|
|
Underline(s.Underline)
|
|
}
|