Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(theme): improving component customization using twMerge #800

Closed
wants to merge 15 commits into from

Conversation

rluders
Copy link
Collaborator

@rluders rluders commented Jun 8, 2023

Description

Users normally get confused about the need to use ! to overwrite the theme classes when using className= property. This PR includes tailwind-merge that handles the conflicts instead of using classNames.

Example:

<Badge className="bg-red-500">A badge with custom background</Badge>

What this PR does:

<span class="flex h-fit items-center gap-1 font-semibold text-cyan-800 dark:bg-cyan-200 dark:text-cyan-800 group-hover:bg-cyan-200 dark:group-hover:bg-cyan-300 rounded p-1 text-xs bg-cyan-500" data-testid="flowbite-badge"><span>Default</span></span>

Current state:

<span class="flex h-fit items-center gap-1 font-semibold bg-cyan-100 text-cyan-800 dark:bg-cyan-200 dark:text-cyan-800 group-hover:bg-cyan-200 dark:group-hover:bg-cyan-300 rounded p-1 text-xs bg-red-500" data-testid="flowbite-badge"><span>Default</span></span>

Fixes # (issue)

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not

Breaking changes

  • By removing the classname library and introducing the tailwind-merge it means that theme-per-component will not require to use !important anymore, the same applies to className prop.
  • If you are using custom theme, it can cause some small issues, better to test and make sure that everything is working.
  • FlowbiteAvatarImageTheme now has a base style.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit test
  • Manual testing

Test Configuration:

N/A

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@rluders rluders added 🚀 enhancement New feature or request discussion It is not a bug or an enhancement labels Jun 8, 2023
@vercel
Copy link

vercel bot commented Jun 8, 2023

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

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2023 10:29pm

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (759aa76) 99.54% compared to head (be1fc1d) 99.54%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #800   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files         129      163   +34     
  Lines        6539     6621   +82     
  Branches      391      401   +10     
=======================================
+ Hits         6509     6591   +82     
  Misses         30       30           
Impacted Files Coverage Δ
src/components/Accordion/Accordion.tsx 100.00% <100.00%> (ø)
src/components/Accordion/AccordionContent.tsx 100.00% <100.00%> (ø)
src/components/Accordion/AccordionTitle.tsx 100.00% <100.00%> (ø)
src/components/Accordion/theme.ts 100.00% <100.00%> (ø)
src/components/Alert/Alert.tsx 100.00% <100.00%> (ø)
src/components/Alert/theme.ts 100.00% <100.00%> (ø)
src/components/Avatar/Avatar.tsx 100.00% <100.00%> (ø)
src/components/Avatar/AvatarGroup.tsx 100.00% <100.00%> (ø)
src/components/Avatar/AvatarGroupCounter.tsx 100.00% <100.00%> (ø)
src/components/Avatar/theme.ts 100.00% <100.00%> (ø)
... and 103 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@rluders rluders force-pushed the feat/theme-tw-merge branch from 04aa4a2 to fd6c964 Compare June 12, 2023 11:54
@rluders rluders changed the title [PoC] feat: improving component customization using twMerge feat: improving component customization using twMerge Jun 14, 2023
@rluders rluders marked this pull request as ready for review June 14, 2023 14:12
@rluders rluders requested a review from tulup-conner June 14, 2023 14:12
@rluders rluders force-pushed the feat/theme-tw-merge branch from 3e609c1 to a303dac Compare June 15, 2023 14:12
@rluders rluders changed the title feat: improving component customization using twMerge feat(theme): improving component customization using twMerge Jun 15, 2023
@rluders rluders removed the discussion It is not a bug or an enhancement label Jun 16, 2023
@tulup-conner tulup-conner added this to the 1.0.0 milestone Jun 20, 2023
Copy link
Collaborator

@tulup-conner tulup-conner left a comment

Choose a reason for hiding this comment

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

Could you also do me a favor and replace the classnames usage in app/components/code-preview.tsx and app/docs/layout.tsx to tailwind-merge?

src/components/Sidebar/SidebarLogo.tsx Show resolved Hide resolved
src/components/Table/TableCell.tsx Show resolved Hide resolved
@tulup-conner
Copy link
Collaborator

Moved to #816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants