Repository navigation
refactor(web): extract themed default logo - #309
Conversation
ravirajsinh45
left a comment
There was a problem hiding this comment.
@luozejian thanks for pulling these six duplicated logo blocks into ThemedDefaultLogo, good direction. A few things to fix before merge:
Blocking
- CHANGELOG — no entry under
[Unreleased]. This fixes a real bug (auth logo fallback never retrying) and changes rendered output in 6 places, so it should be documented per AGENTS.md. - Screenshots — the PR touches visible logo rendering in the sidebar, auth header, share password gate, powered-by badge, and settings previews, but there's no before/after screenshot. Please add them.
- Theme filter can be silently overridden —
.themed-default-logo'sfilterlives in@layer components(globals.css:118), andThemedDefaultLogomerges an openclassNameand forwardsstylewith no guard (themed-default-logo.tsx:37). Any future caller passing a filter-related class or inline style (e.g.className="drop-shadow-sm",style={{filter: 'none'}}) will silently break the dark-theme recolor with no error. Worth excludingstylefrom the forwarded props and either scoping the filter more defensively or documenting the constraint clearly on the component.
Worth a look, not blocking
auth-branding-header.tsx's newfailedLogostate never retries a URL that recovers after a transient failure (branding-preview.tsxalready solves this the same way with auseEffectreset on URL change — could reuse that pattern).- The theme-based logo-URL fallback ternary (
loginLogoUrl || (theme === 'dark' ? ... : ...)) is now duplicated acrossauth-branding-header.tsx,share/[token]/page.tsx, andsidebar.tsx— since this PR already touches all three, might be worth extracting alongside the component work. themed-default-logo.test.tsx: the injected<style>tag (line 47) only gets cleaned up if its assertions pass, so a failing test leaks it into later tests in the file.FreeFrameMarkinpowered-by-badge.tsxis now a dead one-line wrapper — could be inlined at its single call site.
|
@ravirajsinh45
Validation:
Screenshots are attached below. The intended visual output is unchanged; the comparisons cover the login/auth header and attribution, the share password gate, and the settings branding/sidebar preview. |
Maintainer touch-up on top of the review round, all in the same direction the branch was already going. The globals.css comment credited "outside Tailwind's layers" for the filter's precedence. Tailwind v3 flattens the @tailwind directives at build time and emits no @layer at-rules, so there is no layer priority to gain. What actually beats a bare utility is specificity, two selectors against a utility's one, plus sitting after the utilities @tailwind emits. That covers bare utilities only: a variant-prefixed one (hover:, group-hover:, peer-*) is emitted later at equal or higher specificity and would still win. The comment now says that, so the caller contract is legible rather than implied. Dark becomes the unscoped default, matching :root at the top of the same file. Both rules were attribute-gated, but :root and [data-theme="dark"] share the dark palette, so a document that never received a data-theme was painted dark while the logo kept its black ink. Narrow, since the head script sets the attribute on both its try and catch paths, but it costs one selector to close and it restores the file's own convention. style and srcSet were excluded from the props type yet still reached the img at runtime, because the spread precedes only src, alt, aria-hidden and className. Pinning both to undefined makes the ownership the JSDoc claims true without resting on the caller being typechecked. Three test fixes follow from that. The type-only prop assertion asserted a literal [true, true] and could not fail under vitest, which strips types; it is now a render that forces both props past the types and checks the DOM. The globals.css read was anchored to process.cwd(), the launching shell's directory rather than vitest's root, so it threw ENOENT from the repo root; it is anchored to the test file instead. And "applies the production theme filter despite a later filter class" over-claimed: .filter-none is one selector and loses on specificity whatever its position, so the assertions were identical with the class present, absent or first. Renamed to what it checks, with the rule scoping now asserted explicitly so an unscoped rule cannot slip back in. All three mutations verified to fail the suite before this was written.
ravirajsinh45
left a comment
There was a problem hiding this comment.
Verified the pixel claim independently and picked up the remaining small items in 98b6276. CI green on all four jobs. Thanks @luozejian.
|
@luozejian thanks for the quick turnaround on round 1. Five of the seven items landed cleanly, and rather than send this back for another round we picked up the remaining small ones ourselves and pushed 98b6276 to your branch. One thing worth flagging first: your comment says "Screenshots are attached below" but nothing came through, so the upload must have failed silently. With no visual evidence to check the change against, we ended up verifying the pixel claim the long way, and that closer look is where the rest of this came from. Worth attaching them next time a PR touches rendered output, since AGENTS.md and the PR template both ask for it. The good news is that the swap really is pixel-exact, and we confirmed it rather than assuming it. What changed in 98b6276: 1. The globals.css comment named the wrong mechanism. "Outside Tailwind's layers" does not do anything on Tailwind 3.4: the 2. Dark is now the unscoped default. Both rules were attribute-gated, but 3. 4. Three test fixes. The prop-restriction test asserted a literal Each of those is mutation-checked: revert the runtime strip, delete a CSS rule, or unscope one, and the suite fails.
|
Summary
ThemedDefaultLogowith icon/full variants, meaningful or decorative accessibility modes, and caller sizing classesdata-themeCSS, preserving share-page overrides without loading a hidden second imageTesting
pnpm test— 47 files, 358 tests passedpnpm exec tsc --noEmit --pretty falsepnpm buildCloses #288