Skip to content

Commit

Permalink
Working through color profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
JustSteveKing committed Mar 13, 2024
1 parent f2ad998 commit eeafc9b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 16 deletions.
86 changes: 76 additions & 10 deletions pkg/styles/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,83 @@ var Title = lipgloss.NewStyle().
var Divider = lipgloss.NewStyle().
Foreground(lipgloss.Color("8"))

// Define a map for grade to color mapping
var ReportsSvgGradeColorMap = map[string]string{
"A": "#54FF77",
"B": "#04E8B0",
"C": "#FFF586",
"D": "#FFA463",
"F": "#FF0057",
// Define a map for grade to color mapping
var ReportsSvgGradeColorMap = map[string]lipgloss.CompleteAdaptiveColor{
"A": {
Light: lipgloss.CompleteColor{
TrueColor: "#2ABC48",
ANSI256: "6",
ANSI: "6",
},
Dark: lipgloss.CompleteColor{
TrueColor: "#54FF77",
ANSI256: "8",
ANSI: "8",
},
},
"B": {
Light: lipgloss.CompleteColor{
TrueColor: "#04E8B0",
ANSI256: "14",
ANSI: "14",
},
Dark: lipgloss.CompleteColor{
TrueColor: "#04E8B0",
ANSI256: "14",
ANSI: "14",
},
},
"C": {
Light: lipgloss.CompleteColor{
TrueColor: "#B59D03",
ANSI256: "3",
ANSI: "3",
},
Dark: lipgloss.CompleteColor{
TrueColor: "#FFF36B",
ANSI256: "11",
ANSI: "1",
},
},
"D": {
Light: lipgloss.CompleteColor{
TrueColor: "#FF862F",
ANSI256: "11",
ANSI: "1",
},
Dark: lipgloss.CompleteColor{
TrueColor: "#FF862F",
ANSI256: "11",
ANSI: "11",
},
},
"F": {
Light: lipgloss.CompleteColor{
TrueColor: "#FF0057",
ANSI256: "9",
ANSI: "9",
},
Dark: lipgloss.CompleteColor{
TrueColor: "#FF0057",
ANSI256: "9",
ANSI: "9",
},
},
}

// Define a fallback color constant
const ReportsSvgColorBoundaryFallbackColor = "#6C7285"
var ReportsSvgColorBoundaryFallbackColor = lipgloss.CompleteAdaptiveColor{
Light: lipgloss.CompleteColor{
TrueColor: "#3C3C56",
ANSI256: "4",
ANSI: "4",
},
Dark: lipgloss.CompleteColor{
TrueColor: "#E6EAF6",
ANSI256: "15",
ANSI: "15",
},
}

var reportsGradeToScorePercentageMap = map[string][2]int{
"A": {90, 100},
Expand Down Expand Up @@ -85,7 +151,7 @@ func StyleForScore(score int) lipgloss.Style {
color = ReportsSvgColorBoundaryFallbackColor
}

return lipgloss.NewStyle().Foreground(lipgloss.Color(color))
return lipgloss.NewStyle().Foreground(color)
}

// Define a map for grade to score percentage range
Expand All @@ -96,5 +162,5 @@ func StyleForGrade(grade string) lipgloss.Style {
color = ReportsSvgColorBoundaryFallbackColor
}

return lipgloss.NewStyle().Foreground(lipgloss.Color(color))
return lipgloss.NewStyle().Foreground(color)
}
7 changes: 1 addition & 6 deletions pkg/views/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ func ShowInsightsDetails(apiResponse *types.ApiResponse) {
}

func ShowInsightsTechnologyDiscovery(apiResponse *types.ApiResponse) {
pterm.DefaultSection.WithLevel(2).Println("Technologies Discovered")

testData := pterm.TableData{{"Technology Name"}}
testData := pterm.TableData{{"Technologies Discovered"}}
for _, technology := range apiResponse.Report.Technologies {
row := []string{
styles.Title.Render(technology.Name),
Expand Down Expand Up @@ -138,8 +137,6 @@ func NewInsightsDesignView(apiResponse *types.ApiResponse) {

pterm.DefaultTable.WithHasHeader().WithBoxed().WithData(tableData).Render()

pterm.DefaultSection.WithLevel(2).Println("Design Tests")

testData := pterm.TableData{{"Test Title", "Status"}}
for _, test := range category.Tests {
row := []string{
Expand Down Expand Up @@ -169,8 +166,6 @@ func NewInsightsSecurityView(apiResponse *types.ApiResponse) {

pterm.DefaultTable.WithHasHeader().WithBoxed().WithData(tableData).Render()

pterm.DefaultSection.WithLevel(2).Println("Security Tests")

testData := pterm.TableData{{"Test Title", "Status"}}
for _, test := range category.Tests {
row := []string{
Expand Down

0 comments on commit eeafc9b

Please sign in to comment.