BlueGit

timfa bluegit

UI: tooltips tonen de volledige tekst, zonder afkappen

Line-clamp, ellipsis en het title-attribuut zijn weg: je kunt een
tooltip niet hoveren, dus de tekst moet gewoon volledig wrappen.
Max-breedte is min(32rem, calc(100vw - 2rem)), zonder scrollbar.
Float-tips en info-tooltips blijven in het viewport (omklappen of
verschuiven).

timfa Grok Bot · pushed by timfa

Authored 2026-11-17 · 10 hours ago

Hash
36f1e7fc61272621b796d12b7b865328d086ca3f
Parent
3d18c8d8
Pipeline
Passed
6 files changed +132 −46
internal/runnercfg/tip.go +1 −1
@@ -16,5 +16,5 @@ func Tip(lang i18n.Lang, key string) template.HTML {
16 16 id := "tip-" + strings.NewReplacer(".", "-", "_", "-").Replace(key)
17 17 text := template.HTMLEscapeString(i18n.T(lang, key))
18 18 info := template.HTMLEscapeString(i18n.T(lang, "tip.info"))
19 return template.HTML(`<span class="tip"><span class="tip-i" role="button" tabindex="0" aria-expanded="false" aria-label="` + info + `" aria-describedby="` + id + `">i</span><span class="tip-b" role="tooltip" id="` + id + `" title="` + text + `">` + text + `</span></span>`)
19 return template.HTML(`<span class="tip"><span class="tip-i" role="button" tabindex="0" aria-expanded="false" aria-label="` + info + `" aria-describedby="` + id + `">i</span><span class="tip-b" role="tooltip" id="` + id + `">` + text + `</span></span>`)
20 20 }
@@ -16,5 +16,5 @@ func Tip(lang i18n.Lang, key string) template.HTML {
16 id := "tip-" + strings.NewReplacer(".", "-", "_", "-").Replace(key)
16 id := "tip-" + strings.NewReplacer(".", "-", "_", "-").Replace(key)
17 text := template.HTMLEscapeString(i18n.T(lang, key))
17 text := template.HTMLEscapeString(i18n.T(lang, key))
18 info := template.HTMLEscapeString(i18n.T(lang, "tip.info"))
18 info := template.HTMLEscapeString(i18n.T(lang, "tip.info"))
19 return template.HTML(`<span class="tip"><span class="tip-i" role="button" tabindex="0" aria-expanded="false" aria-label="` + info + `" aria-describedby="` + id + `">i</span><span class="tip-b" role="tooltip" id="` + id + `" title="` + text + `">` + text + `</span></span>`)
19 return template.HTML(`<span class="tip"><span class="tip-i" role="button" tabindex="0" aria-expanded="false" aria-label="` + info + `" aria-describedby="` + id + `">i</span><span class="tip-b" role="tooltip" id="` + id + `">` + text + `</span></span>`)
20}
20}
internal/runnercfg/tip_test.go +2 −3
@@ -36,8 +36,7 @@ func TestEverySettingHasTip(t *testing.T) {
36 36 if !strings.Contains(html, `role="tooltip"`) {
37 37 t.Fatal("tip zonder role")
38 38 }
39 text := i18n.T(i18n.NL, "rui.tip.name")
40 if !strings.Contains(html, `title="`+text+`"`) {
41 t.Fatalf("tip-b mist title met de volledige tekst: %s", html)
39 if strings.Contains(html, `title="`) {
40 t.Fatalf("tip-b heeft geen title nodig (niet hoverbaar): %s", html)
42 41 }
43 42 }
@@ -36,8 +36,7 @@ func TestEverySettingHasTip(t *testing.T) {
36 if !strings.Contains(html, `role="tooltip"`) {
36 if !strings.Contains(html, `role="tooltip"`) {
37 t.Fatal("tip zonder role")
37 t.Fatal("tip zonder role")
38 }
38 }
39 text := i18n.T(i18n.NL, "rui.tip.name")
39 if strings.Contains(html, `title="`) {
40 if !strings.Contains(html, `title="`+text+`"`) {
40 t.Fatalf("tip-b heeft geen title nodig (niet hoverbaar): %s", html)
41 t.Fatalf("tip-b mist title met de volledige tekst: %s", html)
42 }
41 }
43}
42}
internal/server/static/float.js +0 −1
@@ -159,7 +159,6 @@
159 159 }
160 160 tipAnchor = el;
161 161 tip.textContent = text;
162 tip.setAttribute("title", text);
163 162 tip.classList.toggle("heat", el.classList.contains("sq"));
164 163 openLayer(tip);
165 164 track(tip, el, "above-center");
@@ -159,7 +159,6 @@
159 }
159 }
160 tipAnchor = el;
160 tipAnchor = el;
161 tip.textContent = text;
161 tip.textContent = text;
162 tip.setAttribute("title", text);
163 tip.classList.toggle("heat", el.classList.contains("sq"));
162 tip.classList.toggle("heat", el.classList.contains("sq"));
164 openLayer(tip);
163 openLayer(tip);
165 track(tip, el, "above-center");
164 track(tip, el, "above-center");
internal/server/static/style.css +6 −8
@@ -782,19 +782,16 @@ button.stage-dot {
782 782 box-sizing: border-box; border: 0; padding: 0.28rem 0.5rem; border-radius: 6px;
783 783 background: #24292f; color: white; font-size: 0.75rem; font-weight: 600;
784 784 line-height: 1.35; white-space: normal; overflow-wrap: anywhere;
785 overflow: hidden; text-overflow: ellipsis; pointer-events: none;
786 display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
787 max-width: min(26rem, calc(100vw - 2rem));
788 max-height: calc(2 * 1.35em + 0.56rem);
785 overflow: hidden; pointer-events: none;
786 max-width: min(32rem, calc(100vw - 2rem));
789 787 }
790 788 .float-tip:popover-open {
791 789 position: fixed;
792 790 inset: auto;
793 791 margin: 0;
794 792 width: max-content;
795 max-width: min(26rem, calc(100vw - 2rem));
793 max-width: min(32rem, calc(100vw - 2rem));
796 794 height: auto;
797 display: -webkit-box;
798 795 overflow: hidden;
799 796 }
800 797 .float-tip.heat { background: #142033; font-size: 0.78rem; font-weight: 400; }
@@ -1526,9 +1523,10 @@ html.bgmodal-open { overflow: hidden; }
1526 1523 .tip { display: inline-flex; vertical-align: middle; margin-left: 4px; }
1527 1524 .tip-i { all: unset; display: inline-block; box-sizing: border-box; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--blue); color: var(--blue-deep); background: var(--blue-soft); font: italic 700 11px/16px Georgia, serif; text-align: center; cursor: help; flex: none; }
1528 1525 .tip-i:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
1529 .tip-b { display: none; box-sizing: border-box; position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; width: max-content; max-width: min(26rem, calc(100vw - 2rem)); max-height: calc(2 * 1.45em + 2 * var(--sp-2)); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); background: var(--ink); color: #fff; font-size: var(--fs-sm); font-weight: 400; font-style: normal; line-height: 1.45; box-shadow: var(--shadow); white-space: normal; text-align: left; overflow-wrap: anywhere; overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
1526 .tip-b { display: none; box-sizing: border-box; position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; width: max-content; max-width: min(32rem, calc(100vw - 2rem)); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); background: var(--ink); color: #fff; font-size: var(--fs-sm); font-weight: 400; font-style: normal; line-height: 1.45; box-shadow: var(--shadow); white-space: normal; text-align: left; overflow-wrap: anywhere; overflow: hidden; }
1530 1527 .tip-b::before { content: ""; position: absolute; top: -5px; left: 14px; border: 5px solid transparent; border-top: 0; border-bottom-color: var(--ink); }
1531 .tip:hover .tip-b, .tip-i:focus + .tip-b, .tip.open .tip-b, .tiphost:focus-within .tip-b { display: -webkit-box; overflow: hidden; }
1528 .tip-b.above::before { top: auto; bottom: -5px; border-bottom: 0; border-top-color: var(--ink); }
1529 .tip:hover .tip-b, .tip-i:focus + .tip-b, .tip.open .tip-b, .tiphost:focus-within .tip-b { display: block; }
1532 1530 .tiphost:has(.tip.open), .tiphost:focus-within, .tiphost:hover { z-index: 31; }
1533 1531
1534 1532 /* Taalkiezer (langpick.js) */
@@ -782,19 +782,16 @@ button.stage-dot {
782 box-sizing: border-box; border: 0; padding: 0.28rem 0.5rem; border-radius: 6px;
782 box-sizing: border-box; border: 0; padding: 0.28rem 0.5rem; border-radius: 6px;
783 background: #24292f; color: white; font-size: 0.75rem; font-weight: 600;
783 background: #24292f; color: white; font-size: 0.75rem; font-weight: 600;
784 line-height: 1.35; white-space: normal; overflow-wrap: anywhere;
784 line-height: 1.35; white-space: normal; overflow-wrap: anywhere;
785 overflow: hidden; text-overflow: ellipsis; pointer-events: none;
785 overflow: hidden; pointer-events: none;
786 display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
786 max-width: min(32rem, calc(100vw - 2rem));
787 max-width: min(26rem, calc(100vw - 2rem));
788 max-height: calc(2 * 1.35em + 0.56rem);
789}
787}
790.float-tip:popover-open {
788.float-tip:popover-open {
791 position: fixed;
789 position: fixed;
792 inset: auto;
790 inset: auto;
793 margin: 0;
791 margin: 0;
794 width: max-content;
792 width: max-content;
795 max-width: min(26rem, calc(100vw - 2rem));
793 max-width: min(32rem, calc(100vw - 2rem));
796 height: auto;
794 height: auto;
797 display: -webkit-box;
798 overflow: hidden;
795 overflow: hidden;
799}
796}
800.float-tip.heat { background: #142033; font-size: 0.78rem; font-weight: 400; }
797.float-tip.heat { background: #142033; font-size: 0.78rem; font-weight: 400; }
@@ -1526,9 +1523,10 @@ html.bgmodal-open { overflow: hidden; }
1526.tip { display: inline-flex; vertical-align: middle; margin-left: 4px; }
1523.tip { display: inline-flex; vertical-align: middle; margin-left: 4px; }
1527.tip-i { all: unset; display: inline-block; box-sizing: border-box; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--blue); color: var(--blue-deep); background: var(--blue-soft); font: italic 700 11px/16px Georgia, serif; text-align: center; cursor: help; flex: none; }
1524.tip-i { all: unset; display: inline-block; box-sizing: border-box; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--blue); color: var(--blue-deep); background: var(--blue-soft); font: italic 700 11px/16px Georgia, serif; text-align: center; cursor: help; flex: none; }
1528.tip-i:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
1525.tip-i:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
1529.tip-b { display: none; box-sizing: border-box; position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; width: max-content; max-width: min(26rem, calc(100vw - 2rem)); max-height: calc(2 * 1.45em + 2 * var(--sp-2)); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); background: var(--ink); color: #fff; font-size: var(--fs-sm); font-weight: 400; font-style: normal; line-height: 1.45; box-shadow: var(--shadow); white-space: normal; text-align: left; overflow-wrap: anywhere; overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
1526.tip-b { display: none; box-sizing: border-box; position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; width: max-content; max-width: min(32rem, calc(100vw - 2rem)); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); background: var(--ink); color: #fff; font-size: var(--fs-sm); font-weight: 400; font-style: normal; line-height: 1.45; box-shadow: var(--shadow); white-space: normal; text-align: left; overflow-wrap: anywhere; overflow: hidden; }
1530.tip-b::before { content: ""; position: absolute; top: -5px; left: 14px; border: 5px solid transparent; border-top: 0; border-bottom-color: var(--ink); }
1527.tip-b::before { content: ""; position: absolute; top: -5px; left: 14px; border: 5px solid transparent; border-top: 0; border-bottom-color: var(--ink); }
1531.tip:hover .tip-b, .tip-i:focus + .tip-b, .tip.open .tip-b, .tiphost:focus-within .tip-b { display: -webkit-box; overflow: hidden; }
1528.tip-b.above::before { top: auto; bottom: -5px; border-bottom: 0; border-top-color: var(--ink); }
1529.tip:hover .tip-b, .tip-i:focus + .tip-b, .tip.open .tip-b, .tiphost:focus-within .tip-b { display: block; }
1532.tiphost:has(.tip.open), .tiphost:focus-within, .tiphost:hover { z-index: 31; }
1530.tiphost:has(.tip.open), .tiphost:focus-within, .tiphost:hover { z-index: 31; }
1533
1531
1534/* Taalkiezer (langpick.js) */
1532/* Taalkiezer (langpick.js) */
internal/server/static/tip.js +81 −3
@@ -1,7 +1,10 @@
1 1 // Info-tooltips (i): tonen bij hover, toetsenbordfocus en als het veld in
2 2 // hetzelfde label focus heeft (CSS). Op touch opent een tik de uitleg;
3 // tik ernaast of Escape sluit hem.
3 // tik ernaast of Escape sluit hem. Zichtbare .tip-b blijft in het
4 // viewport (fixed, geklemd of omgeklapt).
4 5 (function () {
6 var GAP = 8;
7
5 8 function closeAll(except) {
6 9 document.querySelectorAll(".tip.open").forEach(function (t) {
7 10 if (t !== except) {
@@ -11,19 +14,94 @@
11 14 }
12 15 });
13 16 }
17
18 function placeBody(body, anchor) {
19 body.classList.remove("above");
20 body.style.position = "fixed";
21 body.style.left = "0px";
22 body.style.top = "0px";
23 body.style.right = "auto";
24 var rect = anchor.getBoundingClientRect();
25 var w = body.offsetWidth;
26 var h = body.offsetHeight;
27 var vw = document.documentElement.clientWidth;
28 var vh = document.documentElement.clientHeight;
29 var left = rect.left;
30 var top = rect.bottom + GAP;
31 var above = false;
32 if (top + h > vh - GAP && rect.top - GAP - h >= GAP) {
33 top = rect.top - GAP - h;
34 above = true;
35 }
36 if (left + w > vw - GAP) {
37 left = vw - GAP - w;
38 }
39 if (left < GAP) {
40 left = GAP;
41 }
42 if (top + h > vh - GAP) {
43 top = Math.max(GAP, vh - GAP - h);
44 }
45 if (top < GAP) {
46 top = GAP;
47 }
48 body.classList.toggle("above", above);
49 body.style.left = Math.round(left) + "px";
50 body.style.top = Math.round(top) + "px";
51 }
52
53 function clearBody(body) {
54 body.classList.remove("above");
55 body.style.position = "";
56 body.style.left = "";
57 body.style.top = "";
58 body.style.right = "";
59 }
60
61 function repositionTips() {
62 document.querySelectorAll(".tip-b").forEach(function (body) {
63 if (getComputedStyle(body).display === "none") {
64 clearBody(body);
65 return;
66 }
67 var tip = body.closest(".tip");
68 var anchor = (tip && tip.querySelector(".tip-i")) || body.parentElement;
69 if (anchor) {
70 placeBody(body, anchor);
71 }
72 });
73 }
74
75 function schedulePlace() {
76 requestAnimationFrame(repositionTips);
77 }
78
14 79 document.addEventListener("click", function (e) {
15 80 var btn = e.target.closest && e.target.closest(".tip-i");
16 if (!btn) { closeAll(null); return; }
81 if (!btn) { closeAll(null); schedulePlace(); return; }
17 82 e.preventDefault();
18 83 var tip = btn.closest(".tip");
19 84 var open = !tip.classList.contains("open");
20 85 closeAll(tip);
21 86 tip.classList.toggle("open", open);
22 87 btn.setAttribute("aria-expanded", open ? "true" : "false");
88 schedulePlace();
23 89 });
24 90 document.addEventListener("keydown", function (e) {
25 if (e.key === "Escape") { closeAll(null); return; }
91 if (e.key === "Escape") { closeAll(null); schedulePlace(); return; }
26 92 var btn = e.target.closest && e.target.closest(".tip-i");
27 93 if (btn && (e.key === "Enter" || e.key === " ")) { e.preventDefault(); btn.click(); }
28 94 });
95 document.addEventListener("pointerover", function (e) {
96 if (e.target.closest && e.target.closest(".tip, .tiphost")) {
97 schedulePlace();
98 }
99 });
100 document.addEventListener("focusin", function (e) {
101 if (e.target.closest && e.target.closest(".tip, .tiphost")) {
102 schedulePlace();
103 }
104 });
105 window.addEventListener("scroll", repositionTips, true);
106 window.addEventListener("resize", repositionTips);
29 107 })();
@@ -1,7 +1,10 @@
1// Info-tooltips (i): tonen bij hover, toetsenbordfocus en als het veld in
1// Info-tooltips (i): tonen bij hover, toetsenbordfocus en als het veld in
2// hetzelfde label focus heeft (CSS). Op touch opent een tik de uitleg;
2// hetzelfde label focus heeft (CSS). Op touch opent een tik de uitleg;
3// tik ernaast of Escape sluit hem.
3// tik ernaast of Escape sluit hem. Zichtbare .tip-b blijft in het
4// viewport (fixed, geklemd of omgeklapt).
4(function () {
5(function () {
6 var GAP = 8;
7
5 function closeAll(except) {
8 function closeAll(except) {
6 document.querySelectorAll(".tip.open").forEach(function (t) {
9 document.querySelectorAll(".tip.open").forEach(function (t) {
7 if (t !== except) {
10 if (t !== except) {
@@ -11,19 +14,94 @@
11 }
14 }
12 });
15 });
13 }
16 }
17
18 function placeBody(body, anchor) {
19 body.classList.remove("above");
20 body.style.position = "fixed";
21 body.style.left = "0px";
22 body.style.top = "0px";
23 body.style.right = "auto";
24 var rect = anchor.getBoundingClientRect();
25 var w = body.offsetWidth;
26 var h = body.offsetHeight;
27 var vw = document.documentElement.clientWidth;
28 var vh = document.documentElement.clientHeight;
29 var left = rect.left;
30 var top = rect.bottom + GAP;
31 var above = false;
32 if (top + h > vh - GAP && rect.top - GAP - h >= GAP) {
33 top = rect.top - GAP - h;
34 above = true;
35 }
36 if (left + w > vw - GAP) {
37 left = vw - GAP - w;
38 }
39 if (left < GAP) {
40 left = GAP;
41 }
42 if (top + h > vh - GAP) {
43 top = Math.max(GAP, vh - GAP - h);
44 }
45 if (top < GAP) {
46 top = GAP;
47 }
48 body.classList.toggle("above", above);
49 body.style.left = Math.round(left) + "px";
50 body.style.top = Math.round(top) + "px";
51 }
52
53 function clearBody(body) {
54 body.classList.remove("above");
55 body.style.position = "";
56 body.style.left = "";
57 body.style.top = "";
58 body.style.right = "";
59 }
60
61 function repositionTips() {
62 document.querySelectorAll(".tip-b").forEach(function (body) {
63 if (getComputedStyle(body).display === "none") {
64 clearBody(body);
65 return;
66 }
67 var tip = body.closest(".tip");
68 var anchor = (tip && tip.querySelector(".tip-i")) || body.parentElement;
69 if (anchor) {
70 placeBody(body, anchor);
71 }
72 });
73 }
74
75 function schedulePlace() {
76 requestAnimationFrame(repositionTips);
77 }
78
14 document.addEventListener("click", function (e) {
79 document.addEventListener("click", function (e) {
15 var btn = e.target.closest && e.target.closest(".tip-i");
80 var btn = e.target.closest && e.target.closest(".tip-i");
16 if (!btn) { closeAll(null); return; }
81 if (!btn) { closeAll(null); schedulePlace(); return; }
17 e.preventDefault();
82 e.preventDefault();
18 var tip = btn.closest(".tip");
83 var tip = btn.closest(".tip");
19 var open = !tip.classList.contains("open");
84 var open = !tip.classList.contains("open");
20 closeAll(tip);
85 closeAll(tip);
21 tip.classList.toggle("open", open);
86 tip.classList.toggle("open", open);
22 btn.setAttribute("aria-expanded", open ? "true" : "false");
87 btn.setAttribute("aria-expanded", open ? "true" : "false");
88 schedulePlace();
23 });
89 });
24 document.addEventListener("keydown", function (e) {
90 document.addEventListener("keydown", function (e) {
25 if (e.key === "Escape") { closeAll(null); return; }
91 if (e.key === "Escape") { closeAll(null); schedulePlace(); return; }
26 var btn = e.target.closest && e.target.closest(".tip-i");
92 var btn = e.target.closest && e.target.closest(".tip-i");
27 if (btn && (e.key === "Enter" || e.key === " ")) { e.preventDefault(); btn.click(); }
93 if (btn && (e.key === "Enter" || e.key === " ")) { e.preventDefault(); btn.click(); }
28 });
94 });
95 document.addEventListener("pointerover", function (e) {
96 if (e.target.closest && e.target.closest(".tip, .tiphost")) {
97 schedulePlace();
98 }
99 });
100 document.addEventListener("focusin", function (e) {
101 if (e.target.closest && e.target.closest(".tip, .tiphost")) {
102 schedulePlace();
103 }
104 });
105 window.addEventListener("scroll", repositionTips, true);
106 window.addEventListener("resize", repositionTips);
29})();
107})();
internal/server/tooltip_css_test.go +42 −30
@@ -25,12 +25,13 @@ func ruleBlock(css, sel string) string {
25 25 return rest[start+1 : end]
26 26 }
27 27
28 func TestTooltipCSSWrapsTwoLinesWithoutScrollbar(t *testing.T) {
28 func TestTooltipCSSShowsFullTextWithoutScrollbar(t *testing.T) {
29 29 css, err := os.ReadFile("static/style.css")
30 30 if err != nil {
31 31 t.Fatal(err)
32 32 }
33 33 src := string(css)
34 wantMax := "max-width: min(32rem, calc(100vw - 2rem))"
34 35 for _, sel := range []string{".float-tip", ".float-tip:popover-open", ".tip-b"} {
35 36 body := ruleBlock(src, sel)
36 37 if body == "" {
@@ -39,55 +40,66 @@ func TestTooltipCSSWrapsTwoLinesWithoutScrollbar(t *testing.T) {
39 40 if strings.Contains(body, "white-space: nowrap") {
40 41 t.Errorf("%s heeft white-space: nowrap; tekst moet wrappen", sel)
41 42 }
42 if strings.Contains(body, "overflow: auto") || strings.Contains(body, "overflow-x: auto") || strings.Contains(body, "overflow-x: scroll") || strings.Contains(body, "overflow: scroll") {
43 if strings.Contains(body, "overflow: auto") || strings.Contains(body, "overflow-x: auto") || strings.Contains(body, "overflow-x: scroll") || strings.Contains(body, "overflow: scroll") || strings.Contains(body, "overflow-y: auto") || strings.Contains(body, "overflow-y: scroll") {
43 44 t.Errorf("%s mag geen scrollbar krijgen: %s", sel, body)
44 45 }
45 }
46 ft := ruleBlock(src, ".float-tip")
47 for _, want := range []string{
48 "white-space: normal",
49 "overflow: hidden",
50 "-webkit-line-clamp: 2",
51 "line-clamp: 2",
52 "overflow-wrap: anywhere",
53 "box-sizing: border-box",
54 "max-width: min(26rem, calc(100vw - 2rem))",
55 } {
56 if !strings.Contains(ft, want) {
57 t.Errorf(".float-tip mist %q", want)
46 for _, bad := range []string{"line-clamp:", "text-overflow: ellipsis", "-webkit-box", "max-height:"} {
47 if strings.Contains(body, bad) {
48 t.Errorf("%s kapt tekst af (%q): %s", sel, bad, body)
49 }
58 50 }
59 }
60 open := ruleBlock(src, ".float-tip:popover-open")
61 if !strings.Contains(open, "overflow: hidden") || !strings.Contains(open, "display: -webkit-box") {
62 t.Errorf(".float-tip:popover-open moet wrappen zonder scrollbar: %s", open)
63 }
64 tb := ruleBlock(src, ".tip-b")
65 for _, want := range []string{"white-space: normal", "overflow: hidden", "-webkit-line-clamp: 2", "line-clamp: 2", "max-width: min(26rem, calc(100vw - 2rem))"} {
66 if !strings.Contains(tb, want) {
67 t.Errorf(".tip-b mist %q", want)
51 if !strings.Contains(body, "white-space: normal") && sel != ".float-tip:popover-open" {
52 t.Errorf("%s mist white-space: normal", sel)
53 }
54 if !strings.Contains(body, wantMax) {
55 t.Errorf("%s mist %s", sel, wantMax)
56 }
57 if !strings.Contains(body, "overflow: hidden") {
58 t.Errorf("%s mist overflow: hidden (voorkomt UA-scrollbars, zonder hoogte blijft alles zichtbaar)", sel)
68 59 }
69 60 }
70 61 shown := ruleBlock(src, ".tip:hover .tip-b, .tip-i:focus + .tip-b, .tip.open .tip-b, .tiphost:focus-within .tip-b")
71 if !strings.Contains(shown, "display: -webkit-box") {
72 t.Errorf("zichtbare .tip-b moet -webkit-box zijn voor line-clamp: %s", shown)
62 if !strings.Contains(shown, "display: block") || strings.Contains(shown, "-webkit-box") {
63 t.Errorf("zichtbare .tip-b moet display:block zijn, geen line-clamp-box: %s", shown)
73 64 }
74 // Geen latere .float-tip-regel die nowrap terugzet.
75 65 re := regexp.MustCompile(`(?s)\.float-tip[^{]*\{[^}]*white-space:\s*nowrap`)
76 66 if re.MatchString(src) {
77 67 t.Fatal("ergens zet een .float-tip-regel white-space weer op nowrap")
78 68 }
69 clamp := regexp.MustCompile(`(?s)\.(float-tip|tip-b)[^{]*\{[^}]*(line-clamp|text-overflow:\s*ellipsis)`)
70 if clamp.MatchString(src) {
71 t.Fatal("float-tip of tip-b mag tekst niet afkappen met line-clamp of ellipsis")
72 }
79 73 }
80 74
81 func TestFloatTipSetsFullTitle(t *testing.T) {
75 func TestFloatTipHasNoTitleAndKeepsViewport(t *testing.T) {
82 76 js, err := os.ReadFile("static/float.js")
83 77 if err != nil {
84 78 t.Fatal(err)
85 79 }
86 80 src := string(js)
87 if !strings.Contains(src, `tip.setAttribute("title", text)`) {
88 t.Fatal("float-tip moet de volledige tekst in title zetten")
81 if strings.Contains(src, `tip.setAttribute("title"`) {
82 t.Fatal("float-tip heeft geen title: je kunt er niet over hoveren")
89 83 }
90 84 if !strings.Contains(src, `tip.textContent = text`) {
91 85 t.Fatal("float-tip toont de tekst")
92 86 }
87 for _, want := range []string{`vw - GAP`, `vh - GAP`, `above-center`} {
88 if !strings.Contains(src, want) {
89 t.Errorf("place() moet in het viewport blijven (%q ontbreekt)", want)
90 }
91 }
92 }
93
94 func TestInfoTipStaysInViewport(t *testing.T) {
95 js, err := os.ReadFile("static/tip.js")
96 if err != nil {
97 t.Fatal(err)
98 }
99 src := string(js)
100 for _, want := range []string{"position = \"fixed\"", "placeBody", "vw - GAP", "vh - GAP", "classList.toggle(\"above\""} {
101 if !strings.Contains(src, want) {
102 t.Errorf("tip.js moet .tip-b in het viewport plaatsen (%q ontbreekt)", want)
103 }
104 }
93 105 }
@@ -25,12 +25,13 @@ func ruleBlock(css, sel string) string {
25 return rest[start+1 : end]
25 return rest[start+1 : end]
26}
26}
27
27
28func TestTooltipCSSWrapsTwoLinesWithoutScrollbar(t *testing.T) {
28func TestTooltipCSSShowsFullTextWithoutScrollbar(t *testing.T) {
29 css, err := os.ReadFile("static/style.css")
29 css, err := os.ReadFile("static/style.css")
30 if err != nil {
30 if err != nil {
31 t.Fatal(err)
31 t.Fatal(err)
32 }
32 }
33 src := string(css)
33 src := string(css)
34 wantMax := "max-width: min(32rem, calc(100vw - 2rem))"
34 for _, sel := range []string{".float-tip", ".float-tip:popover-open", ".tip-b"} {
35 for _, sel := range []string{".float-tip", ".float-tip:popover-open", ".tip-b"} {
35 body := ruleBlock(src, sel)
36 body := ruleBlock(src, sel)
36 if body == "" {
37 if body == "" {
@@ -39,55 +40,66 @@ func TestTooltipCSSWrapsTwoLinesWithoutScrollbar(t *testing.T) {
39 if strings.Contains(body, "white-space: nowrap") {
40 if strings.Contains(body, "white-space: nowrap") {
40 t.Errorf("%s heeft white-space: nowrap; tekst moet wrappen", sel)
41 t.Errorf("%s heeft white-space: nowrap; tekst moet wrappen", sel)
41 }
42 }
42 if strings.Contains(body, "overflow: auto") || strings.Contains(body, "overflow-x: auto") || strings.Contains(body, "overflow-x: scroll") || strings.Contains(body, "overflow: scroll") {
43 if strings.Contains(body, "overflow: auto") || strings.Contains(body, "overflow-x: auto") || strings.Contains(body, "overflow-x: scroll") || strings.Contains(body, "overflow: scroll") || strings.Contains(body, "overflow-y: auto") || strings.Contains(body, "overflow-y: scroll") {
43 t.Errorf("%s mag geen scrollbar krijgen: %s", sel, body)
44 t.Errorf("%s mag geen scrollbar krijgen: %s", sel, body)
44 }
45 }
45 }
46 for _, bad := range []string{"line-clamp:", "text-overflow: ellipsis", "-webkit-box", "max-height:"} {
46 ft := ruleBlock(src, ".float-tip")
47 if strings.Contains(body, bad) {
47 for _, want := range []string{
48 t.Errorf("%s kapt tekst af (%q): %s", sel, bad, body)
48 "white-space: normal",
49 }
49 "overflow: hidden",
50 "-webkit-line-clamp: 2",
51 "line-clamp: 2",
52 "overflow-wrap: anywhere",
53 "box-sizing: border-box",
54 "max-width: min(26rem, calc(100vw - 2rem))",
55 } {
56 if !strings.Contains(ft, want) {
57 t.Errorf(".float-tip mist %q", want)
58 }
50 }
59 }
51 if !strings.Contains(body, "white-space: normal") && sel != ".float-tip:popover-open" {
60 open := ruleBlock(src, ".float-tip:popover-open")
52 t.Errorf("%s mist white-space: normal", sel)
61 if !strings.Contains(open, "overflow: hidden") || !strings.Contains(open, "display: -webkit-box") {
53 }
62 t.Errorf(".float-tip:popover-open moet wrappen zonder scrollbar: %s", open)
54 if !strings.Contains(body, wantMax) {
63 }
55 t.Errorf("%s mist %s", sel, wantMax)
64 tb := ruleBlock(src, ".tip-b")
56 }
65 for _, want := range []string{"white-space: normal", "overflow: hidden", "-webkit-line-clamp: 2", "line-clamp: 2", "max-width: min(26rem, calc(100vw - 2rem))"} {
57 if !strings.Contains(body, "overflow: hidden") {
66 if !strings.Contains(tb, want) {
58 t.Errorf("%s mist overflow: hidden (voorkomt UA-scrollbars, zonder hoogte blijft alles zichtbaar)", sel)
67 t.Errorf(".tip-b mist %q", want)
68 }
59 }
69 }
60 }
70 shown := ruleBlock(src, ".tip:hover .tip-b, .tip-i:focus + .tip-b, .tip.open .tip-b, .tiphost:focus-within .tip-b")
61 shown := ruleBlock(src, ".tip:hover .tip-b, .tip-i:focus + .tip-b, .tip.open .tip-b, .tiphost:focus-within .tip-b")
71 if !strings.Contains(shown, "display: -webkit-box") {
62 if !strings.Contains(shown, "display: block") || strings.Contains(shown, "-webkit-box") {
72 t.Errorf("zichtbare .tip-b moet -webkit-box zijn voor line-clamp: %s", shown)
63 t.Errorf("zichtbare .tip-b moet display:block zijn, geen line-clamp-box: %s", shown)
73 }
64 }
74 // Geen latere .float-tip-regel die nowrap terugzet.
75 re := regexp.MustCompile(`(?s)\.float-tip[^{]*\{[^}]*white-space:\s*nowrap`)
65 re := regexp.MustCompile(`(?s)\.float-tip[^{]*\{[^}]*white-space:\s*nowrap`)
76 if re.MatchString(src) {
66 if re.MatchString(src) {
77 t.Fatal("ergens zet een .float-tip-regel white-space weer op nowrap")
67 t.Fatal("ergens zet een .float-tip-regel white-space weer op nowrap")
78 }
68 }
69 clamp := regexp.MustCompile(`(?s)\.(float-tip|tip-b)[^{]*\{[^}]*(line-clamp|text-overflow:\s*ellipsis)`)
70 if clamp.MatchString(src) {
71 t.Fatal("float-tip of tip-b mag tekst niet afkappen met line-clamp of ellipsis")
72 }
79}
73}
80
74
81func TestFloatTipSetsFullTitle(t *testing.T) {
75func TestFloatTipHasNoTitleAndKeepsViewport(t *testing.T) {
82 js, err := os.ReadFile("static/float.js")
76 js, err := os.ReadFile("static/float.js")
83 if err != nil {
77 if err != nil {
84 t.Fatal(err)
78 t.Fatal(err)
85 }
79 }
86 src := string(js)
80 src := string(js)
87 if !strings.Contains(src, `tip.setAttribute("title", text)`) {
81 if strings.Contains(src, `tip.setAttribute("title"`) {
88 t.Fatal("float-tip moet de volledige tekst in title zetten")
82 t.Fatal("float-tip heeft geen title: je kunt er niet over hoveren")
89 }
83 }
90 if !strings.Contains(src, `tip.textContent = text`) {
84 if !strings.Contains(src, `tip.textContent = text`) {
91 t.Fatal("float-tip toont de tekst")
85 t.Fatal("float-tip toont de tekst")
92 }
86 }
87 for _, want := range []string{`vw - GAP`, `vh - GAP`, `above-center`} {
88 if !strings.Contains(src, want) {
89 t.Errorf("place() moet in het viewport blijven (%q ontbreekt)", want)
90 }
91 }
92}
93
94func TestInfoTipStaysInViewport(t *testing.T) {
95 js, err := os.ReadFile("static/tip.js")
96 if err != nil {
97 t.Fatal(err)
98 }
99 src := string(js)
100 for _, want := range []string{"position = \"fixed\"", "placeBody", "vw - GAP", "vh - GAP", "classList.toggle(\"above\""} {
101 if !strings.Contains(src, want) {
102 t.Errorf("tip.js moet .tip-b in het viewport plaatsen (%q ontbreekt)", want)
103 }
104 }
93}
105}