Skip to content

Commit

Permalink
Merge pull request #42 from AnshumanNeon/anshuman_main_branch
Browse files Browse the repository at this point in the history
Anshuman main branch
  • Loading branch information
yorukot authored Apr 10, 2024
2 parents 3d43c42 + 1efe716 commit 53819f0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 40 deletions.
Binary file modified asset/theme/catpuccin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/components/modelRender.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ func SideBarRender(m model) string {
cursor = ""
}
if folder.location == m.fileModel.filePanels[m.filePanelFocusIndex].location {
s += cursorStyle.Render(cursor) + " " + sideBarSelected.Render(TruncateText(folder.name, sideBarWidth-2)) + "" + "\n"
s += cursorStyle.Render(cursor) + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + sideBarSelected.Render(TruncateText(folder.name, sideBarWidth-2)) + "" + "\n"
} else {
s += cursorStyle.Render(cursor) + " " + sideBarItem.Render(TruncateText(folder.name, sideBarWidth-2)) + "" + "\n"
s += cursorStyle.Render(cursor) + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + sideBarItem.Render(TruncateText(folder.name, sideBarWidth-2)) + "" + "\n"
}
if i == 7 {
s += "\n" + sideBarTitle.Render("󰐃 Pinned") + borderStyle.Render(" ───────────") + "\n\n"
Expand Down Expand Up @@ -78,7 +78,7 @@ func FilePanelRender(m model) string {
if filePanel.renaming && h == filePanel.cursor {
f[i] += filePanel.rename.View() + "\n"
} else {
f[i] += cursorStyle.Render(cursor) + " " + PrettierName(filePanel.element[h].name, m.fileModel.width-5, filePanel.element[h].folder, isItemSelected) + "\n"
f[i] += cursorStyle.Render(cursor) + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + PrettierName(filePanel.element[h].name, m.fileModel.width-5, filePanel.element[h].folder, isItemSelected) + "\n"
}
}
cursorPosition := strconv.Itoa(filePanel.cursor + 1)
Expand Down Expand Up @@ -307,13 +307,13 @@ func TypineModalRender(m model) string {
fileLocation := filePanelTopFolderIcon.Render("  ") + filePanelTopPath.Render(TruncateTextBeginning(m.typingModal.location+"/"+m.typingModal.textInput.Value(), modalWidth-4)) + "\n"
confirm := modalConfirm.Render(" (" + Config.Confirm[0] + ") New File ")
cancel := modalCancel.Render(" (" + Config.Cancel[0] + ") Cancel ")
tip := confirm + " " + cancel
tip := confirm + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + cancel
return FullScreenStyle(m.fullHeight, m.fullWidth).Render(FocusedModalStyle(modalHeight, modalWidth).Render(fileLocation + "\n" + m.typingModal.textInput.View() + "\n\n" + tip))
} else {
fileLocation := filePanelTopFolderIcon.Render("  ") + filePanelTopPath.Render(TruncateTextBeginning(m.typingModal.location+"/"+m.typingModal.textInput.Value(), modalWidth-4)) + "\n"
confirm := modalConfirm.Render(" (" + Config.Confirm[0] + ") New Folder ")
cancel := modalCancel.Render(" (" + Config.Cancel[0] + ") Cancel ")
tip := confirm + " " + cancel
tip := confirm + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + cancel
return FullScreenStyle(m.fullHeight, m.fullWidth).Render(FocusedModalStyle(modalHeight, modalWidth).Render(fileLocation + "\n" + m.typingModal.textInput.View() + "\n\n" + tip))
}
}
Expand All @@ -323,6 +323,6 @@ func WarnModalRender(m model) string {
content := m.warnModal.content
confirm := modalCancel.Render(" (" + Config.Confirm[0] + ") Confirm ")
cancel := modalCancel.Render(" (" + Config.Cancel[0] + ") Cancel ")
tip := confirm + " " + cancel
tip := confirm + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + cancel
return FullScreenStyle(m.fullHeight, m.fullWidth).Render(FocusedModalStyle(modalHeight, modalWidth).Render(title + "\n\n" + content + "\n\n" + tip))
}
75 changes: 43 additions & 32 deletions src/components/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ var (
terminalTooSmall lipgloss.Style
terminalMinimumSize lipgloss.Style

borderStyle lipgloss.Style
cursorStyle lipgloss.Style
borderStyle lipgloss.Style
cursorStyle lipgloss.Style
backgroundWindow lipgloss.Color
)

