Skip to content

Conversation

@TheOrcDev
Copy link
Owner

@TheOrcDev TheOrcDev commented Jun 13, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced calendar component with improved styling, richer customization options, and RTL support.
    • Added new props for flexible layout, button styling, and custom formatting.
    • Introduced a new calendar day button with better focus management and detailed selection states.
  • Refactor

    • Streamlined calendar layout and navigation for a more consistent user experience.
    • Consolidated left and right chevron icons into a single adaptable component to reduce duplication.
  • Chores

    • Updated "react-day-picker" dependency to the latest version.

@coderabbitai
Copy link

coderabbitai bot commented Jun 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The Calendar component was refactored for improved styling, customization, and accessibility. New props and custom components were introduced, including CalendarDayButton and a multi-orientation Chevron. The dependency react-day-picker was updated from version 8.10.1 to 9.7.0 in package.json. The 8bit calendar icons were consolidated into a single Chevron component. Both Calendar and CalendarDayButton are now exported.

Changes

File(s) Change Summary
components/ui/calendar.tsx Refactored Calendar for enhanced styling, added new props, custom components (CalendarDayButton, multi-orientation Chevron), and accessibility improvements. Updated exports.
components/ui/8bit/calendar.tsx Consolidated IconLeft and IconRight into a single Chevron component with conditional rendering based on orientation prop.
package.json Updated react-day-picker dependency from version 8.10.1 to 9.7.0.
public/r/8bit-calendar.json Refactored internal icon rendering to use single Chevron component with conditional left/right rendering; no other changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Calendar
    participant DayPicker
    participant CalendarDayButton
    participant Button

    User->>Calendar: Render with props (captionLayout, buttonVariant, components, formatters)
    Calendar->>DayPicker: Pass customized props, formatters, components (including Chevron, CalendarDayButton)
    DayPicker->>CalendarDayButton: Render each day using CalendarDayButton
    CalendarDayButton->>Button: Render day button with custom styling and focus management
Loading

Possibly related PRs

Poem

In the garden where calendars grow,
New buttons and chevrons steal the show.
With styles refreshed and focus keen,
Days now sparkle, crisp and clean.
The picker’s learned some brand new tricks—
Hopping forward with version nine-point-six! 🗓️🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7d2846 and c291757.

📒 Files selected for processing (1)
  • public/r/8bit-calendar.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel
Copy link

vercel bot commented Jun 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
8bitcn-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 13, 2025 0:24am

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
components/ui/calendar.tsx (1)

28-29: Minor: avoid recomputing default class map

getDefaultClassNames() is pure; calling it twice per render (Calendar & CalendarDayButton) is unnecessary.
Consider lifting it outside the components or memoising to avoid redundant work.

Also applies to: 180-181

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5de2a07 and 3b2c411.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • components/ui/calendar.tsx (1 hunks)
  • package.json (1 hunks)
🔇 Additional comments (3)
package.json (1)

50-51: Major-version bump – verify integration & build pipeline

react-day-picker jumped from 8 → 9 (breaking).
Please run the full build/test suite (including SSR pages) and confirm:

  1. No ESM/TS import resolution issues.
  2. The required v9 CSS (or getDefaultClassNames) is actually bundled.
  3. All calendar usages elsewhere were migrated.
components/ui/calendar.tsx (2)

40-44: Possible wrong formatter key

formatMonthDropdown is not listed in the v9 formatter API (formatCaption, formatDay, …).
Double-check this – an unknown key will be ignored and the dropdown may fallback to default English labels.


182-186: LGTM – focus handling is correct

Effect scopes to modifiers.focused; straightforward and side-effect free.

