-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
central utility for the charm, reusable classes
Signed-off-by: amands98 <amandeepsm.in@gmail.com>
- Loading branch information
Showing
12 changed files
with
105 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package tablelist | ||
|
||
import ( | ||
"github.com/charmbracelet/bubbles/table" | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/goharbor/harbor-cli/pkg/views" | ||
) | ||
|
||
type Model struct { | ||
Table table.Model | ||
} | ||
|
||
func NewModel(columns []table.Column, rows []table.Row, height int) Model { | ||
t := table.New( | ||
table.WithColumns(columns), | ||
table.WithRows(rows), | ||
table.WithFocused(true), | ||
table.WithHeight(height), | ||
) | ||
|
||
// Set the styles for the table | ||
s := table.DefaultStyles() | ||
s.Header = s.Header. | ||
BorderStyle(lipgloss.NormalBorder()). | ||
BorderBottom(true). | ||
Bold(false) | ||
|
||
s.Selected = s.Selected. | ||
Foreground(s.Cell.GetForeground()). | ||
Background(s.Cell.GetBackground()). | ||
Bold(false) | ||
t.SetStyles(s) | ||
|
||
return Model{Table: t} | ||
} | ||
|
||
func (m Model) Init() tea.Cmd { | ||
return tea.Quit | ||
} | ||
|
||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
var cmd tea.Cmd | ||
m.Table, cmd = m.Table.Update(msg) | ||
return m, cmd | ||
} | ||
|
||
func (m Model) View() string { | ||
return views.BaseStyle.Render(m.Table.View()) + "\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.