Skip to content

improvements#15

Merged
gfazioli merged 11 commits into
masterfrom
improvements
Mar 22, 2026
Merged

improvements#15
gfazioli merged 11 commits into
masterfrom
improvements

Conversation

@gfazioli
Copy link
Copy Markdown
Owner

  • refactor(Clock): 🛠️ improve Clock for SSR, accessibility, and performance
  • refactor: clean up clock hooks and stories for consistency 🧹
  • feat(clock): 🕒 add Clock.Digital and new clock features
  • 🚀 feat: add absolute tick positioning and perimeter-based numbers for rectangle geometry
  • 🛠️ Fix hand positioning using correct center coordinates
  • feat(ClockDigital): add ClockDigital component with docs and demos
  • docs(demo): center Clock demo group alignment 📄
  • ✨ Add ClockDigital styles API demo
  • refactor: 📚 Add componentPrefix to DocsTabs for Clock components

…ance

- Add static ClockFace component to render safe SSR markup.
- Introduce `ariaLabel` prop and default label with current time.
- Set default `secondHandBehavior` to `'tick'` and expose the prop.
- Replace esbuild-jest with a custom transformer to avoid Babel fallback.
- Update package.json, docs, and add CLAUDE.md for better documentation.
- Remove redundant amPm display in countdown story.
- Simplify reset logic in useClockCountDown.
- Update stories to use formatted time values and pad minutes.
- Change start button to resume for correct start behavior.
- Introduce Clock.Digital compound component with timezone, 12/24‑hour, AM/PM, date, separators, and update frequency
- Add shape, aspectRatio, borderRadius, sectors, faceContent, animateOnMount, and custom hand render props to Clock
- Implement auto‑size support for size="auto" using ResizeObserver
- Add new demos, docs, styles‑api entries, and comprehensive tests for the new features
- Update exports to expose ClockDigital, geometry helpers, and related types
… rectangle geometry

- Position ticks absolutely with rotation for rounded rectangle clocks.
- Numbers now follow the perimeter, matching Apple Watch style.
- Updated geometry calculations for edge distance and corner arcs.
- Added tests for tick and number placement.
- Updated glass wrapper to set width/height.
- Use geometry.centerX and centerY for hand and center placement instead of clockRadius.
- Corrects visual misalignment of hour, minute, second hands and center dot.
- Ensures consistent layout across all clock sizes.
- Introduce ClockDigital component with customizable display options.
- Add ClockDigital styles API for theming.
- Provide configurator and demo examples for ClockDigital.
- Update docs to include ClockDigital section and new animation props.
- Adjust Clock component and docgen to support ClockDigital.
- Aligns Clock components centrally in the demo for a cleaner layout.
- Uses `justify="center"` and `align="center"` to improve visual consistency.
- Introduce a new demo showcasing Clock.Digital styles API
- Export the demo from the docs index
- Update the docs page to display the new demo section
- Adds componentPrefix prop to DocsTabs to prefix Clock component names.
- Ensures docs display correct names for Clock and ClockDigital.
- Improves clarity in generated documentation.
Copilot AI review requested due to automatic review settings March 21, 2026 11:54
Copy link
Copy Markdown

Copilot AI left a comment

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 significantly expands and refactors the clock package: adding a new ClockDigital component, introducing geometry-driven rendering (including rounded-rect “watch” faces), improving SSR safety/performance, and modernizing hooks/docs/testing setup.

Changes:

  • Add ClockDigital (compound Clock.Digital + standalone export) with Styles API, tests, and docs/demos.
  • Introduce geometry module to support circular + rounded-rectangle layouts, absolute tick positioning, and sector paths.
  • Refactor useClock / useClockCountDown return shapes (numeric + formatted fields), drift-free countdown logic, and update test infrastructure (custom Jest transformer).

Reviewed changes

