-
Notifications
You must be signed in to change notification settings - Fork 0
chore: theme token cleanup + chrome-active helper #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yigitdot
wants to merge
6
commits into
main
Choose a base branch
from
chore/theme-chrome-followups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a3309d3
chore(theme): drop unreferenced --font-sans token
yigitdot 9b17693
refactor(theme): promote --frame-* tokens to Tailwind v4 namespaces
yigitdot 39ac7c8
refactor(chrome): extract resolveActiveSection helper + unit tests
yigitdot 4b08b39
chore(chrome): drop #112 back-reference from test name
yigitdot 0730f82
refactor(chrome): tighten resolveActiveSection types + add exact-matc…
yigitdot 86293ff
refactor(chrome): drop T extends string + correct guard rationale
yigitdot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { resolveActiveSection } from "./chrome-active"; | ||
|
|
||
| describe("resolveActiveSection", () => { | ||
| it.each([ | ||
| { | ||
| name: "off-home + scrolled falls back", | ||
| pathname: "/blog/foo/", | ||
| scrolled: true, | ||
| observed: "compare", | ||
| expected: "intro", | ||
| }, | ||
| { | ||
| name: "home but not yet scrolled falls back (back-nav flash guard)", | ||
| pathname: "/", | ||
| scrolled: false, | ||
| observed: "compare", | ||
| expected: "intro", | ||
| }, | ||
| { | ||
| name: "home + scrolled returns the observed dark section", | ||
| pathname: "/", | ||
| scrolled: true, | ||
| observed: "compare", | ||
| expected: "compare", | ||
| }, | ||
| { | ||
| name: "home + scrolled passes other DARK_SECTIONS members through", | ||
| pathname: "/", | ||
| scrolled: true, | ||
| observed: "faq", | ||
| expected: "faq", | ||
| }, | ||
| { | ||
| name: "off-home dominates regardless of scrolled state", | ||
| pathname: "/blog/", | ||
| scrolled: false, | ||
| observed: "faq", | ||
| expected: "intro", | ||
| }, | ||
| { | ||
| name: "home with query string falls back (exact match)", | ||
| pathname: "/?utm=x", | ||
| scrolled: true, | ||
| observed: "compare", | ||
| expected: "intro", | ||
| }, | ||
| ] as const)("$name", ({ pathname, scrolled, observed, expected }) => { | ||
| expect(resolveActiveSection(pathname, scrolled, observed, "intro")).toBe( | ||
| expected, | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Both `pathname === "/"` and `scrolled` must hold for `observed` to win. | ||
| // Off-home, the caller's observer never gets built but `active` still | ||
| // holds its last home-route value — the home check stops that stale value | ||
| // painting. On home, `active` is briefly stale between the route-change | ||
| // render and the new observer's first callback; `scrolled` (scrollY > 8) | ||
| // stands in for "observer has had a moment to fire". Caveat: back-nav | ||
| // with restored scroll skips this — a brief stale-tone flash is possible. | ||
| export function resolveActiveSection<T>( | ||
| pathname: string, | ||
| scrolled: boolean, | ||
| observed: T, | ||
| fallback: T, | ||
| ): T { | ||
| return pathname === "/" && scrolled ? observed : fallback; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Tailwind CSS v4, the --container-* namespace is specifically reserved for configuring the container utility (e.g., centering, padding, or breakpoint-specific max-widths). It does not automatically generate a max-w-* utility for the given name. To enable the max-w-frame utility used in Chrome.tsx, Footer.tsx, and Frame.tsx, you should use the --width-* namespace (or --spacing-* if you want it available for padding/margin as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified —
--container-*does generatemax-w-*in Tailwind v4. Afterpnpm buildon this branch (39ac7c8), the static export contains.max-w-frame{max-width:1280px}— exactly the utilityChrome.tsx/Footer.tsx/Frame.tsxrely on. Tailwind v4's own defaults follow the same pattern:node_modules/tailwindcss/theme.cssdefines--container-3xs…--container-7xl, which back the framework'smax-w-3xs…max-w-7xlutilities, and the official v4 docs implement everymax-w-*asmax-width: var(--container-<name>)(e.g.max-w-2xsismax-width: var(--container-2xs)).The
@frame:container-query variant the comment alludes to is an additional output of--container-*, not a substitute — both happen.--width-*isn't a max-width-generating namespace in v4, so renaming to--width-framewould actually breakmax-w-frame. No change needed.