var (
sideBarWidth = 20
sideBarTitle lipgloss.Style
sideBarItem lipgloss.Style
sideBarSelected lipgloss.Style
sideBarWidth = 20
sideBarTitle lipgloss.Style
sideBarItem lipgloss.Style
sideBarSelected lipgloss.Style
)

var (
Expand All @@ -39,50 +40,54 @@ var (
)

func LoadThemeConfig() {
terminalTooSmall = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.TerminalTooSmallError))
terminalMinimumSize = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.TerminalSizeCorrect))
backgroundWindow = lipgloss.Color(theme.BackgroundWindow)

borderStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.Border))
cursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.Cursor)).Bold(true)
terminalTooSmall = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.TerminalTooSmallError)).Background(backgroundWindow)
terminalMinimumSize = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.TerminalSizeCorrect)).Background(backgroundWindow)

sideBarTitle = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.SideBarTitle)).Bold(true)
sideBarItem = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.SideBarItem))
borderStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.Border)).Background(backgroundWindow)
cursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.Cursor)).Bold(true).Background(backgroundWindow)

sideBarSelected = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.SideBarSelected)).Bold(true)
sideBarTitle = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.SideBarTitle)).Bold(true).Background(backgroundWindow)
sideBarItem = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.SideBarItem)).Background(backgroundWindow)

filePanelTopFolderIcon = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelTopFolderIcon)).Bold(true)
filePanelTopPath = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelTopPath)).Bold(true)
filePanelItem = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelItem))
filePanelItemSelected = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelItemSelected))
sideBarSelected = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.SideBarSelected)).Bold(true).Background(backgroundWindow)

filePanelTopFolderIcon = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelTopFolderIcon)).Bold(true).Background(backgroundWindow)
filePanelTopPath = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelTopPath)).Bold(true).Background(backgroundWindow)
filePanelItem = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelItem)).Background(backgroundWindow)
filePanelItemSelected = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.FilePanelItemSelected)).Background(backgroundWindow)

modalCancel = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.ModalForeground)).Background(lipgloss.Color(theme.ModalCancel))
modalConfirm = lipgloss.NewStyle().Foreground(lipgloss.Color(theme.ModalForeground)).Background(lipgloss.Color(theme.ModalConfirm))
}

func FullScreenStyle(height int, width int) lipgloss.Style {
return lipgloss.NewStyle().Height(height).Width(width).Align(lipgloss.Center, lipgloss.Center)
return lipgloss.NewStyle().Height(height).Width(width).Align(lipgloss.Center, lipgloss.Center).Background(backgroundWindow)
}

func FocusedModalStyle(height int, width int) lipgloss.Style {
return lipgloss.NewStyle().Height(height).
Width(width).
Align(lipgloss.Center, lipgloss.Center).
Border(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(theme.FilePanelFocus))
BorderForeground(lipgloss.Color(theme.FilePanelFocus)).BorderBackground(backgroundWindow).Background(backgroundWindow)
}

func SideBarBoardStyle(height int, focus focusPanelType) lipgloss.Style {
if focus == sideBarFocus {
return lipgloss.NewStyle().
BorderStyle(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(theme.SideBarFocus)).
BorderBackground(backgroundWindow).
Width(sideBarWidth).
Height(height).Bold(true)
Height(height).Bold(true).Background(backgroundWindow)
} else {
return lipgloss.NewStyle().
BorderStyle(lipgloss.HiddenBorder()).
BorderBackground(backgroundWindow).
Width(sideBarWidth).
Height(height).Bold(true)
Height(height).Bold(true).Background(backgroundWindow)
}
}

Expand Down Expand Up @@ -111,8 +116,9 @@ func FilePanelBoardStyle(height int, width int, focusType filePanelFocusType, bo
return lipgloss.NewStyle().
Border(filePanelBottomBoard, true, true, true, true).
BorderForeground(lipgloss.Color(FilePanelFocusColor(focusType))).
BorderBackground(backgroundWindow).
Width(width).
Height(height)
Height(height).Background(backgroundWindow)
}

