-
Notifications
You must be signed in to change notification settings - Fork 34
/
banners.go
80 lines (74 loc) · 2.13 KB
/
banners.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// Copyright 2023 Stacklok, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cli
import (
"os"
"github.com/charmbracelet/lipgloss"
"golang.org/x/term"
)
// Color Palette
var (
// PrimaryColor is the primary color for the cli.
PrimaryColor = lipgloss.Color("#00BBBE")
// SecondaryColor is the secondary color for the cli.
SecondaryColor = lipgloss.Color("#59CFA8")
// AccentColor is the accent color for the cli.
AccentColor = lipgloss.Color("#3D34E0")
// WhiteColor is the white color for the cli.
WhiteColor = lipgloss.Color("#FFFFFF")
// BlackColor is the black color for the cli.
BlackColor = lipgloss.Color("#000000")
)
// Styles
var (
// DefaultBannerWidth is the default width for a banner
DefaultBannerWidth = 80
// Header is the style to use for headers
Header = lipgloss.NewStyle().
Bold(true).
Foreground(PrimaryColor).
PaddingTop(1).
PaddingBottom(1).
PaddingLeft(1).
PaddingRight(1).
MaxWidth(80)
WarningBanner = lipgloss.NewStyle().
Bold(true).
Background(BlackColor).
Foreground(WhiteColor).
BorderForeground(AccentColor).
PaddingTop(2).
PaddingBottom(2).
PaddingLeft(4).
PaddingRight(4).
Width(DefaultBannerWidth)
// SuccessBanner is the style to use for a success banner
SuccessBanner = lipgloss.NewStyle().
Bold(true).
Background(AccentColor).
Foreground(WhiteColor).
PaddingTop(1).
PaddingBottom(1).
PaddingLeft(4).
PaddingRight(4).
Width(DefaultBannerWidth)
)
func init() {
// Get the terminal width, if available, and set widths based on terminal width
w, _, err := term.GetSize(int(os.Stdout.Fd()))
if err == nil {
DefaultBannerWidth = w
}
}