diff --git a/docs.templ b/docs.templ index 3ab51a3..fc49eb2 100644 --- a/docs.templ +++ b/docs.templ @@ -21,9 +21,8 @@ templ documentationPage(g guide, navigation, section []components.NavItem, theme - - @headerStylesheet() + @siteHead() @@ -50,5 +49,5 @@ templ documentationSidebarFooter() {

Go-native. HTML-first.
Yours to compose.

Built with TendUI · development -

Website source ↗

+

TendUI source ↗

} diff --git a/docs/brand-assets.json b/docs/brand-assets.json index f7f5bc8..5a5b91a 100644 --- a/docs/brand-assets.json +++ b/docs/brand-assets.json @@ -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" } ] } diff --git a/docs_templ.go b/docs_templ.go index f23289c..cccb9b8 100644 --- a/docs_templ.go +++ b/docs_templ.go @@ -129,58 +129,45 @@ func documentationPage(g guide, navigation, section []components.NavItem, theme if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var10 string - templ_7745c5c3_Var10, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(libraryStylesheetURL)).ResolveURL(ctx) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `docs.templ`, Line: 25, Col: 77} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\">") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = headerStylesheet().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = siteHead().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var11 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -192,7 +179,7 @@ func documentationPage(g guide, navigation, section []components.NavItem, theme }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var13 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -204,33 +191,33 @@ func documentationPage(g guide, navigation, section []components.NavItem, theme }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "

TENDUI / DOCUMENTATION

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "

