Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs.templ
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ templ documentationPage(g guide, navigation, section []components.NavItem, theme
<meta property="og:image" content={ "https://tendui.com" + brandURL("og-image.png") }/>
<meta name="twitter:card" content="summary_large_image"/>
<link rel="canonical" href={ templ.SafeURL("https://tendui.com" + g.Path) }/>
<link rel="icon" href={ templ.SafeURL(brandURL("favicon.svg")) } type="image/svg+xml"/>
<link rel="stylesheet" href={ templ.SafeURL(libraryStylesheetURL) }/>
@headerStylesheet()
@siteHead()
<link rel="stylesheet" href={ templ.SafeURL(docsStylesheetURL) }/>
</head>
<body>
Expand All @@ -50,5 +49,5 @@ templ documentationSidebarFooter() {
<img class="docs-mascot" src={ templ.SafeURL(brandURL("mascot-guide.svg")) } alt="" width="88" height="88" loading="lazy"/>
<p>Go-native. HTML-first.<br/>Yours to compose.</p>
<small>Built with TendUI · development</small>
<p><a href="https://github.com/Tend-Stack/TendUI-web">Website source ↗</a></p>
<p><a href="https://github.com/Tend-Stack/TendUI">TendUI source ↗</a></p>
}
30 changes: 30 additions & 0 deletions docs/brand-assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,36 @@
"source": "03_web_and_social/github-social-preview-1280x640.png",
"bytes": 649151,
"processing": "Copied unchanged"
},
{
"file": "static/brand/favicon.ico",
"source": "02_mascot_icons/favicon.ico",
"bytes": 53609,
"processing": "Copied unchanged"
},
{
"file": "static/brand/favicon-32.png",
"source": "02_mascot_icons/favicon-32.png",
"bytes": 2171,
"processing": "Copied unchanged"
},
{
"file": "static/brand/apple-touch-icon.png",
"source": "02_mascot_icons/apple-touch-icon.png",
"bytes": 14656,
"processing": "Copied unchanged"
},
{
"file": "static/brand/android-chrome-192x192.png",
"source": "02_mascot_icons/android-chrome-192x192.png",
"bytes": 15655,
"processing": "Copied unchanged"
},
{
"file": "static/brand/android-chrome-512x512.png",
"source": "02_mascot_icons/android-chrome-512x512.png",
"bytes": 43943,
"processing": "Copied unchanged"
}
]
}
81 changes: 34 additions & 47 deletions docs_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion header.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ func demoOptions() site.Options {
Header: func(active string) templ.Component { return siteHeader(active, nil) },
DefaultTheme: defaultTheme,
HostPage: hostPage,
Head: headerStylesheet(),
Head: siteHead(),
}
}
52 changes: 52 additions & 0 deletions header_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package main

import (
"bytes"
"encoding/json"
"image/png"
"net/http"
"net/http/httptest"
"regexp"
Expand Down Expand Up @@ -100,3 +103,52 @@ func TestDocsGuidesMoveIntoCompactMenu(t *testing.T) {
t.Fatalf("compact menu should list only guides: %s", section)
}
}

// Navigation must not lose the tab icon on pages hosted by the example handler.
func TestSiteIconsAcrossSurfaces(t *testing.T) {
h := handler()
for _, path := range []string{"/", "/docs", "/examples", "/catalog", "/catalog/button", "/playground", "/forms"} {
w := httptest.NewRecorder()
h.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
body := w.Body.String()
for _, want := range []string{brandURL("favicon.ico"), brandURL("favicon-32.png"), brandURL("favicon.svg"), brandURL("apple-touch-icon.png"), `href="/site.webmanifest"`} {
if strings.Count(body, want) != 1 {
t.Errorf("%s: expected one icon declaration for %s", path, want)
}
}
}
for _, path := range []string{"/favicon.ico", "/apple-touch-icon.png", brandURL("favicon.ico"), brandURL("favicon-32.png")} {
w := httptest.NewRecorder()
h.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
if w.Code != 200 || w.Body.Len() == 0 {
t.Errorf("%s: unavailable icon (%d)", path, w.Code)
}
}
w := httptest.NewRecorder()
h.ServeHTTP(w, httptest.NewRequest("GET", "/site.webmanifest", nil))
var manifest struct {
Name string
Icons []struct{ Src, Sizes string }
}
if err := json.Unmarshal(w.Body.Bytes(), &manifest); err != nil {
t.Fatal(err)
}
if manifest.Name != "Tend UI" || len(manifest.Icons) != 2 {
t.Fatalf("invalid manifest: %+v", manifest)
}
if !strings.Contains(w.Header().Get("Content-Security-Policy"), "manifest-src 'self'") {
t.Fatal("manifest blocked by CSP")
}
for i, icon := range manifest.Icons {
r := httptest.NewRecorder()
h.ServeHTTP(r, httptest.NewRequest("GET", icon.Src, nil))
config, err := png.DecodeConfig(bytes.NewReader(r.Body.Bytes()))
if err != nil {
t.Fatal(err)
}
size := []int{192, 512}[i]
if r.Code != 200 || config.Width != size || config.Height != size {
t.Errorf("invalid app icon: %+v", config)
}
}
}
3 changes: 1 addition & 2 deletions landing.templ
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ templ landingPage(theme string) {
<meta property="og:image:alt" content="TendUI gopher — Beautiful interfaces. No build pipeline."/>
<meta name="twitter:card" content="summary_large_image"/>
<link rel="canonical" href="https://tendui.com/"/>
<link rel="icon" href={ templ.SafeURL(brandURL("favicon.svg")) } type="image/svg+xml"/>
<link rel="stylesheet" href={ templ.SafeURL(libraryStylesheetURL) }/>
@headerStylesheet()
@siteHead()
<link rel="stylesheet" href={ templ.SafeURL(siteStylesheetURL) }/>
</head>
<body>
Expand Down
Loading