Copilot reviewed 46 out of 49 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
scripts/docgen.ts Include ClockDigital in doc generation inputs
package/src/index.ts Export new component/types and geometry API
package/src/hooks/use-clock.ts Return numeric time + formatted strings; update frequency clamp; remove start
package/src/hooks/use-clock.test.tsx Replace placeholder tests with real hook tests
package/src/hooks/use-clock.story.tsx Update stories to new hook API (formatted*, resume)
package/src/hooks/use-clock-count-down.ts Drift-free countdown, formatted outputs, API surface changes
package/src/hooks/use-clock-count-down.test.tsx Replace placeholder tests with real countdown tests
package/src/hooks/use-clock-count-down.story.tsx Update stories to new countdown API (days, resume)
package/src/geometry.ts New geometry abstraction + rounded-rect perimeter logic
package/src/geometry.test.ts Add unit tests for geometry utilities/classes
package/src/ClockDigital.tsx New digital clock component using Mantine factory + useClock
package/src/ClockDigital.test.tsx Tests for rendering/accessibility/ref forwarding/compound usage
package/src/ClockDigital.module.css Styling for digital clock segments/date/am-pm
package/src/Clock.tsx Major refactor: geometry-driven layout, Clock.Digital, sectors, faceContent, auto size, mount animation, onTimeChange
package/src/Clock.test.tsx Expand tests for new features and behaviors
package/src/Clock.module.css CSS adjustments + new faceContent selector
package/package.json Update package keywords
package.json Bump tool/library versions (yarn/dayjs/mantine/storybook/etc.)
jest.config.cjs Switch to local custom transformer
esbuild-jest-transformer.cjs Add custom esbuild transformer to avoid babel fallback
docs/styles-api/index.ts Register ClockDigital styles API
docs/styles-api/ClockDigital.styles-api.ts Add Styles API data for ClockDigital
docs/styles-api/Clock.styles-api.ts Document new faceContent selector
docs/pages/index.tsx Update DocsTabs to include ClockDigital + component prefix
docs/package.json Rename docs package + bump Mantine/Next deps
docs/docs.mdx Update hook docs + add Clock.Digital / shapes / sectors / etc. sections
docs/demos/useClockCountDown.demo.targetDates.tsx Update demo to new countdown API and formatted fields
docs/demos/useClockCountDown.demo.interactive.tsx Update demo to new countdown API (resume, formatted fields)
docs/demos/useClock.demo.worldClocks.tsx Use formatted fields in display
docs/demos/useClock.demo.specificTime.tsx Replace start with resume
docs/demos/useClock.demo.basic.tsx Use formatted fields + resume in controls
docs/demos/index.ts Export new demo modules
docs/demos/ClockDigital.demo.stylesApi.tsx Add styles-api demo for ClockDigital
docs/demos/ClockDigital.demo.configurator.tsx Add configurator demo for ClockDigital
docs/demos/ClockCountDown.demo.basic.tsx Update imports + formatted fields + API changes
docs/demos/Clock.demo.shapes.tsx Add shapes demo (rounded-rect/aspectRatio)
docs/demos/Clock.demo.sectors.tsx Add sectors demo
docs/demos/Clock.demo.reverseCountdown.tsx Update reverse countdown to formatted fields + resume
docs/demos/Clock.demo.responsiveSize.tsx Add auto-size demo
docs/demos/Clock.demo.mountAnimation.tsx Add animate-on-mount demo
docs/demos/Clock.demo.faceContent.tsx Add faceContent demo
docs/demos/Clock.demo.digital.tsx Add Clock.Digital usage demo
docs/demos/Clock.demo.customHands.tsx Add custom hand rendering demo
docs/demos/Clock.demo.configurator.tsx Extend configurator controls for shape props
CLAUDE.md Add repo guidance/commands/architecture notes
.yarnrc.yml Update yarn release path
Comments suppressed due to low confidence (1)

package/src/hooks/use-clock.ts:71

  • useClock removes the start control method from the returned ClockData. If this hook is part of the public API, this is a breaking change for consumers. Consider keeping start as an alias of resume (possibly deprecated) or clearly documenting the breaking change and coordinating it with a version bump.

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

Comment thread package/src/Clock.tsx Outdated
Comment thread package/src/Clock.tsx
Comment thread package/src/Clock.tsx
Comment thread package/src/Clock.tsx
Comment thread package/src/hooks/use-clock.ts
Comment thread package/src/hooks/use-clock-count-down.ts
Comment thread package/src/geometry.ts
- Add `start` method as alias for `resume` in countdown hook
- Update docs with new `start` prop, shape, sectors, face content, animation, etc.
- Use `useCallbackRef` and cancelAnimationFrame for proper cleanup
- Enforce minimum `aspectRatio` and `borderRadius` in rounded‑rect geometry
- Return `year: 0` in SSR for `useClock` hook
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 46 out of 49 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

package/src/hooks/use-clock.ts:71

  • useClock no longer returns a start() method (only resume()), which is a breaking API change for hook consumers. Consider keeping start as an alias of resume (as done in useClockCountDown) or documenting the breaking change + versioning it appropriately.

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

Comment thread package/src/geometry.ts
Comment thread package/src/geometry.ts Outdated
Comment thread package/src/hooks/use-clock.ts Outdated
Comment thread package/src/hooks/use-clock-count-down.ts Outdated
Comment thread package/src/hooks/use-clock.test.tsx
Comment thread package/src/Clock.tsx Outdated
- Clamp updateFrequency to ≥16 ms, fallback to 1000 ms for non‑finite values.
- Add role, tabIndex, aria‑label, and key handlers to interactive clock sectors.
- Warn when RoundedRectGeometry receives a negative discriminant.
- Refactor CSS variable resolver for clarity and reuse.
- Memoize geometry calculation to avoid unnecessary recomputations.
- Update test to verify real year after mount.
@gfazioli gfazioli merged commit 128193d into master Mar 22, 2026
1 check passed
@gfazioli gfazioli deleted the improvements branch March 22, 2026 22:27
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.

2 participants