Skip to content

fix(theme): add default value for custom theme properties#5195

Merged
jrgarciadev merged 2 commits into
heroui-inc:canaryfrom
il-1337:fix/theme
Apr 28, 2025
Merged

fix(theme): add default value for custom theme properties#5195
jrgarciadev merged 2 commits into
heroui-inc:canaryfrom
il-1337:fix/theme

Conversation

@il-1337
Copy link
Copy Markdown

@il-1337 il-1337 commented Apr 15, 2025

Closes #5194

📝 Description

Custom theme reports an error when colors attribute is not specified.

⛳️ Current behavior (updates)

The deepMerge operation only applies if the custom theme explicitly defines both colors and layout properties. Undefined properties remain unchanged.

🚀 New behavior

Custom theme properties now extend their default values from the parent theme.

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency by always assigning default values for theme colors and layout, ensuring these properties are always defined in custom themes.
  • Chores

    • Added documentation for a patch update to the theme package, highlighting the addition of default values for custom theme properties.

@il-1337 il-1337 requested a review from jrgarciadev as a code owner April 15, 2025 09:02
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 15, 2025

🦋 Changeset detected

Latest commit: 5e37ea7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@heroui/theme Patch
@heroui/autocomplete Patch
@heroui/checkbox Patch
@heroui/date-input Patch
@heroui/date-picker Patch
@heroui/form Patch
@heroui/input-otp Patch
@heroui/input Patch
@heroui/number-input Patch
@heroui/radio Patch
@heroui/select Patch
@heroui/table Patch
@heroui/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2025

@il-1337 is attempting to deploy a commit to the HeroUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2025

"""

Walkthrough

The changes introduce a refactor in the merging logic for custom theme properties, specifically for the colors and layout attributes within the theme plugin. The new implementation ensures that these properties are always assigned default values, even when not provided by the user. Additionally, a changeset file documents this patch update for the @heroui/theme package. No changes were made to exported or public entities.

Changes

File(s) Change Summary
packages/core/theme/src/plugin.ts Refactored merging logic for colors and layout properties to always assign default values.
.changeset/honest-keys-swim.md Added changeset documenting the patch update for default custom theme properties.

Sequence Diagram(s)

sequenceDiagram
    participant User as User Theme Config
    participant Plugin as Theme Plugin
    participant Base as Base Theme

    User->>Plugin: Provide custom theme (may omit colors/layout)
    Plugin->>Base: Retrieve base colors/layout
    Plugin->>Plugin: Merge user theme with base (always assign colors/layout)
    Plugin->>User: Return merged theme with defaults
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent error when custom theme omits colors attribute (#5194)
"""

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa9ea5c and 5e37ea7.

📒 Files selected for processing (1)
  • .changeset/honest-keys-swim.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/honest-keys-swim.md

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 21, 2025

Open in StackBlitz

@heroui/accordion

npm i https://pkg.pr.new/@heroui/accordion@5195

@heroui/alert

npm i https://pkg.pr.new/@heroui/alert@5195

@heroui/autocomplete

npm i https://pkg.pr.new/@heroui/autocomplete@5195

@heroui/avatar

npm i https://pkg.pr.new/@heroui/avatar@5195

@heroui/badge

npm i https://pkg.pr.new/@heroui/badge@5195

@heroui/breadcrumbs

npm i https://pkg.pr.new/@heroui/breadcrumbs@5195

@heroui/button

npm i https://pkg.pr.new/@heroui/button@5195

@heroui/calendar

npm i https://pkg.pr.new/@heroui/calendar@5195

@heroui/card

npm i https://pkg.pr.new/@heroui/card@5195

@heroui/checkbox

npm i https://pkg.pr.new/@heroui/checkbox@5195

@heroui/chip

npm i https://pkg.pr.new/@heroui/chip@5195

@heroui/code

npm i https://pkg.pr.new/@heroui/code@5195

@heroui/date-input

npm i https://pkg.pr.new/@heroui/date-input@5195

@heroui/date-picker

npm i https://pkg.pr.new/@heroui/date-picker@5195

@heroui/divider

npm i https://pkg.pr.new/@heroui/divider@5195

@heroui/drawer

npm i https://pkg.pr.new/@heroui/drawer@5195

@heroui/dropdown

npm i https://pkg.pr.new/@heroui/dropdown@5195

@heroui/form

npm i https://pkg.pr.new/@heroui/form@5195

@heroui/image

npm i https://pkg.pr.new/@heroui/image@5195

@heroui/input

npm i https://pkg.pr.new/@heroui/input@5195

@heroui/input-otp

npm i https://pkg.pr.new/@heroui/input-otp@5195

@heroui/kbd

npm i https://pkg.pr.new/@heroui/kbd@5195

@heroui/link

npm i https://pkg.pr.new/@heroui/link@5195

@heroui/listbox

npm i https://pkg.pr.new/@heroui/listbox@5195

@heroui/menu

npm i https://pkg.pr.new/@heroui/menu@5195

@heroui/modal

npm i https://pkg.pr.new/@heroui/modal@5195

@heroui/navbar

npm i https://pkg.pr.new/@heroui/navbar@5195

@heroui/number-input

npm i https://pkg.pr.new/@heroui/number-input@5195

@heroui/pagination

npm i https://pkg.pr.new/@heroui/pagination@5195

@heroui/popover

npm i https://pkg.pr.new/@heroui/popover@5195

@heroui/progress

npm i https://pkg.pr.new/@heroui/progress@5195

@heroui/radio

npm i https://pkg.pr.new/@heroui/radio@5195

