Skip to content

Commit 8fb3a2b

Browse files
committed
fix(pixels): fix Button extend by using same tailwind-merge and tailwind-variants version of theme
1 parent 8f3bf4c commit 8fb3a2b

File tree

23 files changed

+248
-265
lines changed

23 files changed

+248
-265
lines changed

packages/pixel-utils/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040
"build": "tsup --config node_modules/@repo/tsup-config/config.ts",
4141
"prepack": "pnpm build"
4242
},
43+
"peerDependencies": {
44+
"tailwind-merge": "*",
45+
"tailwind-variants": "*"
46+
},
4347
"dependencies": {
4448
"@heroui/theme": "2.4.20",
4549
"classnames": "2.5.1",
46-
"slug": "9.1.0",
47-
"tailwind-merge": "3.3.1",
48-
"tailwind-variants": "3.1.1"
50+
"slug": "9.1.0"
4951
},
5052
"devDependencies": {
5153
"@types/slug": "5.0.9"

packages/pixels/src/Alert/__snapshots__/Alert.test.tsx.snap

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
115115
faded
116116
</div>
117117
<div
118-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium border-info-200 bg-info-50 text-info-600 dark:border-info-100 dark:bg-info-50/50"
118+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small border-info-200 bg-info-50 text-info-600 dark:border-info-100 dark:bg-info-50/50"
119119
data-has-description="true"
120120
data-has-title="true"
121121
data-visible="true"
@@ -163,7 +163,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
163163
bordered
164164
</div>
165165
<div
166-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-info text-info"
166+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium bg-transparent border-small border-info text-info"
167167
data-has-description="true"
168168
data-has-title="true"
169169
data-visible="true"
@@ -316,7 +316,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
316316
faded
317317
</div>
318318
<div
319-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-default-100 dark:bg-default-50/50 text-default-foreground border-default-300 dark:border-default-200"
319+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-default-100 dark:bg-default-50/50 text-default-foreground border-default-300 dark:border-default-200"
320320
data-has-description="true"
321321
data-has-title="true"
322322
data-visible="true"
@@ -364,7 +364,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
364364
bordered
365365
</div>
366366
<div
367-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-default text-foreground"
367+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-transparent border-default text-foreground"
368368
data-has-description="true"
369369
data-has-title="true"
370370
data-visible="true"
@@ -517,7 +517,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
517517
faded
518518
</div>
519519
<div
520-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-primary-600 bg-primary-50 dark:bg-primary-50/50 border-primary-200 dark:border-primary-100"
520+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-primary-600 bg-primary-50 dark:bg-primary-50/50 border-primary-200 dark:border-primary-100"
521521
data-has-description="true"
522522
data-has-title="true"
523523
data-visible="true"
@@ -565,7 +565,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
565565
bordered
566566
</div>
567567
<div
568-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-primary text-primary"
568+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-transparent border-primary text-primary"
569569
data-has-description="true"
570570
data-has-title="true"
571571
data-visible="true"
@@ -718,7 +718,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
718718
faded
719719
</div>
720720
<div
721-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-secondary-600 bg-secondary-50 dark:bg-secondary-50/50 border-secondary-200"
721+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-secondary-600 bg-secondary-50 dark:bg-secondary-50/50 border-secondary-200"
722722
data-has-description="true"
723723
data-has-title="true"
724724
data-visible="true"
@@ -766,7 +766,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
766766
bordered
767767
</div>
768768
<div
769-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-secondary text-secondary"
769+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-transparent border-secondary text-secondary"
770770
data-has-description="true"
771771
data-has-title="true"
772772
data-visible="true"
@@ -929,7 +929,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
929929
faded
930930
</div>
931931
<div
932-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-success-700 dark:text-success bg-success-50 dark:bg-success-50/50 border-success-300 dark:border-success-100"
932+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-success-700 dark:text-success bg-success-50 dark:bg-success-50/50 border-success-300 dark:border-success-100"
933933
data-has-description="true"
934934
data-has-title="true"
935935
data-visible="true"
@@ -982,7 +982,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
982982
bordered
983983
</div>
984984
<div
985-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-success text-success"
985+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-transparent border-success text-success"
986986
data-has-description="true"
987987
data-has-title="true"
988988
data-visible="true"
@@ -1146,7 +1146,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
11461146
faded
11471147
</div>
11481148
<div
1149-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-warning-700 dark:text-warning bg-warning-50 dark:bg-warning-50/50 border-warning-300 dark:border-warning-100"
1149+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-warning-700 dark:text-warning bg-warning-50 dark:bg-warning-50/50 border-warning-300 dark:border-warning-100"
11501150
data-has-description="true"
11511151
data-has-title="true"
11521152
data-visible="true"
@@ -1197,7 +1197,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
11971197
bordered
11981198
</div>
11991199
<div
1200-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-warning text-warning"
1200+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-transparent border-warning text-warning"
12011201
data-has-description="true"
12021202
data-has-title="true"
12031203
data-visible="true"
@@ -1353,7 +1353,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
13531353
faded
13541354
</div>
13551355
<div
1356-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-danger-600 dark:text-danger-500 bg-danger-50 dark:bg-danger-50/50 border-danger-200 dark:border-danger-100"
1356+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-danger-600 dark:text-danger-500 bg-danger-50 dark:bg-danger-50/50 border-danger-200 dark:border-danger-100"
13571357
data-has-description="true"
13581358
data-has-title="true"
13591359
data-visible="true"
@@ -1401,7 +1401,7 @@ exports[`Story Snapshots > AllColorsAndVariants 1`] = `
14011401
bordered
14021402
</div>
14031403
<div
1404-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-danger text-danger"
1404+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-transparent border-danger text-danger"
14051405
data-has-description="true"
14061406
data-has-title="true"
14071407
data-visible="true"
@@ -1453,7 +1453,7 @@ exports[`Story Snapshots > AllColorsWithShowMoreButton 1`] = `
14531453
info
14541454
</div>
14551455
<div
1456-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium border-info-200 bg-info-50 text-info-600 dark:border-info-100 dark:bg-info-50/50"
1456+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small border-info-200 bg-info-50 text-info-600 dark:border-info-100 dark:bg-info-50/50"
14571457
data-has-description="true"
14581458
data-has-title="true"
14591459
data-visible="true"
@@ -1505,7 +1505,7 @@ exports[`Story Snapshots > AllColorsWithShowMoreButton 1`] = `
15051505
default
15061506
</div>
15071507
<div
1508-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-default-100 dark:bg-default-50/50 text-default-foreground border-default-300 dark:border-default-200"
1508+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-default-100 dark:bg-default-50/50 text-default-foreground border-default-300 dark:border-default-200"
15091509
data-has-description="true"
15101510
data-has-title="true"
15111511
data-visible="true"
@@ -1557,7 +1557,7 @@ exports[`Story Snapshots > AllColorsWithShowMoreButton 1`] = `
15571557
primary
15581558
</div>
15591559
<div
1560-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-primary-600 bg-primary-50 dark:bg-primary-50/50 border-primary-200 dark:border-primary-100"
1560+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-primary-600 bg-primary-50 dark:bg-primary-50/50 border-primary-200 dark:border-primary-100"
15611561
data-has-description="true"
15621562
data-has-title="true"
15631563
data-visible="true"
@@ -1609,7 +1609,7 @@ exports[`Story Snapshots > AllColorsWithShowMoreButton 1`] = `
16091609
secondary
16101610
</div>
16111611
<div
1612-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-secondary-600 bg-secondary-50 dark:bg-secondary-50/50 border-secondary-200"
1612+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-secondary-600 bg-secondary-50 dark:bg-secondary-50/50 border-secondary-200"
16131613
data-has-description="true"
16141614
data-has-title="true"
16151615
data-visible="true"
@@ -1661,7 +1661,7 @@ exports[`Story Snapshots > AllColorsWithShowMoreButton 1`] = `
16611661
success
16621662
</div>
16631663
<div
1664-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-success-700 dark:text-success bg-success-50 dark:bg-success-50/50 border-success-300 dark:border-success-100"
1664+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-success-700 dark:text-success bg-success-50 dark:bg-success-50/50 border-success-300 dark:border-success-100"
16651665
data-has-description="true"
16661666
data-has-title="true"
16671667
data-visible="true"
@@ -1718,7 +1718,7 @@ exports[`Story Snapshots > AllColorsWithShowMoreButton 1`] = `
17181718
warning
17191719
</div>
17201720
<div
1721-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-warning-700 dark:text-warning bg-warning-50 dark:bg-warning-50/50 border-warning-300 dark:border-warning-100"
1721+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-warning-700 dark:text-warning bg-warning-50 dark:bg-warning-50/50 border-warning-300 dark:border-warning-100"
17221722
data-has-description="true"
17231723
data-has-title="true"
17241724
data-visible="true"
@@ -1773,7 +1773,7 @@ exports[`Story Snapshots > AllColorsWithShowMoreButton 1`] = `
17731773
danger
17741774
</div>
17751775
<div
1776-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-danger-600 dark:text-danger-500 bg-danger-50 dark:bg-danger-50/50 border-danger-200 dark:border-danger-100"
1776+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-danger-600 dark:text-danger-500 bg-danger-50 dark:bg-danger-50/50 border-danger-200 dark:border-danger-100"
17771777
data-has-description="true"
17781778
data-has-title="true"
17791779
data-visible="true"
@@ -2014,7 +2014,7 @@ exports[`Story Snapshots > Closable 1`] = `
20142014
faded
20152015
</div>
20162016
<div
2017-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium border-info-200 bg-info-50 text-info-600 dark:border-info-100 dark:bg-info-50/50"
2017+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small border-info-200 bg-info-50 text-info-600 dark:border-info-100 dark:bg-info-50/50"
20182018
data-closeable="true"
20192019
data-has-description="true"
20202020
data-has-title="true"
@@ -2087,7 +2087,7 @@ exports[`Story Snapshots > Closable 1`] = `
20872087
bordered
20882088
</div>
20892089
<div
2090-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-info text-info"
2090+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium bg-transparent border-small border-info text-info"
20912091
data-closeable="true"
20922092
data-has-description="true"
20932093
data-has-title="true"
@@ -2492,7 +2492,7 @@ exports[`Story Snapshots > NoIcon 1`] = `
24922492
faded
24932493
</div>
24942494
<div
2495-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium text-primary-600 bg-primary-50 dark:bg-primary-50/50 border-primary-200 dark:border-primary-100"
2495+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small text-primary-600 bg-primary-50 dark:bg-primary-50/50 border-primary-200 dark:border-primary-100"
24962496
data-has-description="true"
24972497
data-has-title="true"
24982498
data-visible="true"
@@ -2538,7 +2538,7 @@ exports[`Story Snapshots > NoIcon 1`] = `
25382538
bordered
25392539
</div>
25402540
<div
2541-
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 border-small rounded-medium bg-transparent border-primary text-primary"
2541+
class="flex flex-grow flex-row w-full items-center py-3 px-4 gap-x-1 rounded-medium border-small bg-transparent border-primary text-primary"
25422542
data-has-description="true"
25432543
data-has-title="true"
25442544
data-visible="true"

packages/pixels/src/Button/Button.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { TVProps } from '@fuf-stack/pixel-utils';
12
import type { ButtonProps as HeroButtonProps } from '@heroui/button';
23
import type { ReactNode } from 'react';
34

@@ -8,11 +9,7 @@ import { tv } from '@fuf-stack/pixel-utils';
89

910
import LoadingSpinner from './subcomponents/LoadingSpinner';
1011

11-
const tvConfig = <T extends Parameters<typeof tv>[0]>(c: T) => {
12-
return c;
13-
};
14-
15-
const buttonVariantsConfig = tvConfig({
12+
export const buttonVariants = tv({
1613
extend: heroButtonVariants,
1714
variants: {
1815
color: {
@@ -85,17 +82,17 @@ const buttonVariantsConfig = tvConfig({
8582
],
8683
});
8784

88-
export const buttonVariants: ReturnType<typeof tv> = tv(buttonVariantsConfig);
85+
type VariantProps = TVProps<typeof buttonVariants>;
8986

90-
export interface ButtonProps {
87+
export interface ButtonProps extends VariantProps {
9188
/** sets HTML aria-label attribute */
9289
ariaLabel?: string;
9390
/** content of the button */
9491
children?: ReactNode;
9592
/** CSS class name */
9693
className?: string;
9794
/** color of the button */
98-
color?: HeroButtonProps['color'] | 'info';
95+
color?: VariantProps['color'];
9996
/** disables the button */
10097
disabled?: boolean;
10198
/** disables all animations */
@@ -107,17 +104,17 @@ export interface ButtonProps {
107104
/** click event handler */
108105
onClick?: HeroButtonProps['onPress'];
109106
/** border radius size */
110-
radius?: HeroButtonProps['radius'];
107+
radius?: VariantProps['radius'];
111108
/** enable ripple animation effect on click */
112109
ripple?: boolean;
113110
/** size options */
114-
size?: HeroButtonProps['size'];
111+
size?: VariantProps['size'];
115112
/** HTML data-testid attribute used in e2e tests */
116113
testId?: string;
117114
/** HTML button type attribute */
118115
type?: 'button' | 'submit' | 'reset' | undefined;
119116
/** visual style variant */
120-
variant?: HeroButtonProps['variant'];
117+
variant?: VariantProps['variant'];
121118
}
122119

123120
/**

0 commit comments

Comments
 (0)