Skip to content

refactor(types): augment CSSProperties for CSS custom properties - #53

Merged
yigitdot merged 2 commits into
mainfrom
refactor/css-vars-typed
May 9, 2026
Merged

yigitdot merged 2 commits into
mainfrom
refactor/css-vars-typed

Conversation

@yigitdot

@yigitdot yigitdot commented May 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add types/css.d.ts module-augmenting React.CSSProperties with --reveal-delay (typed as `${number}ms`) and --wordmark-h (typed as string).
  • Drop the 9 per-key ["--var" as string] casts across Close.tsx, Comparison.tsx, ComparisonRow.tsx, FaqItem.tsx, and MethodRow.tsx.
  • Document the convention in AGENTS.md.

The tighter `${number}ms` type on --reveal-delay matches the actual contract — app/globals.css feeds it to transition-delay, which only accepts <time> — and catches unit typos like "120 ms" or "0.12s" at compile time. All call sites already satisfy it.

Closes #48.

Follow-ups

Test plan

  • pnpm lint clean
  • pnpm build clean — TypeScript would flag the unaugmented --var keys as excess properties on CSSProperties, so build passing confirms the augmentation is in effect; build also validates the tighter `${number}ms` type at every call site
  • Visual smoke on / — reveal animations and Close hero wordmark sizing match prior behavior

🤖 Generated with Claude Code

Declare --reveal-delay and --wordmark-h on React.CSSProperties via
types/css.d.ts and drop the 9 per-key `[... as string]` casts across
6 files. Document the convention in AGENTS.md.

Closes #48.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 9, 2026 21:19
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 9, 2026 •

Copy link
Copy Markdown

Deploying website with  Cloudflare Pages  Cloudflare Pages

Latest commit: b7d017d
Status: ✅  Deploy successful!
Preview URL: https://ad3a184d.website-70y.pages.dev
Branch Preview URL: https://refactor-css-vars-typed.website-70y.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves type-safety and ergonomics around using CSS custom properties in React style props by module-augmenting React.CSSProperties and removing repetitive per-key casts at call sites (addressing #48).

Changes:

  • Added types/css.d.ts to augment react’s CSSProperties with --reveal-delay and --wordmark-h.
  • Replaced ["--var" as string] patterns with plain "--var" keys in affected components.
  • Documented the convention in AGENTS.md so future custom properties are added to the shared type declaration.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
types/css.d.ts Adds CSSProperties module augmentation for known CSS custom properties.
components/ui/MethodRow.tsx Removes per-key cast for --reveal-delay style prop usage.
components/ui/FaqItem.tsx Removes per-key cast for --reveal-delay style prop usage.
components/ui/ComparisonRow.tsx Removes per-key cast for --reveal-delay while keeping other style keys intact.
components/site/Comparison.tsx Removes per-key casts for multiple --reveal-delay usages.
components/site/Close.tsx Removes per-key casts for --wordmark-h and --reveal-delay usages.
AGENTS.md Documents the new convention (declare known --var names in types/css.d.ts).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces type safety for custom CSS properties by augmenting React's CSSProperties interface in a new types/css.d.ts file. This allows for the removal of manual type casting when using CSS variables like --reveal-delay and --wordmark-h across several components. The documentation in AGENTS.md has also been updated to reflect this change. I have no feedback to provide as the implementation is clean and follows the documented pattern.

The CSS consumer (transition-delay in app/globals.css) only accepts a
<time> value, and every call site already produces `${ms}ms`. Tightening
the type catches unit typos at compile time with zero call-site churn.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yigitdot
yigitdot merged commit bfbf61f into main May 9, 2026
7 checks passed
@yigitdot
yigitdot deleted the refactor/css-vars-typed branch May 9, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convention: per-key ["--var" as string] cast vs. as React.CSSProperties for CSS-variable style props

2 participants