Skip to content

Commit

Permalink
refactor: changed the style package name to colorscheme
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Jan 9, 2023
1 parent 9444179 commit 265df8d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
10 changes: 5 additions & 5 deletions cmd/goread/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"os"

"github.com/TypicalAM/goread/internal/colorscheme"
"github.com/TypicalAM/goread/internal/config"
"github.com/TypicalAM/goread/internal/model/browser"
"github.com/TypicalAM/goread/internal/style"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
Expand Down Expand Up @@ -44,7 +44,7 @@ func main() {

// If the user wants to test the colors, do that and exit
if testColors {
fmt.Println(style.GlobalColorscheme.TestColors())
fmt.Println(colorscheme.Global.TestColors())
os.Exit(0)
}

Expand All @@ -68,14 +68,14 @@ func main() {

func convertFromPywal() {
// Convert the pywal colorscheme
err := style.GlobalColorscheme.Convert()
err := colorscheme.Global.Convert()
if err != nil {
fmt.Println(err)
os.Exit(1)
}

// Save the colorscheme
err = style.GlobalColorscheme.Save("")
err = colorscheme.Global.Save("")
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand All @@ -84,5 +84,5 @@ func convertFromPywal() {
// Notify the user
messageStyle := lipgloss.NewStyle().Italic(true).Foreground(lipgloss.Color("#6bae6c"))
fmt.Println(messageStyle.Render("The new colorscheme was saved to the config directory\n"))
fmt.Println(style.GlobalColorscheme.TestColors())
fmt.Println(colorscheme.Global.TestColors())
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package style
package colorscheme

import (
"encoding/json"
Expand All @@ -11,8 +11,8 @@ import (
"github.com/charmbracelet/lipgloss"
)

// Create the basic colorscheme on startup
var GlobalColorscheme = Load("")
// Create the colorscheme on startup
var Global = Load("")

// The basic colorscheme to use in the app
type Colorscheme struct {
Expand Down
26 changes: 13 additions & 13 deletions internal/model/browser/style.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package browser

import (
"github.com/TypicalAM/goread/internal/colorscheme"
"github.com/TypicalAM/goread/internal/model/tab"
"github.com/TypicalAM/goread/internal/style"
"github.com/charmbracelet/lipgloss"
)

Expand All @@ -16,33 +16,33 @@ var (
Padding(0, 0, 0, 3).
Bold(true).
Border(lipgloss.Border{Left: "┃"}, false, false, false, true).
BorderForeground(style.GlobalColorscheme.TextDark)
BorderForeground(colorscheme.Global.TextDark)

tabStyle = lipgloss.NewStyle().
Padding(0, 7, 0, 1).
Background(style.GlobalColorscheme.BgDark).
Foreground(style.GlobalColorscheme.TextDark)
Background(colorscheme.Global.BgDark).
Foreground(colorscheme.Global.TextDark)

tabIcon = activeTabIcon.Copy().
Background(style.GlobalColorscheme.BgDark).
BorderForeground(style.GlobalColorscheme.BgDarker).
BorderBackground(style.GlobalColorscheme.BgDark)
Background(colorscheme.Global.BgDark).
BorderForeground(colorscheme.Global.BgDarker).
BorderBackground(colorscheme.Global.BgDark)

tabGap = lipgloss.NewStyle().
Background(style.GlobalColorscheme.BgDarker)
Background(colorscheme.Global.BgDarker)

statusBarGap = lipgloss.NewStyle().
Background(style.GlobalColorscheme.BgDark)
Background(colorscheme.Global.BgDark)

statusBarCell = lipgloss.NewStyle().
Bold(true).
Padding(0, 1).
Foreground(style.GlobalColorscheme.BgDark)
Foreground(colorscheme.Global.BgDark)

iconColors = map[tab.Type]lipgloss.Color{
tab.Welcome: style.GlobalColorscheme.Color4,
tab.Category: style.GlobalColorscheme.Color5,
tab.Feed: style.GlobalColorscheme.Color3,
tab.Welcome: colorscheme.Global.Color4,
tab.Category: colorscheme.Global.Color5,
tab.Feed: colorscheme.Global.Color3,
}

icons = map[tab.Type]string{
Expand Down
18 changes: 9 additions & 9 deletions internal/model/simplelist/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package simplelist
import (
"fmt"

"github.com/TypicalAM/goread/internal/style"
"github.com/TypicalAM/goread/internal/colorscheme"
"github.com/charmbracelet/lipgloss"
)

Expand All @@ -24,28 +24,28 @@ func newListStyle() listStyle {

// titleStyle is used to style the title of the list
newStyle.titleStyle = lipgloss.NewStyle().
Foreground(style.GlobalColorscheme.Color1).
Foreground(colorscheme.Global.Color1).
MarginLeft(3).
PaddingBottom(1)

// newItemsStyle is used to style the message when there are no items
newStyle.noItemsStyle = lipgloss.NewStyle().
MarginLeft(3).
Foreground(style.GlobalColorscheme.Color2).
Foreground(colorscheme.Global.Color2).
Italic(true)

// newItemsStyle is used to style the items in the list
newStyle.itemStyle = lipgloss.NewStyle().
MarginLeft(3).
Foreground(style.GlobalColorscheme.Color2)
Foreground(colorscheme.Global.Color2)

// bracketStyle is used to style the brackets around the index
newStyle.bracketStyle = lipgloss.NewStyle().
Foreground(style.GlobalColorscheme.Color7)
Foreground(colorscheme.Global.Color7)

// numberStyle is used to style the number in the index
newStyle.numberStyle = lipgloss.NewStyle().
Foreground(style.GlobalColorscheme.Color6)
Foreground(colorscheme.Global.Color6)

// Return the new style
return newStyle
Expand All @@ -56,12 +56,12 @@ func (s listStyle) styleDescription(description string) string {
// Create the arrow style
arrowStyle := lipgloss.NewStyle().
MarginLeft(10).
Foreground(style.GlobalColorscheme.Color3)
Foreground(colorscheme.Global.Color3)

// Create the text style
textStyle := lipgloss.NewStyle().
MarginLeft(1).
Foreground(style.GlobalColorscheme.Color3)
Foreground(colorscheme.Global.Color3)

return arrowStyle.Render("⮡") + textStyle.Render(description)
}
Expand All @@ -71,7 +71,7 @@ func (s listStyle) styleIndex(index int, isSelected bool) string {
// If the index is the active index render it differently
numberStyle := s.numberStyle.Copy()
if isSelected {
numberStyle = numberStyle.Background(style.GlobalColorscheme.Text)
numberStyle = numberStyle.Background(colorscheme.Global.Text)
}

// Check if the index is a digit
Expand Down
14 changes: 7 additions & 7 deletions internal/model/tab/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"

"github.com/TypicalAM/goread/internal/backend"
"github.com/TypicalAM/goread/internal/colorscheme"
"github.com/TypicalAM/goread/internal/model/simplelist"
"github.com/TypicalAM/goread/internal/model/tab"
"github.com/TypicalAM/goread/internal/style"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/spinner"
"github.com/charmbracelet/bubbles/viewport"
Expand Down Expand Up @@ -37,7 +37,7 @@ func New(width, height int, title string, reader func(string) tea.Cmd) Model {
// Create a spinner for loading the data
spin := spinner.New()
spin.Spinner = spinner.Points
spin.Style = lipgloss.NewStyle().Foreground(style.GlobalColorscheme.Color1)
spin.Style = lipgloss.NewStyle().Foreground(colorscheme.Global.Color1)

// Create the model
return Model{
Expand Down Expand Up @@ -149,13 +149,13 @@ func (m Model) loadTab(items []list.Item) (tab.Tab, tea.Cmd) {
// Create the styles for the list items
delegateStyles := list.NewDefaultItemStyles()
delegateStyles.SelectedTitle = delegateStyles.SelectedTitle.Copy().
BorderForeground(style.GlobalColorscheme.Color3).
Foreground(style.GlobalColorscheme.Color3).
BorderForeground(colorscheme.Global.Color3).
Foreground(colorscheme.Global.Color3).
Italic(true)

delegateStyles.SelectedDesc = delegateStyles.SelectedDesc.Copy().
BorderForeground(style.GlobalColorscheme.Color3).
Foreground(style.GlobalColorscheme.Color2).
BorderForeground(colorscheme.Global.Color3).
Foreground(colorscheme.Global.Color2).
Italic(true)

// Create the list
Expand Down Expand Up @@ -245,7 +245,7 @@ func (m Model) showLoading() string {
if m.fetchFailed {
// Render the failed message with an cross mark
errorMsgStyle := messageStyle.Copy().
Foreground(style.GlobalColorscheme.Color4)
Foreground(colorscheme.Global.Color4)
loadingMsg = lipgloss.JoinHorizontal(
lipgloss.Top,
errorMsgStyle.Render(" "),
Expand Down
6 changes: 3 additions & 3 deletions internal/model/tab/feed/style.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package feed

import (
"github.com/TypicalAM/goread/internal/style"
"github.com/TypicalAM/goread/internal/colorscheme"
"github.com/charmbracelet/lipgloss"
)

var (
columnStyle = lipgloss.NewStyle().
Border(lipgloss.NormalBorder()).
BorderForeground(style.GlobalColorscheme.TextDark)
BorderForeground(colorscheme.Global.TextDark)

focusedStyle = lipgloss.NewStyle().
Border(lipgloss.NormalBorder()).
BorderForeground(style.GlobalColorscheme.Color1)
BorderForeground(colorscheme.Global.Color1)
)

0 comments on commit 265df8d

Please sign in to comment.