TENDUI / DOCUMENTATION

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var14 string - templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(g.Title) + var templ_7745c5c3_Var13 string + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(g.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `docs.templ`, Line: 36, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `docs.templ`, Line: 35, Col: 33} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var15 string - templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(g.Summary) + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(g.Summary) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `docs.templ`, Line: 37, Col: 51} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `docs.templ`, Line: 36, Col: 51} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -238,13 +225,13 @@ func documentationPage(g guide, navigation, section []components.NavItem, theme if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = components.Prose(components.ProseProps{Measure: components.MeasureWide}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = components.Prose(components.ProseProps{Measure: components.MeasureWide}).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -253,11 +240,11 @@ func documentationPage(g guide, navigation, section []components.NavItem, theme templ_7745c5c3_Err = components.AppShell(components.AppShellProps{ Brand: "TendUI", BrandHref: "/", Navigation: navigation, Header: siteHeader(g.Path, section), Footer: documentationSidebarFooter(), - }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + }).Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -282,20 +269,20 @@ func documentationSidebarFooter() templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\"\"

Go-native. HTML-first.
Yours to compose.

Built with TendUI · development

Website source ↗

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\" alt=\"\" width=\"88\" height=\"88\" loading=\"lazy\">

Go-native. HTML-first.
Yours to compose.

Built with TendUI · development

TendUI source ↗

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/header.go b/header.go index 0880a8f..da443eb 100644 --- a/header.go +++ b/header.go @@ -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(), } } diff --git a/header_test.go b/header_test.go index cc53a99..f10cd89 100644 --- a/header_test.go +++ b/header_test.go @@ -1,6 +1,9 @@ package main import ( + "bytes" + "encoding/json" + "image/png" "net/http" "net/http/httptest" "regexp" @@ -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) + } + } +} diff --git a/landing.templ b/landing.templ index e5b5f43..2a15bf6 100644 --- a/landing.templ +++ b/landing.templ @@ -25,9 +25,8 @@ templ landingPage(theme string) { - - @headerStylesheet() + @siteHead() diff --git a/landing_templ.go b/landing_templ.go index 4509435..5e9914a 100644 --- a/landing_templ.go +++ b/landing_templ.go @@ -63,54 +63,41 @@ func landingPage(theme string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var5 string - templ_7745c5c3_Var5, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(libraryStylesheetURL)).ResolveURL(ctx) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `landing.templ`, Line: 29, Col: 68} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\">") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = headerStylesheet().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = siteHead().Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "Skip to content") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\">Skip to content") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -118,20 +105,20 @@ func landingPage(theme string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "

PURE CSS · SEMANTIC HTML · GO

Beautiful interfaces.
No build pipeline.

Pure CSS. Semantic HTML. No Node.js, no npm, no bundled JavaScript. First-class Go and templ support.

Built for Go. Shipped in one binary.

Embed the stylesheet with Go, compose 37 typed templ components, and ship one executable. Use the same CSS with any HTML stack.

Start building ↗

Try the playground · Go 1.26+ · MIT

THE SHAPE OF SIMPLE01 / UI

PURE CSS · SEMANTIC HTML · GO

Beautiful interfaces.
No build pipeline.

Pure CSS. Semantic HTML. No Node.js, no npm, no bundled JavaScript. First-class Go and templ support.

Built for Go. Shipped in one binary.

Embed the stylesheet with Go, compose 37 typed templ components, and ship one executable. Use the same CSS with any HTML stack.

Start building ↗

Try the playground · Go 1.26+ · MIT

THE SHAPE OF SIMPLE01 / UI
\"TendUI’s
A LITTLE CHARACTER.

A lot less setup.

Made for curious Go developers.
✳Made with care

LESS SETUP. MORE MAKING.

A little structure.
A lot of possibility.

Room to build something that feels like you.

Simple by nature +

This disclosure is native HTML. Just a browser doing what it does best.

↳ One binary. All together.
HTML + CSS + GOAn interface study
01

Go all the way.

Styles embedded in your binary. No asset pipeline to maintain.

02

Let HTML be HTML.

Semantic elements, typed templ components, and native interactions.

03

Make it yours.

Themes, spacing, typography, and a little CSS motion. Your choices.

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\" alt=\"TendUI’s cloaked gopher holding a UI card\" width=\"144\" height=\"144\">
A LITTLE CHARACTER.

A lot less setup.

Made for curious Go developers.
✳Made with care

LESS SETUP. MORE MAKING.

A little structure.
A lot of possibility.

Room to build something that feels like you.

Simple by nature +

This disclosure is native HTML. Just a browser doing what it does best.

↳ One binary. All together.
HTML + CSS + GOAn interface study
01

Go all the way.

Styles embedded in your binary. No asset pipeline to maintain.

02

Let HTML be HTML.

Semantic elements, typed templ components, and native interactions.

03

Make it yours.

Themes, spacing, typography, and a little CSS motion. Your choices.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/main.go b/main.go index 52909e9..5f4463a 100644 --- a/main.go +++ b/main.go @@ -104,6 +104,8 @@ func handler() http.Handler { {docsStylesheetURL, "docs.css", "text/css; charset=utf-8"}, {headerStylesheetURL, "header.css", "text/css; charset=utf-8"}, {"/favicon.svg", "brand/favicon.svg", "image/svg+xml"}, + {"/favicon.ico", "brand/favicon.ico", "image/vnd.microsoft.icon"}, + {"/apple-touch-icon.png", "brand/apple-touch-icon.png", "image/png"}, {"/robots.txt", "robots.txt", "text/plain; charset=utf-8"}, } for _, asset := range brandAssets { @@ -122,6 +124,24 @@ func handler() http.Handler { http.ServeContent(w, r, asset.file, time.Time{}, bytes.NewReader(data)) }) } + mux.HandleFunc("/site.webmanifest", func(w http.ResponseWriter, r *http.Request) { + if !readMethod(w, r) { + return + } + w.Header().Set("Content-Type", "application/manifest+json") + w.Header().Set("Cache-Control", "public, max-age=0, must-revalidate") + if r.Method != http.MethodHead { + _ = json.NewEncoder(w).Encode(map[string]any{ + "name": "Tend UI", "short_name": "Tend UI", + "start_url": "/", "scope": "/", "display": "browser", + "background_color": "#0B0A18", "theme_color": "#0B0A18", + "icons": []map[string]string{ + {"src": brandURL("android-chrome-192x192.png"), "sizes": "192x192", "type": "image/png"}, + {"src": brandURL("android-chrome-512x512.png"), "sizes": "512x512", "type": "image/png"}, + }, + }) + } + }) landing := renderLanding() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { @@ -149,7 +169,7 @@ func handler() http.Handler { } }) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Security-Policy", "default-src 'none'; style-src 'self'; img-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'") + w.Header().Set("Content-Security-Policy", "default-src 'none'; style-src 'self'; img-src 'self'; manifest-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'") w.Header().Set("X-Content-Type-Options", "nosniff") w.Header().Set("Referrer-Policy", "strict-origin-when-cross-origin") w.Header().Set("Permissions-Policy", "camera=(), microphone=(), geolocation=()") diff --git a/site_header.templ b/site_header.templ index f049e2b..ae23475 100644 --- a/site_header.templ +++ b/site_header.templ @@ -19,7 +19,7 @@ templ siteHeader(active string, section []components.NavItem) { } templ siteBrand() { - + Tend UI Preview } @@ -28,6 +28,17 @@ templ siteSourceLink() { Source } -templ headerStylesheet() { +templ siteHead() { + @siteIcons() } + +// siteIcons is shared by the landing page, documentation and mounted demos. +// Hashed links avoid stale browser and proxy favicon caches after brand changes. +templ siteIcons() { + + + + + +} diff --git a/site_header_templ.go b/site_header_templ.go index 8dc4938..45e5341 100644 --- a/site_header_templ.go +++ b/site_header_templ.go @@ -78,7 +78,7 @@ func siteBrand() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\" alt=\"\" width=\"32\" height=\"32\"> Tend UI Preview") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\" alt=\"\" width=\"40\" height=\"40\"> Tend UI Preview") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -111,7 +111,7 @@ func siteSourceLink() templ.Component { }) } -func headerStylesheet() templ.Component { +func siteHead() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -128,6 +128,10 @@ func headerStylesheet() templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = siteIcons().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + var _ = templruntime.GeneratedTemplate diff --git a/static/brand/android-chrome-192x192.png b/static/brand/android-chrome-192x192.png new file mode 100644 index 0000000..a6801b1 Binary files /dev/null and b/static/brand/android-chrome-192x192.png differ diff --git a/static/brand/android-chrome-512x512.png b/static/brand/android-chrome-512x512.png new file mode 100644 index 0000000..5b5b441 Binary files /dev/null and b/static/brand/android-chrome-512x512.png differ diff --git a/static/brand/apple-touch-icon.png b/static/brand/apple-touch-icon.png new file mode 100644 index 0000000..f4bdcd5 Binary files /dev/null and b/static/brand/apple-touch-icon.png differ diff --git a/static/brand/favicon-32.png b/static/brand/favicon-32.png new file mode 100644 index 0000000..f617791 Binary files /dev/null and b/static/brand/favicon-32.png differ diff --git a/static/brand/favicon.ico b/static/brand/favicon.ico new file mode 100644 index 0000000..7ca5905 Binary files /dev/null and b/static/brand/favicon.ico differ diff --git a/static/header.css b/static/header.css index 1d1cb71..b963546 100644 --- a/static/header.css +++ b/static/header.css @@ -3,3 +3,5 @@ .site-wordmark > span { color: var(--tendui-primary); } .site-version { padding: .1875rem .4375rem; border-radius: 999px; background: var(--tendui-subtle); color: var(--tendui-muted); font-family: var(--tendui-mono); font-size: .6875rem; font-weight: 500; letter-spacing: 0; } @media (max-width: 56rem) { .site-version { display: none; } } + +.site-brand > img { inline-size: 2.5rem; block-size: 2.5rem; object-fit: contain; } diff --git a/tests/browser/site.spec.js b/tests/browser/site.spec.js index b210c2a..de1433f 100644 --- a/tests/browser/site.spec.js +++ b/tests/browser/site.spec.js @@ -171,3 +171,27 @@ test('one header on every surface', async ({ page }, testInfo) => { } } }); + + +test('brand icons load on every surface and the taller mascot fits the header', async ({ page, request }) => { + for (const route of ['/', '/docs', '/catalog', '/playground']) { + await page.goto(route); + const icons = page.locator('link[rel="icon"]'); + await expect(icons).toHaveCount(3); + for (const href of await icons.evaluateAll(nodes => nodes.map(n => n.href))) { + const response = await request.get(href); + expect(response.status()).toBe(200); + expect(response.headers()['content-type']).toMatch(/^image\//); + } + const logo = page.locator('.site-brand > img'); + expect(await logo.evaluate(e => e.complete && e.naturalWidth > 0)).toBe(true); + const box = await logo.boundingBox(); + const header = await page.locator('.site-header').boundingBox(); + const rootSize = await page.locator('html').evaluate(e => parseFloat(getComputedStyle(e).fontSize)); + expect(box.height).toBeCloseTo(rootSize * 2.5, 0); + expect(box.y).toBeGreaterThanOrEqual(header.y); + expect(box.y + box.height).toBeLessThanOrEqual(header.y + header.height); + await expect(page.locator('link[rel="apple-touch-icon"]')).toHaveCount(1); + await expect(page.locator('link[rel="manifest"]')).toHaveCount(1); + } +});