Repository navigation
refactor(types): augment CSSProperties for CSS custom properties - #53
Conversation
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>
Deploying website with
|
| 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 |
There was a problem hiding this comment.
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.tsto augmentreact’sCSSPropertieswith--reveal-delayand--wordmark-h. - Replaced
["--var" as string]patterns with plain"--var"keys in affected components. - Documented the convention in
AGENTS.mdso 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.
There was a problem hiding this comment.
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>
Summary
types/css.d.tsmodule-augmentingReact.CSSPropertieswith--reveal-delay(typed as`${number}ms`) and--wordmark-h(typed asstring).["--var" as string]casts acrossClose.tsx,Comparison.tsx,ComparisonRow.tsx,FaqItem.tsx, andMethodRow.tsx.AGENTS.md.The tighter
`${number}ms`type on--reveal-delaymatches the actual contract —app/globals.cssfeeds it totransition-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
--wordmark-hfrom CSSProperties augmentation; inline as local const #54 — drop--wordmark-hfrom the augmentation; it's used in one component and could be a local const.Test plan
pnpm lintcleanpnpm buildclean — TypeScript would flag the unaugmented--varkeys as excess properties onCSSProperties, so build passing confirms the augmentation is in effect; build also validates the tighter`${number}ms`type at every call site/— reveal animations and Close hero wordmark sizing match prior behavior🤖 Generated with Claude Code