From 4b3d867e37abd0a23014b01cd89ada610a03ba66 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 12 Jul 2024 10:54:44 +0100 Subject: [PATCH] Add subtle-bg variant to IconButton To match Figma https://www.figma.com/design/rTaQE2nIUSLav4Tg3nozq7/Compound-Web-Components?node-id=656-7159&t=YyxhzkrG2nuC13Zk-1 --- ...ith-Subtle-Background-1-chromium-linux.png | Bin 0 -> 5328 bytes .../Button/IconButton/IconButton.module.css | 5 +++ .../Button/IconButton/IconButton.stories.tsx | 5 +++ .../Button/IconButton/IconButton.test.tsx | 5 +++ .../Button/IconButton/IconButton.tsx | 3 ++ .../__snapshots__/IconButton.test.tsx.snap | 36 ++++++++++++++++++ 6 files changed, 54 insertions(+) create mode 100644 playwright/visual.test.ts-snapshots/Button-IconButton-With-Subtle-Background-1-chromium-linux.png diff --git a/playwright/visual.test.ts-snapshots/Button-IconButton-With-Subtle-Background-1-chromium-linux.png b/playwright/visual.test.ts-snapshots/Button-IconButton-With-Subtle-Background-1-chromium-linux.png new file mode 100644 index 0000000000000000000000000000000000000000..8efb7dfc7cdd9d84809ab60b64e177e74c091608 GIT binary patch literal 5328 zcmeI0{a4ai9>*^_TT`iYrXAfPp`A{#t=ZG0m58?0Xb-Da`bEnWciqHir-P`0Voj%Z z%Y*LpAnQZX!-VlAFh|jh0J9vMOwkCwr2#&M^3{+KEJt8zAO3>Y(-(-(yPGn!mnHK!6{L1LsLtn zZ<(+%WgY;?FKW)PF#vp^e{~%LR;~J9&8GX6ml#q@(7=?Yy|~_&DKlD`5TxE3C8_2g z^^Eey`e+6R+m6b80VqBmWs2?)UrdG=A&u&)sR%_D7E6(mk9EVc z>nJ!WRKNT%zE^TI%m~2XqX~4wN?EdKe<;FjFJ>rSEdZxjD7tt?B&e!ZbkcAZi^UpF zC^<&!sTCfG7i%~*EwF&EDNTLYoUMzK7EawI;`K=)&HJSAO}#K9b+w&&9Du*g1iIp+ z2dSzOZH~@5r5fiv`9rSmAwzj0_%4+iUSu6({>5NB&Rd>=g;+)D-Ja z9ZzLg5sEFo?QkR+HR9mf< z-Qi-p>$>bv#E0Rl~QwFKWq>uE0XJ?OTXy$b_II814CBan`veccwvbU z^vkuAMzJzj7rN!prC623(3fPz);n|T!zLf~h?F2mycBD#S-q@G859-E;yG+n4L$4q zd%OO7l3*EQ*{HN-x}fWa6edPrC3J>S7|ymcsZ zmy=pbg)poOou>q@U;nbbeV6_1(*X#wJ}sAGV~$Lw26Vd=6?M1BubiJzd2A7$fD>gQ z2IGsdfFOBR=dcy=ktY~>sCQ<=w?n4VZ!^tv56lfr>)?_?&I$8-1N9A#T96As!U0#h zb0wAKuSAK#@g)<9`Qy_inQTWz;p3uwq@3wI6KjI0B#`JBwx@zL(&)66>&2J;3&O*>< z5}bM>AI_-mZ?z9Ghs{aW(QBPB`Gt6O9-$t$jhHoZ&Rb$=NIK9%-a5MUOP5k8D)ceM z7s-nbJZYbKZLunyHj}FgXGt*{laBoH%1^Af0wOwV(z0!|zp~>hvC?|aKScR=&_cyT*sS{a&Httu+(4B4*N~+3p^hF-qw3T=Lf*M zNWI4c*!XsIhFpQXD=?sEVhPBE%7DJV62KVIh%#Y;6-Cs|fmpTp>OhtItR?Mf-Q^Had&}KvPmyIo1AA>o{Lh&2{YiJ z-j~yZDc(LIH*w%peO-{Zi { @@ -55,4 +56,8 @@ describe("IconButton", () => { const { container } = render(); expect(container).toMatchSnapshot(); }); + it("renders a WithSubtleBackground IconButton", () => { + const { container } = render(); + expect(container).toMatchSnapshot(); + }); }); diff --git a/src/components/Button/IconButton/IconButton.tsx b/src/components/Button/IconButton/IconButton.tsx index 87bc92ff..4c8f7840 100644 --- a/src/components/Button/IconButton/IconButton.tsx +++ b/src/components/Button/IconButton/IconButton.tsx @@ -53,6 +53,7 @@ type IconButtonProps = UnstyledButtonPropsFor<"button"> & * Optional tooltip for the button */ tooltip?: string; + subtleBackground?: boolean; }; /** @@ -71,12 +72,14 @@ export const IconButton = forwardRef< disabled, destructive, tooltip, + subtleBackground, ...props }, ref, ) { const classes = classnames(styles["icon-button"], className, { [styles.destructive]: destructive, + [styles["subtle-bg"]]: subtleBackground, }); const button = ( diff --git a/src/components/Button/IconButton/__snapshots__/IconButton.test.tsx.snap b/src/components/Button/IconButton/__snapshots__/IconButton.test.tsx.snap index b1cadf39..e6182686 100644 --- a/src/components/Button/IconButton/__snapshots__/IconButton.test.tsx.snap +++ b/src/components/Button/IconButton/__snapshots__/IconButton.test.tsx.snap @@ -186,6 +186,42 @@ exports[`IconButton > renders a WithIndicatorDisabled IconButton 1`] = ` `; +exports[`IconButton > renders a WithSubtleBackground IconButton 1`] = ` +
+ +
+`; + exports[`IconButton > renders a WithSuccessIndicator IconButton 1`] = `