func ProcsssBarBoarder(height int, width int, borderBottom string, focusType focusPanelType) lipgloss.Style {
Expand All @@ -130,14 +136,16 @@ func ProcsssBarBoarder(height int, width int, borderBottom string, focusType foc
return lipgloss.NewStyle().
Border(filePanelBottomBoard, true, true, true, true).
BorderForeground(lipgloss.Color(theme.BottomBarFocus)).
BorderBackground(backgroundWindow).
Width(width).
Height(height).Bold(true)
Height(height).Bold(true).Background(backgroundWindow)
} else {
return lipgloss.NewStyle().
Border(filePanelBottomBoard, true, true, true, true).
BorderForeground(lipgloss.Color(theme.Border)).
BorderBackground(backgroundWindow).
Width(width).
Height(height).Bold(true)
Height(height).Bold(true).Background(backgroundWindow)
}
}

Expand All @@ -156,14 +164,16 @@ func MetaDataBoarder(height int, width int, borderBottom string, focusType focus
return lipgloss.NewStyle().
Border(filePanelBottomBoard, true, true, true, true).
BorderForeground(lipgloss.Color(theme.BottomBarFocus)).
BorderBackground(backgroundWindow).
Width(width).
Height(height).Bold(true)
Height(height).Bold(true).Background(backgroundWindow)
} else {
return lipgloss.NewStyle().
Border(filePanelBottomBoard, true, true, true, true).
BorderForeground(lipgloss.Color(theme.Border)).
BorderBackground(backgroundWindow).
Width(width).
Height(height).Bold(true)
Height(height).Bold(true).Background(backgroundWindow)
}
}

Expand All @@ -182,13 +192,14 @@ func ClipboardBoarder(height int, width int, borderBottom string) lipgloss.Style
return lipgloss.NewStyle().
Border(filePanelBottomBoard, true, true, true, true).
BorderForeground(lipgloss.Color(theme.Border)).
BorderBackground(backgroundWindow).
Width(width).
Height(height).Bold(true)
Height(height).Bold(true).Background(backgroundWindow)

}

func FilePanelDividerStyle(focusType filePanelFocusType) lipgloss.Style {
return lipgloss.NewStyle().Foreground(lipgloss.Color(FilePanelFocusColor(focusType))).Bold(true)
return lipgloss.NewStyle().Foreground(lipgloss.Color(FilePanelFocusColor(focusType))).Bold(true).Background(backgroundWindow)
}

func TruncateText(text string, maxChars int) string {
Expand Down Expand Up @@ -223,18 +234,18 @@ func TruncateMiddleText(text string, maxChars int) string {
func PrettierName(name string, width int, isDir bool, isSelected bool) string {
style := getElementIcon(name, isDir)
if isSelected {
return StringColorRender(style.color).Render(style.icon) + " " + filePanelItemSelected.Render(TruncateText(name, width))
return StringColorRender(style.color).Background(backgroundWindow).Render(style.icon) + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + filePanelItemSelected.Render(TruncateText(name, width))
} else {
return StringColorRender(style.color).Render(style.icon) + " " + filePanelItem.Render(TruncateText(name, width))
return StringColorRender(style.color).Background(backgroundWindow).Render(style.icon) + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + filePanelItem.Render(TruncateText(name, width))
}
}

func ClipboardPrettierName(name string, width int, isDir bool, isSelected bool) string {
style := getElementIcon(name, isDir)
if isSelected {
return StringColorRender(style.color).Render(style.icon) + " " + filePanelItemSelected.Render(TruncateTextBeginning(name, width))
return StringColorRender(style.color).Background(backgroundWindow).Render(style.icon) + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + filePanelItemSelected.Render(TruncateTextBeginning(name, width))
} else {
return StringColorRender(style.color).Render(style.icon) + " " + filePanelItem.Render(TruncateTextBeginning(name, width))
return StringColorRender(style.color).Background(backgroundWindow).Render(style.icon) + lipgloss.NewStyle().Background(backgroundWindow).Render(" ") + filePanelItem.Render(TruncateTextBeginning(name, width))
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ type iconStyle struct {

// Theme configuration
type ThemeType struct {
Border string
Cursor string
Border string
Cursor string
BackgroundWindow string

TerminalTooSmallError string
TerminalSizeCorrect string
Expand Down
2 changes: 2 additions & 0 deletions src/superfile/theme/catpuccin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"border": "#6c7086",
"cursor": "#f5e0dc",

"backgroundWindow": "#1e1e2e",

"terminalTooSmallError": "#c74a4d",
"terminalSizeCurrect": "#4EB8CA",

Expand Down

0 comments on commit 53819f0

Please sign in to comment.