@heroui/ripple

npm i https://pkg.pr.new/@heroui/ripple@5195

@heroui/scroll-shadow

npm i https://pkg.pr.new/@heroui/scroll-shadow@5195

@heroui/select

npm i https://pkg.pr.new/@heroui/select@5195

@heroui/skeleton

npm i https://pkg.pr.new/@heroui/skeleton@5195

@heroui/slider

npm i https://pkg.pr.new/@heroui/slider@5195

@heroui/snippet

npm i https://pkg.pr.new/@heroui/snippet@5195

@heroui/spacer

npm i https://pkg.pr.new/@heroui/spacer@5195

@heroui/spinner

npm i https://pkg.pr.new/@heroui/spinner@5195

@heroui/switch

npm i https://pkg.pr.new/@heroui/switch@5195

@heroui/table

npm i https://pkg.pr.new/@heroui/table@5195

@heroui/tabs

npm i https://pkg.pr.new/@heroui/tabs@5195

@heroui/toast

npm i https://pkg.pr.new/@heroui/toast@5195

@heroui/tooltip

npm i https://pkg.pr.new/@heroui/tooltip@5195

@heroui/user

npm i https://pkg.pr.new/@heroui/user@5195

@heroui/react

npm i https://pkg.pr.new/@heroui/react@5195

@heroui/system

npm i https://pkg.pr.new/@heroui/system@5195

@heroui/system-rsc

npm i https://pkg.pr.new/@heroui/system-rsc@5195

@heroui/theme

npm i https://pkg.pr.new/@heroui/theme@5195

@heroui/use-aria-accordion

npm i https://pkg.pr.new/@heroui/use-aria-accordion@5195

@heroui/use-aria-accordion-item

npm i https://pkg.pr.new/@heroui/use-aria-accordion-item@5195

@heroui/use-aria-button

npm i https://pkg.pr.new/@heroui/use-aria-button@5195

@heroui/use-aria-link

npm i https://pkg.pr.new/@heroui/use-aria-link@5195

@heroui/use-aria-modal-overlay

npm i https://pkg.pr.new/@heroui/use-aria-modal-overlay@5195

@heroui/use-aria-multiselect

npm i https://pkg.pr.new/@heroui/use-aria-multiselect@5195

@heroui/use-callback-ref

npm i https://pkg.pr.new/@heroui/use-callback-ref@5195

@heroui/use-clipboard

npm i https://pkg.pr.new/@heroui/use-clipboard@5195

@heroui/use-data-scroll-overflow

npm i https://pkg.pr.new/@heroui/use-data-scroll-overflow@5195

@heroui/use-disclosure

npm i https://pkg.pr.new/@heroui/use-disclosure@5195

@heroui/use-draggable

npm i https://pkg.pr.new/@heroui/use-draggable@5195

@heroui/use-image

npm i https://pkg.pr.new/@heroui/use-image@5195

@heroui/use-infinite-scroll

npm i https://pkg.pr.new/@heroui/use-infinite-scroll@5195

@heroui/use-is-mobile

npm i https://pkg.pr.new/@heroui/use-is-mobile@5195

@heroui/use-intersection-observer

npm i https://pkg.pr.new/@heroui/use-intersection-observer@5195

@heroui/use-is-mounted

npm i https://pkg.pr.new/@heroui/use-is-mounted@5195

@heroui/use-measure

npm i https://pkg.pr.new/@heroui/use-measure@5195

@heroui/use-pagination

npm i https://pkg.pr.new/@heroui/use-pagination@5195

@heroui/use-real-shape

npm i https://pkg.pr.new/@heroui/use-real-shape@5195

@heroui/use-ref-state

npm i https://pkg.pr.new/@heroui/use-ref-state@5195

@heroui/use-resize

npm i https://pkg.pr.new/@heroui/use-resize@5195

@heroui/use-safe-layout-effect

npm i https://pkg.pr.new/@heroui/use-safe-layout-effect@5195

@heroui/use-scroll-position

npm i https://pkg.pr.new/@heroui/use-scroll-position@5195

@heroui/use-ssr

npm i https://pkg.pr.new/@heroui/use-ssr@5195

@heroui/use-theme

npm i https://pkg.pr.new/@heroui/use-theme@5195

@heroui/use-update-effect

npm i https://pkg.pr.new/@heroui/use-update-effect@5195

@heroui/aria-utils

npm i https://pkg.pr.new/@heroui/aria-utils@5195

@heroui/dom-animation

npm i https://pkg.pr.new/@heroui/dom-animation@5195

@heroui/framer-utils

npm i https://pkg.pr.new/@heroui/framer-utils@5195

@heroui/react-rsc-utils

npm i https://pkg.pr.new/@heroui/react-rsc-utils@5195

@heroui/react-utils

npm i https://pkg.pr.new/@heroui/react-utils@5195

@heroui/shared-icons

npm i https://pkg.pr.new/@heroui/shared-icons@5195

@heroui/shared-utils

npm i https://pkg.pr.new/@heroui/shared-utils@5195

@heroui/stories-utils

npm i https://pkg.pr.new/@heroui/stories-utils@5195

@heroui/test-utils

npm i https://pkg.pr.new/@heroui/test-utils@5195

commit: 5e37ea7

@wingkwong wingkwong added this to the v2.7.7 milestone Apr 23, 2025
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2025

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

Name Status Preview Comments Updated (UTC)
heroui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 23, 2025 5:44am
heroui-sb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 23, 2025 5:44am

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.

[BUG] - Custom theme reports an error when colors attribute is not specified

3 participants