Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(skill-burger): line up the pill's sheen with its step count

AdityaUmaleeb47406e56bf
diff --git a/src/components/skill-burger/BurgerPill.dom.test.ts b/src/components/skill-burger/BurgerPill.dom.test.ts
new file mode 100644
index 0000000000..927c09a08c
--- /dev/null
+++ b/src/components/skill-burger/BurgerPill.dom.test.ts
@@ -0,0 +1,34 @@
+// @vitest-environment happy-dom
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, expect, it } from "vitest";
+
+import { Sheen, WithCount } from "./BurgerPill";
+
+(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+let host: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ host = document.createElement("div");
+ document.body.append(host);
+ root = createRoot(host);
+});
+afterEach(() => {
+ act(() => root.unmount());
+ host.remove();
+});
+
+it("draws the sheen's copy of a counting label over the label itself, not beside or below it", async () => {
+ await act(async () => root.render(createElement(Sheen, { text: "Cooking… 12", children: createElement(WithCount, { template: "Cooking… {count}", count: 12 }) })));
+ const box = host.querySelector<HTMLElement>(".thinking-shimmer")!;
+ const copy = box.querySelector<HTMLElement>(".thinking-sheen [data-text]")!;
+ const count = box.querySelector<HTMLElement>(".burger-tick")!;
+ expect(copy.dataset.text).toBe(box.firstChild!.textContent! + count.textContent);
+ // The copy is drawn from its own box's top with the same line height, so the box must be a block, not an inline span
+ // whose box is shorter than its line.
+ expect(box.classList).toContain("block");
+ // The count's digits are fixed width; the copy inherits its digits from the box, so it must use the same ones.
+ expect(count.classList).toContain("tabular-nums");
+ expect(box.classList).toContain("tabular-nums");
+});
diff --git a/src/components/skill-burger/BurgerPill.tsx b/src/components/skill-burger/BurgerPill.tsx
index e21672a80f..bf74eb94ce 100644
--- a/src/components/skill-burger/BurgerPill.tsx
+++ b/src/components/skill-burger/BurgerPill.tsx
@@ -40,7 +40,7 @@ const SHEEN_PERIOD_MS = 2000;
export function Sheen({ children, text }: { children: ReactNode; text: string }) {
const [delay] = useState(() => `-${Date.now() % SHEEN_PERIOD_MS}ms`);
return (
- <span className="thinking-shimmer min-w-0 truncate" style={{ "--sheen-period": `${SHEEN_PERIOD_MS}ms`, "--sheen-delay": delay } as CSSProperties}>
+ <span className="thinking-shimmer block min-w-0 truncate tabular-nums" style={{ "--sheen-period": `${SHEEN_PERIOD_MS}ms`, "--sheen-delay": delay } as CSSProperties}>
{children}
<span aria-hidden="true" className="thinking-sheen"><span data-text={text} /></span>
</span>