Comment on lines +188 to +194
<Button
ref={ref}
variant="ghost"
size="icon"
data-day={day.date.toLocaleDateString()}
data-selected-single={
modifiers.selected &&
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use locale-independent day identifiers

data-day={day.date.toLocaleDateString()} varies with the user’s locale (e.g. 04/07/2025 vs 7.4.2025).
Prefer an ISO value to keep DOM queries deterministic:

- data-day={day.date.toLocaleDateString()}
+ data-day={day.date.toISOString().slice(0,10)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Button
ref={ref}
variant="ghost"
size="icon"
data-day={day.date.toLocaleDateString()}
data-selected-single={
modifiers.selected &&
<Button
ref={ref}
variant="ghost"
size="icon"
data-day={day.date.toISOString().slice(0,10)}
data-selected-single={
modifiers.selected &&
🤖 Prompt for AI Agents
In components/ui/calendar.tsx around lines 188 to 194, the data-day attribute
uses day.date.toLocaleDateString(), which produces locale-dependent date
strings. Replace this with an ISO 8601 formatted date string (e.g.,
day.date.toISOString().split('T')[0]) to ensure consistent, locale-independent
day identifiers for reliable DOM queries.

@TheOrcDev TheOrcDev merged commit 62f6b35 into main Jun 13, 2025
1 of 2 checks passed
@TheOrcDev TheOrcDev deleted the chore/new-shadcn-calendar branch June 13, 2025 12:23
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b2c411 and c7d2846.

📒 Files selected for processing (1)
  • components/ui/8bit/calendar.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
components/ui/8bit/calendar.tsx (1)
lib/utils.ts (1)
  • cn (4-6)
🔇 Additional comments (1)
components/ui/8bit/calendar.tsx (1)

114-135:

❓ Verification inconclusive

Handle the "down" orientation (and future-proof the fallback)

The new Shadcn calendar emits three orientations: "left", "right" and "down".
With the current implementation any non-"left" value falls through to the right-chevron, so the month/year selector will incorrectly render a right arrow instead of a downward one.

Quick fix:

-   if (orientation === "left") { … }
-   return ( // right
+   if (orientation === "left") { … }
+   if (orientation === "right") { … }
+   // ↓ fallback for "down" (rotate the right chevron 90° as a placeholder)
+   return (
+     <svg
+       viewBox="0 0 256 256"
+       className={cn("size-4 shrink-0 -rotate-90", className)}
+       aria-label="chevron-down"
+       {...props}
+     >
+       {/* existing right-chevron rects */}
+     </svg>
+   );

At minimum, add an explicit if (orientation === "down") guard so the intent is clear and avoid silently rendering the wrong icon.


🏁 Script executed:

#!/usr/bin/env bash
# Locate the calendar component file
FILE=$(fd calendar.tsx -t f | head -n1)
echo "Using file: $FILE"

# Show occurrences of orientation prop and related logic
rg -n "orientation" "$FILE"

# Extract lines around the SVG return (approx. lines 90–160)
sed -n '90,160p' "$FILE"

Length of output: 277


Explicitly handle the “down” orientation in the chevron icon

Please verify in components/ui/8bit/calendar.tsx (lines 114–135) that non-"left" values aren’t silently falling back to the right-chevron. You should add explicit guards for both "right" and "down" so the down-arrow doesn’t render as a right-arrow when the calendar emits "down" (and to future-proof against any new orientations).

Example snippet:

- if (orientation === "left") { … }
- return ( // right
+ if (orientation === "left") {
+   … // left-chevron
+ } else if (orientation === "right") {
+   … // right-chevron
+ } else if (orientation === "down") {
+   return (
+     <svg
+       viewBox="0 0 256 256"
+       className={cn("size-4 shrink-0 -rotate-90", className)}
+       aria-label="chevron-down"
+       {...props}
+     >
+       {/* existing rects */}
+     </svg>
+   );
+ }
+ // fallback for any other orientation
+ return (
+   <svg
+     viewBox="0 0 256 256"
+     className={cn("size-4 shrink-0", className)}
+     aria-label="chevron-right"
+     {...props}
+   >
+     {/* existing rects */}
+   </svg>
+ );

Comment on lines +54 to +67
Chevron: ({ className, ...props }) => {
if (props.orientation === "left") {
return (
<svg
viewBox="0 0 256 256"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
stroke="currentColor"
strokeWidth="0.25"
color=""
className={cn("size-4 shrink-0", className)}
aria-label="chevron-left"
{...props}
>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid leaking orientation onto the rendered <svg> element

orientation is currently buried inside props, then spread onto the <svg>.
React will pass it through as an unknown DOM attribute (orientation="left" / "right"), which is invalid HTML and needlessly inflates the markup.

- Chevron: ({ className, ...props }) => {
-   if (props.orientation === "left") {
+ Chevron: ({ className, orientation, ...props }) => {
+   if (orientation === "left") {-       {...props}
+       {...props}
     >

Extracting the variable keeps the public signature intact while preventing the stray attribute from ever reaching the DOM.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Chevron: ({ className, ...props }) => {
if (props.orientation === "left") {
return (
<svg
viewBox="0 0 256 256"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
stroke="currentColor"
strokeWidth="0.25"
color=""
className={cn("size-4 shrink-0", className)}
aria-label="chevron-left"
{...props}
>
Chevron: ({ className, orientation, ...props }) => {
if (orientation === "left") {
return (
<svg
viewBox="0 0 256 256"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
stroke="currentColor"
strokeWidth="0.25"
color=""
className={cn("size-4 shrink-0", className)}
aria-label="chevron-left"
{...props}
>
🤖 Prompt for AI Agents
In components/ui/8bit/calendar.tsx around lines 54 to 67, the orientation prop
is being spread onto the SVG element, causing an invalid HTML attribute to
appear in the DOM. To fix this, destructure orientation from props before
spreading the remaining props onto the SVG, so orientation is used internally
but not passed as an attribute to the SVG element.

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