Skip to content

Commit f7e2fa6

Browse files
Fix website icons and refine the header mascot
Restore browser and app icons across the website
2 parents 8f453ac + 87bc0e6 commit f7e2fa6

17 files changed

Lines changed: 283 additions & 89 deletions

‎docs.templ‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ templ documentationPage(g guide, navigation, section []components.NavItem, theme
2121
<meta property="og:image" content={ "https://tendui.com" + brandURL("og-image.png") }/>
2222
<meta name="twitter:card" content="summary_large_image"/>
2323
<link rel="canonical" href={ templ.SafeURL("https://tendui.com" + g.Path) }/>
24-
<link rel="icon" href={ templ.SafeURL(brandURL("favicon.svg")) } type="image/svg+xml"/>
2524
<link rel="stylesheet" href={ templ.SafeURL(libraryStylesheetURL) }/>
26-
@headerStylesheet()
25+
@siteHead()
2726
<link rel="stylesheet" href={ templ.SafeURL(docsStylesheetURL) }/>
2827
</head>
2928
<body>
@@ -50,5 +49,5 @@ templ documentationSidebarFooter() {
5049
<img class="docs-mascot" src={ templ.SafeURL(brandURL("mascot-guide.svg")) } alt="" width="88" height="88" loading="lazy"/>
5150
<p>Go-native. HTML-first.<br/>Yours to compose.</p>
5251
<small>Built with TendUI · development</small>
53-
<p><a href="https://github.com/Tend-Stack/TendUI-web">Website source ↗</a></p>
52+
<p><a href="https://github.com/Tend-Stack/TendUI">TendUI source ↗</a></p>
5453
}

‎docs/brand-assets.json‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,36 @@
4242
"source": "03_web_and_social/github-social-preview-1280x640.png",
4343
"bytes": 649151,
4444
"processing": "Copied unchanged"
45+
},
46+
{
47+
"file": "static/brand/favicon.ico",
48+
"source": "02_mascot_icons/favicon.ico",
49+
"bytes": 53609,
50+
"processing": "Copied unchanged"
51+
},
52+
{
53+
"file": "static/brand/favicon-32.png",
54+
"source": "02_mascot_icons/favicon-32.png",
55+
"bytes": 2171,
56+
"processing": "Copied unchanged"
57+
},
58+
{
59+
"file": "static/brand/apple-touch-icon.png",
60+
"source": "02_mascot_icons/apple-touch-icon.png",
61+
"bytes": 14656,
62+
"processing": "Copied unchanged"
63+
},
64+
{
65+
"file": "static/brand/android-chrome-192x192.png",
66+
"source": "02_mascot_icons/android-chrome-192x192.png",
67+
"bytes": 15655,
68+
"processing": "Copied unchanged"
69+
},
70+
{
71+
"file": "static/brand/android-chrome-512x512.png",
72+
"source": "02_mascot_icons/android-chrome-512x512.png",
73+
"bytes": 43943,
74+
"processing": "Copied unchanged"
4575
}
4676
]
4777
}

‎docs_templ.go‎

Lines changed: 34 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎header.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ func demoOptions() site.Options {
7575
Header: func(active string) templ.Component { return siteHeader(active, nil) },
7676
DefaultTheme: defaultTheme,
7777
HostPage: hostPage,
78-
Head: headerStylesheet(),
78+
Head: siteHead(),
7979
}
8080
}

‎header_test.go‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package main
22

33
import (
4+
"bytes"
5+
"encoding/json"
6+
"image/png"
47
"net/http"
58
"net/http/httptest"
69
"regexp"
@@ -100,3 +103,52 @@ func TestDocsGuidesMoveIntoCompactMenu(t *testing.T) {
100103
t.Fatalf("compact menu should list only guides: %s", section)
101104
}
102105
}
106+
107+
// Navigation must not lose the tab icon on pages hosted by the example handler.
108+
func TestSiteIconsAcrossSurfaces(t *testing.T) {
109+
h := handler()
110+
for _, path := range []string{"/", "/docs", "/examples", "/catalog", "/catalog/button", "/playground", "/forms"} {
111+
w := httptest.NewRecorder()
112+
h.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
113+
body := w.Body.String()
114+
for _, want := range []string{brandURL("favicon.ico"), brandURL("favicon-32.png"), brandURL("favicon.svg"), brandURL("apple-touch-icon.png"), `href="/site.webmanifest"`} {
115+
if strings.Count(body, want) != 1 {
116+
t.Errorf("%s: expected one icon declaration for %s", path, want)
117+
}
118+
}
119+
}
120+
for _, path := range []string{"/favicon.ico", "/apple-touch-icon.png", brandURL("favicon.ico"), brandURL("favicon-32.png")} {
121+
w := httptest.NewRecorder()
122+
h.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
123+
if w.Code != 200 || w.Body.Len() == 0 {
124+
t.Errorf("%s: unavailable icon (%d)", path, w.Code)
125+
}
126+
}
127+
w := httptest.NewRecorder()
128+
h.ServeHTTP(w, httptest.NewRequest("GET", "/site.webmanifest", nil))
129+
var manifest struct {
130+
Name string
131+
Icons []struct{ Src, Sizes string }
132+
}
133+
if err := json.Unmarshal(w.Body.Bytes(), &manifest); err != nil {
134+
t.Fatal(err)
135+
}
136+
if manifest.Name != "Tend UI" || len(manifest.Icons) != 2 {
137+
t.Fatalf("invalid manifest: %+v", manifest)
138+
}
139+
if !strings.Contains(w.Header().Get("Content-Security-Policy"), "manifest-src 'self'") {
140+
t.Fatal("manifest blocked by CSP")
141+
}
142+
for i, icon := range manifest.Icons {
143+
r := httptest.NewRecorder()
144+
h.ServeHTTP(r, httptest.NewRequest("GET", icon.Src, nil))
145+
config, err := png.DecodeConfig(bytes.NewReader(r.Body.Bytes()))
146+
if err != nil {
147+
t.Fatal(err)
148+
}
149+
size := []int{192, 512}[i]
150+
if r.Code != 200 || config.Width != size || config.Height != size {
151+
t.Errorf("invalid app icon: %+v", config)
152+
}
153+
}
154+
}

‎landing.templ‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ templ landingPage(theme string) {
2525
<meta property="og:image:alt" content="TendUI gopher — Beautiful interfaces. No build pipeline."/>
2626
<meta name="twitter:card" content="summary_large_image"/>
2727
<link rel="canonical" href="https://tendui.com/"/>
28-
<link rel="icon" href={ templ.SafeURL(brandURL("favicon.svg")) } type="image/svg+xml"/>
2928
<link rel="stylesheet" href={ templ.SafeURL(libraryStylesheetURL) }/>
30-
@headerStylesheet()
29+
@siteHead()
3130
<link rel="stylesheet" href={ templ.SafeURL(siteStylesheetURL) }/>
3231
</head>
3332
<body>

0 commit comments

Comments
 (0)