feat: icons added via <img> by static path
This commit is contained in:
parent
b036002ca8
commit
d7dce88751
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
@ -18,6 +19,11 @@ type Category struct {
|
||||||
Name string
|
Name string
|
||||||
ColorHsl string
|
ColorHsl string
|
||||||
Score int
|
Score int
|
||||||
|
IconPath string
|
||||||
|
}
|
||||||
|
|
||||||
|
func iconPath(categoryName string) string {
|
||||||
|
return fmt.Sprintf("/static/public/images/icon-%s.svg", categoryName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// starts webserver that serves html page for exercise
|
// starts webserver that serves html page for exercise
|
||||||
|
@ -31,15 +37,19 @@ func main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
mySummary := [...]Category{
|
mySummary := [...]Category{
|
||||||
{Name: "Reaction", ColorHsl: "0deg 100% 67%", Score: 80},
|
{Name: "Reaction", ColorHsl: "0deg 100% 67%",
|
||||||
{Name: "Memory", ColorHsl: "39deg 100% 56%", Score: 92},
|
Score: 80, IconPath: iconPath("reaction")},
|
||||||
{Name: "Verbal", ColorHsl: "166deg 100% 37%", Score: 61},
|
{Name: "Memory", ColorHsl: "39deg 100% 56%",
|
||||||
{Name: "Visual", ColorHsl: "234deg 85% 45%", Score: 72},
|
Score: 92, IconPath: iconPath("memory")},
|
||||||
|
{Name: "Verbal", ColorHsl: "166deg 100% 37%",
|
||||||
|
Score: 61, IconPath: iconPath("verbal")},
|
||||||
|
{Name: "Visual", ColorHsl: "234deg 85% 45%",
|
||||||
|
Score: 72, IconPath: iconPath("visual")},
|
||||||
}
|
}
|
||||||
|
|
||||||
// main page with results summary
|
// main page with results summary
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
||||||
templateName := "templates/summary-component.gohtml"
|
templateName := "templates/summary-component.gohtml"
|
||||||
tmpl := template.Must(template.ParseFS(templates, templateName))
|
tmpl := template.Must(template.ParseFS(templates, templateName))
|
||||||
if err := tmpl.Execute(w, mySummary); err != nil {
|
if err := tmpl.Execute(w, mySummary); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
|
@ -600,6 +600,10 @@ video {
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rounded-lg {
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.rounded-b-3xl {
|
.rounded-b-3xl {
|
||||||
border-bottom-right-radius: 1.5rem;
|
border-bottom-right-radius: 1.5rem;
|
||||||
border-bottom-left-radius: 1.5rem;
|
border-bottom-left-radius: 1.5rem;
|
||||||
|
@ -610,8 +614,8 @@ video {
|
||||||
background-color: hsl(224 30% 27% / var(--tw-bg-opacity));
|
background-color: hsl(224 30% 27% / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.bg-summary-item-color\/10 {
|
.bg-summary-item-color\/5 {
|
||||||
background-color: hsl(var(--summary-item-color-var) / 0.1);
|
background-color: hsl(var(--summary-item-color-var) / 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
.bg-gradient-to-t {
|
.bg-gradient-to-t {
|
||||||
|
@ -647,10 +651,19 @@ video {
|
||||||
padding-right: 2.5rem;
|
padding-right: 2.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.px-5 {
|
||||||
|
padding-left: 1.25rem;
|
||||||
|
padding-right: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
.pb-8 {
|
.pb-8 {
|
||||||
padding-bottom: 2rem;
|
padding-bottom: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pr-2 {
|
||||||
|
padding-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.pt-4 {
|
.pt-4 {
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
}
|
}
|
||||||
|
@ -682,6 +695,11 @@ video {
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-dark-gray-blue {
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: hsl(224 30% 27% / var(--tw-text-opacity));
|
||||||
|
}
|
||||||
|
|
||||||
.text-pale-blue {
|
.text-pale-blue {
|
||||||
--tw-text-opacity: 1;
|
--tw-text-opacity: 1;
|
||||||
color: hsl(221 100% 96% / var(--tw-text-opacity));
|
color: hsl(221 100% 96% / var(--tw-text-opacity));
|
||||||
|
|
|
@ -53,16 +53,17 @@
|
||||||
|
|
||||||
<section class="flex flex-col gap-y-4 p-7">
|
<section class="flex flex-col gap-y-4 p-7">
|
||||||
<h2 class="font-bold">Summary</h2>
|
<h2 class="font-bold">Summary</h2>
|
||||||
<dl class="flex flex-col">
|
<dl class="flex flex-col gap-y-4">
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
<div
|
<div
|
||||||
class="flex flex-row bg-summary-item-color/10"
|
class="flex flex-row items-center px-5 h-12 text-sm rounded-lg bg-summary-item-color/5"
|
||||||
style="--summary-item-color-var: {{ .ColorHsl }}"
|
style="--summary-item-color-var: {{ .ColorHsl }}"
|
||||||
>
|
>
|
||||||
|
<img src="{{ .IconPath }}" alt="" class="pr-2" />
|
||||||
<dt class="flex-1 text-summary-item-color">{{ .Name }}</dt>
|
<dt class="flex-1 text-summary-item-color">{{ .Name }}</dt>
|
||||||
<dd class="flex flex-row">
|
<dd class="flex flex-row">
|
||||||
<strong>{{ .Score }}</strong>
|
<strong class="pr-2" >{{ .Score }}</strong>
|
||||||
/ 100
|
<span class="text-dark-gray-blue">/ 100</span>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue