Skip to content

Commit

Permalink
refactor: modularise svg icon
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu committed Jun 10, 2024
1 parent 69f7e3e commit aec12f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 9 additions & 0 deletions infrastructure/code/code_html.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func getCodeDetailsHtml(issue snyk.Issue) string {
"LessonIcon": getLessonIconSvg(),
"IgnoreLineAction": getLineToIgnoreAction(issue),
"HasAIFix": additionalData.HasAIFix,
"ExternalIcon": getExternalIconSvg(),
}

if issue.IsIgnored {
Expand Down Expand Up @@ -229,6 +230,14 @@ func formatDate(date time.Time) string {
return fmt.Sprintf("%s %02d, %d", month, date.Day(), date.Year())
}

func getExternalIconSvg() template.HTML {
return template.HTML(` <svg class="is-external-icon" width="9" height="9" viewBox="0 0 9 9" xmlns="http://www.w3.
org/2000/svg" fill="none">
<path d="M4.99998 0L6.64648 1.6465L3.14648 5.1465L3.85348 5.8535L7.35348 2.3535L8.99998 4V0H4.99998Z" fill="#888"/>
<path d="M8 8H1V1H4.5L3.5 0H1C0.4485 0 0 0.4485 0 1V8C0 8.5515 0.4485 9 1 9H8C8.5515 9 9 8.5515 9 8V5.5L8 4.5V8Z" fill="#888"/>
</svg>`)
}

func getSeverityIconSvg(issue snyk.Issue) template.HTML {
switch issue.Severity {
case snyk.Critical:
Expand Down
10 changes: 6 additions & 4 deletions infrastructure/code/template/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
padding-right: 12px;
}

.is-external-icon {
margin-bottom: 8px;
margin-left: 2px;
}

.styled-link {
text-decoration: none;
}
Expand Down Expand Up @@ -663,10 +668,7 @@ <h2 class="severity-title">{{.IssueTitle}}</h2>
</div>
<a class="lesson-link styled-link is-external" target="_blank" rel="noopener noreferrer" href="{{.LessonUrl}}">
Learn about this vulnerability
<svg width="9" height="9" viewBox="0 0 9 9" xmlns="http://www.w3.org/2000/svg" fill="none">
<path d="M4.99998 0L6.64648 1.6465L3.14648 5.1465L3.85348 5.8535L7.35348 2.3535L8.99998 4V0H4.99998Z" fill="#888"/>
<path d="M8 8H1V1H4.5L3.5 0H1C0.4485 0 0 0.4485 0 1V8C0 8.5515 0.4485 9 1 9H8C8.5515 9 9 8.5515 9 8V5.5L8 4.5V8Z" fill="#888"/>
</svg>
{{.ExternalIcon}}
</a>
</div>
{{end}}
Expand Down

0 comments on commit aec12f5

Please sign in to comment.