From 4f2eba7a5899f15c5646778675ebc3b127d8b7c9 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Thu, 21 Jul 2022 14:07:55 -0300 Subject: [PATCH 1/5] docs(example): rainbow string Signed-off-by: Carlos A Becker --- example/go.mod | 1 + example/go.sum | 15 +++++++++++++++ example/main.go | 14 +++++++++++++- go.mod | 1 - 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/example/go.mod b/example/go.mod index 3ff788fb..51dbdf69 100644 --- a/example/go.mod +++ b/example/go.mod @@ -5,6 +5,7 @@ go 1.16 require ( github.com/charmbracelet/lipgloss v0.4.0 github.com/lucasb-eyer/go-colorful v1.2.0 + github.com/muesli/gamut v0.3.0 golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 ) diff --git a/example/go.sum b/example/go.sum index 9ef83e7d..ed7b7ddd 100644 --- a/example/go.sum +++ b/example/go.sum @@ -1,3 +1,6 @@ +github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= @@ -5,6 +8,13 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/muesli/clusters v0.0.0-20180605185049-a07a36e67d36/go.mod h1:mw5KDqUj0eLj/6DUNINLVJNoPTFkEuGMHtJsXLviLkY= +github.com/muesli/clusters v0.0.0-20200529215643-2700303c1762 h1:p4A2Jx7Lm3NV98VRMKlyWd3nqf8obft8NfXlAUmqd3I= +github.com/muesli/clusters v0.0.0-20200529215643-2700303c1762/go.mod h1:mw5KDqUj0eLj/6DUNINLVJNoPTFkEuGMHtJsXLviLkY= +github.com/muesli/gamut v0.3.0 h1:ZL6bOudh1oBQjh5S+9lHZIZ/aodhn9V0F+RtSTb+HOQ= +github.com/muesli/gamut v0.3.0/go.mod h1:28EAV1OoUHPOE9e4EgSfi4seod9CaSJMPlT1Q7ufB/I= +github.com/muesli/kmeans v0.3.0 h1:cI2cpeS8m3pm+gTOdzl+7SlzZYSe+x0XoqXUyUvb1ro= +github.com/muesli/kmeans v0.3.0/go.mod h1:eNyybq0tX9/iBEP6EMU4Y7dpmGK0uEhODdZpnG1a/iQ= github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 h1:y1p/ycavWjGT9FnmSjdbWUlLGvcxrY0Rw3ATltrxOhk= github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ= github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0 h1:STjmj0uFfRryL9fzRA/OupNppeAID6QJYPMavTL7jtY= @@ -12,8 +22,13 @@ github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0/go.mod h1:Bd5NYQ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 h1:EC6+IGYTjPpRfv9a2b/6Puw0W+hLtAhkV1tPsXhutqs= golang.org/x/term v0.0.0-20210317153231-de623e64d2a6/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/example/main.go b/example/main.go index 8ec832b8..617cd9b8 100644 --- a/example/main.go +++ b/example/main.go @@ -2,11 +2,13 @@ package main import ( "fmt" + "image/color" "os" "strings" "github.com/charmbracelet/lipgloss" "github.com/lucasb-eyer/go-colorful" + "github.com/muesli/gamut" "golang.org/x/term" ) @@ -28,6 +30,7 @@ var ( subtle = lipgloss.AdaptiveColor{Light: "#D9DCCF", Dark: "#383838"} highlight = lipgloss.AdaptiveColor{Light: "#874BFD", Dark: "#7D56F4"} special = lipgloss.AdaptiveColor{Light: "#43BF6D", Dark: "#73F59F"} + blends = gamut.Blends(highlight, special, 24) divider = lipgloss.NewStyle(). SetString("•"). @@ -233,7 +236,7 @@ func main() { okButton := activeButtonStyle.Render("Yes") cancelButton := buttonStyle.Render("Maybe") - question := lipgloss.NewStyle().Width(50).Align(lipgloss.Center).Render("Are you sure you want to eat marmalade?") + question := lipgloss.NewStyle().Width(50).Align(lipgloss.Center).Render(Rainbow(lipgloss.NewStyle(), "Are you sure you want to eat marmalade?", blends)) buttons := lipgloss.JoinHorizontal(lipgloss.Top, okButton, cancelButton) ui := lipgloss.JoinVertical(lipgloss.Center, question, buttons) @@ -369,3 +372,12 @@ func max(a, b int) int { } return b } + +func rainbow(base lipgloss.Style, s string, colors []color.Color) string { + var str string + for i, ss := range s { + color, _ := colorful.MakeColor(colors[i%len(colors)]) + str = str + base.Copy().Foreground(lipgloss.Color(color.Hex())).Render(string(ss)) + } + return str +} diff --git a/go.mod b/go.mod index c511c036..e79392ee 100644 --- a/go.mod +++ b/go.mod @@ -7,5 +7,4 @@ require ( github.com/mattn/go-runewidth v0.0.13 github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0 - golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c ) From 1d759ef2c4e921c9bfed3a676d8927395ba48682 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Thu, 21 Jul 2022 14:19:38 -0300 Subject: [PATCH 2/5] fix: rename Signed-off-by: Carlos A Becker --- example/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/main.go b/example/main.go index 617cd9b8..9b2a0a17 100644 --- a/example/main.go +++ b/example/main.go @@ -236,7 +236,7 @@ func main() { okButton := activeButtonStyle.Render("Yes") cancelButton := buttonStyle.Render("Maybe") - question := lipgloss.NewStyle().Width(50).Align(lipgloss.Center).Render(Rainbow(lipgloss.NewStyle(), "Are you sure you want to eat marmalade?", blends)) + question := lipgloss.NewStyle().Width(50).Align(lipgloss.Center).Render(rainbow(lipgloss.NewStyle(), "Are you sure you want to eat marmalade?", blends)) buttons := lipgloss.JoinHorizontal(lipgloss.Top, okButton, cancelButton) ui := lipgloss.JoinVertical(lipgloss.Center, question, buttons) From 203188c5155f26d4ac57e779a1ce4ff2a2efa1f3 Mon Sep 17 00:00:00 2001 From: Carlos A Becker Date: Fri, 22 Jul 2022 15:20:38 -0300 Subject: [PATCH 3/5] fix: update gamut Signed-off-by: Carlos A Becker --- example/go.mod | 2 +- example/go.sum | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/example/go.mod b/example/go.mod index 51dbdf69..de53e522 100644 --- a/example/go.mod +++ b/example/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( github.com/charmbracelet/lipgloss v0.4.0 github.com/lucasb-eyer/go-colorful v1.2.0 - github.com/muesli/gamut v0.3.0 + github.com/muesli/gamut v0.3.1 golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 ) diff --git a/example/go.sum b/example/go.sum index ed7b7ddd..4295b0da 100644 --- a/example/go.sum +++ b/example/go.sum @@ -1,6 +1,4 @@ -github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= @@ -11,10 +9,10 @@ github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/muesli/clusters v0.0.0-20180605185049-a07a36e67d36/go.mod h1:mw5KDqUj0eLj/6DUNINLVJNoPTFkEuGMHtJsXLviLkY= github.com/muesli/clusters v0.0.0-20200529215643-2700303c1762 h1:p4A2Jx7Lm3NV98VRMKlyWd3nqf8obft8NfXlAUmqd3I= github.com/muesli/clusters v0.0.0-20200529215643-2700303c1762/go.mod h1:mw5KDqUj0eLj/6DUNINLVJNoPTFkEuGMHtJsXLviLkY= -github.com/muesli/gamut v0.3.0 h1:ZL6bOudh1oBQjh5S+9lHZIZ/aodhn9V0F+RtSTb+HOQ= -github.com/muesli/gamut v0.3.0/go.mod h1:28EAV1OoUHPOE9e4EgSfi4seod9CaSJMPlT1Q7ufB/I= -github.com/muesli/kmeans v0.3.0 h1:cI2cpeS8m3pm+gTOdzl+7SlzZYSe+x0XoqXUyUvb1ro= -github.com/muesli/kmeans v0.3.0/go.mod h1:eNyybq0tX9/iBEP6EMU4Y7dpmGK0uEhODdZpnG1a/iQ= +github.com/muesli/gamut v0.3.1 h1:8hozovcrDBWLLAwuOXC+UDyO0/uNroIdXAmY/lQOMHo= +github.com/muesli/gamut v0.3.1/go.mod h1:BED0DN21PXU1YaYNwaTmX9700SRHPcWWd6Llj0zsz5k= +github.com/muesli/kmeans v0.3.1 h1:KshLQ8wAETfLWOJKMuDCVYHnafddSa1kwGh/IypGIzY= +github.com/muesli/kmeans v0.3.1/go.mod h1:8/OvJW7cHc1BpRf8URb43m+vR105DDe+Kj1WcFXYDqc= github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 h1:y1p/ycavWjGT9FnmSjdbWUlLGvcxrY0Rw3ATltrxOhk= github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ= github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0 h1:STjmj0uFfRryL9fzRA/OupNppeAID6QJYPMavTL7jtY= From e23bad1a06637a3edd17db5306cbdc3c911ce760 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 13 May 2024 11:14:28 -0300 Subject: [PATCH 4/5] chore: go mod tidy Signed-off-by: Carlos Alexandro Becker --- go.mod | 4 ---- 1 file changed, 4 deletions(-) diff --git a/go.mod b/go.mod index 3ef4560d..da46fbf1 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,6 @@ retract v0.7.0 // v0.7.0 introduces a bug that causes some apps to freeze. go 1.18 require ( - github.com/lucasb-eyer/go-colorful v1.2.0 - github.com/mattn/go-runewidth v0.0.13 - github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 - github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0 github.com/charmbracelet/x/exp/term v0.0.0-20240408110044-525ba71bb562 github.com/muesli/termenv v0.15.2 github.com/rivo/uniseg v0.4.7 From e621cb8e897bce84cbbbf651e5c1017139ca3bf4 Mon Sep 17 00:00:00 2001 From: bashbunni Date: Tue, 24 Sep 2024 11:08:02 -0700 Subject: [PATCH 5/5] refactor: change blended colours --- examples/layout/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/layout/main.go b/examples/layout/main.go index 0ba28486..05725a6a 100644 --- a/examples/layout/main.go +++ b/examples/layout/main.go @@ -32,7 +32,7 @@ var ( subtle = lipgloss.AdaptiveColor{Light: "#D9DCCF", Dark: "#383838"} highlight = lipgloss.AdaptiveColor{Light: "#874BFD", Dark: "#7D56F4"} special = lipgloss.AdaptiveColor{Light: "#43BF6D", Dark: "#73F59F"} - blends = gamut.Blends(highlight, special, 24) + blends = gamut.Blends(lipgloss.Color("#F25D94"), lipgloss.Color("#EDFF82"), 50) divider = lipgloss.NewStyle(). SetString("•").