aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/web_test.go
diff options
context:
space:
mode:
authorgrm <grm@eyesin.space>2026-09-19 00:04:08 +0300
committergrm <grm@eyesin.space>2026-09-19 00:04:08 +0300
commitc42c56108ebac6673ec5c86f9f0d51f31e8eb2bd (patch)
tree61e20aa8973a3ef628f62063da65245c62ac23af /internal/web/web_test.go
parent96336d8bacd2bdf81acf9a18e2fe57be9d4e9b4f (diff)
downloadblogspace-c42c56108ebac6673ec5c86f9f0d51f31e8eb2bd.tar.gz
blogspace-c42c56108ebac6673ec5c86f9f0d51f31e8eb2bd.tar.bz2
blogspace-c42c56108ebac6673ec5c86f9f0d51f31e8eb2bd.zip
Remove the menu fold
The header menu no longer folds into a ☰ button: the nav_fold and nav_fold_label options, Layout.Fold/BurgerAt, the burger markup and its checkbox, the fold rules in blog.css and the measuring script on the public page are gone, and the Design tab's preview only sizes its frame again. The public page runs no script of its own once more. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A
Diffstat (limited to 'internal/web/web_test.go')
-rw-r--r--internal/web/web_test.go76
1 files changed, 1 insertions, 75 deletions
diff --git a/internal/web/web_test.go b/internal/web/web_test.go
index e9e38fb..fc255b1 100644
--- a/internal/web/web_test.go
+++ b/internal/web/web_test.go
@@ -126,7 +126,7 @@ func TestThemeNormalizeAndCSS(t *testing.T) {
}
// The menu links' weight, case and underline are body classes blog.css draws; the theme CSS only colours them.
css = DefaultTheme().CSS()
- if !strings.Contains(css, ".site-nav a, .site-nav .nav-burger { color:#222222; }") || strings.Contains(css, "font-weight") || strings.Contains(css, "text-transform") {
+ if !strings.Contains(css, ".site-nav a { color:#222222; }") || strings.Contains(css, "font-weight") || strings.Contains(css, "text-transform") {
t.Errorf("nav css: %s", css)
}
if css := DefaultTheme().CSS(); strings.Contains(css, "@font-face") || strings.Contains(css, "h1, h2") {
@@ -170,80 +170,6 @@ func TestNavStyles(t *testing.T) {
}
}
-// The header menu folds into a button (theme nav_fold) carried by the title
-// or logo block just above it, else by the menu bar; the checkbox that is the
-// open/closed state comes first in the header so the CSS can reach both.
-func TestHeaderFold(t *testing.T) {
- hdr := func(kinds ...string) []store.Module {
- var mods []store.Module
- for _, k := range kinds {
- mods = append(mods, store.Module{Area: "header", Kind: k})
- }
- return mods
- }
- th := DefaultTheme()
- if l := buildLayout(th, hdr("title", "menu")); l.Fold {
- t.Errorf("fold is off by default: %+v", l)
- }
- th.NavFold = true
- for _, c := range []struct {
- kinds []string
- logo bool
- at int // -1: no fold
- }{
- {[]string{"title", "menu"}, false, 0}, {[]string{"menu", "title"}, false, 0}, {[]string{"logo", "menu"}, false, 1}, {[]string{"logo", "menu"}, true, 0},
- {[]string{"search", "menu"}, false, 1}, {[]string{"title", "search", "menu"}, false, 2}, {[]string{"title"}, false, -1}, {nil, false, -1},
- } {
- th.Logo = ""
- if c.logo {
- th.Logo = uuid.New().String()
- }
- l := buildLayout(th, hdr(c.kinds...))
- if l.Fold != (c.at >= 0) || (l.Fold && l.BurgerAt != c.at) {
- t.Errorf("%v (logo %v): fold %v at %d, want %d", c.kinds, c.logo, l.Fold, l.BurgerAt, c.at)
- }
- }
- th.HeaderOn = false
- if l := buildLayout(th, hdr("title", "menu")); l.Fold {
- t.Errorf("no header, nothing to fold: %+v", l)
- }
- th.HeaderOn = true
-
- tpl, err := newTemplates(false).get("en", "blog/page.html")
- if err != nil {
- t.Fatal(err)
- }
- render := func(th Theme, mods []store.Module) string {
- var b strings.Builder
- l := buildLayout(th, mods)
- v := view{Blog: &store.Blog{Title: "Gizmo"}, Media: "/media", Data: map[string]any{"theme": th, "layout": l, "menu": []store.MenuItem{{Label: "Home", URL: "/"}, {Label: "About", URL: "/about"}}}}
- if err := tpl.ExecuteTemplate(&b, "siteheader", v); err != nil {
- t.Fatal(err)
- }
- return b.String()
- }
- burger := `<label for="nav-toggle" class="nav-burger burger-icon"><span class="nb-icon" aria-hidden="true">&#9776;</span><span class="nb-text">Menu</span></label>`
- off := DefaultTheme()
- out := render(off, hdr("title", "menu"))
- if strings.Contains(out, "nav-toggle") || strings.Contains(out, "nav-burger") || strings.Contains(out, "nav-fold") || strings.Contains(out, "<script") {
- t.Errorf("fold off: %s", out)
- }
- out = render(th, hdr("title", "menu"))
- toggle, block, bar := strings.Index(out, `<input type="checkbox" id="nav-toggle" class="nav-toggle"`), strings.Index(out, `class="wrap header-text has-burger"`), strings.Index(out, `<div class="site-nav"><div class="wrap nav-inner">`)
- if !strings.HasPrefix(out, `<div class="site-header nav-fold nav-auto">`) || toggle < 0 || block < toggle || bar < block || strings.Count(out, burger) != 1 || strings.Index(out, burger) > bar || !strings.Contains(out, "<script") {
- t.Errorf("title host: %s", out)
- }
- out = render(th, hdr("menu", "title"))
- if !strings.Contains(out, `<div class="site-nav has-burger"><div class="wrap nav-inner">`+burger+`<a href="/">`) || strings.Contains(out, "header-text has-burger") {
- t.Errorf("menu first: %s", out)
- }
- th.HeaderAlign, th.NavFoldLabel, th.HeaderRule = "center", "both", "line"
- out = render(th, hdr("title", "menu"))
- if !strings.HasPrefix(out, `<div class="site-header nav-fold nav-auto header-center">`) || !strings.Contains(out, `class="wrap header-text ruled rule-line has-burger"`) || !strings.Contains(out, `</div><div class="header-rule"></div><label for="nav-toggle" class="nav-burger burger-both">`) {
- t.Errorf("centred, ruled, both: %s", out)
- }
-}
-
// The design page's preview is the header alone as a page of its own, with
// the blog's files linked through the dashboard's path for them.
func TestDesignPreview(t *testing.T) {