From d43019cd42d6a7fd6176c82bbd7f5d1d4c60192d Mon Sep 17 00:00:00 2001 From: taysea Date: Wed, 23 Oct 2024 15:51:03 -0700 Subject: [PATCH 1/2] =?UTF-8?q?Select=20=E2=80=94=20Add=20theme.select.cle?= =?UTF-8?q?ar.container.hover?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/components/Select/SelectContainer.js | 13 +- .../Select/__tests__/Select-test.js | 52 ++ .../__snapshots__/Select-test.js.snap | 637 ++++++++++++++++++ src/js/themes/base.d.ts | 2 +- src/js/themes/base.js | 3 + 5 files changed, 703 insertions(+), 4 deletions(-) diff --git a/src/js/components/Select/SelectContainer.js b/src/js/components/Select/SelectContainer.js index fa528650e0b..a55ba1382fe 100644 --- a/src/js/components/Select/SelectContainer.js +++ b/src/js/components/Select/SelectContainer.js @@ -51,12 +51,19 @@ const ClearButton = forwardRef( ref={ref} onClick={onClear} focusIndicator={false} + plain {...passThemeFlag} {...rest} > - - {buttonLabel} - + {({ hover }) => ( + + {buttonLabel} + + )} ); }, diff --git a/src/js/components/Select/__tests__/Select-test.js b/src/js/components/Select/__tests__/Select-test.js index 572e4d19934..850007a03d3 100644 --- a/src/js/components/Select/__tests__/Select-test.js +++ b/src/js/components/Select/__tests__/Select-test.js @@ -1763,6 +1763,58 @@ describe('Select', () => { expect(onChange.mock.calls[0][0].value.type).toBe(Box); }); + test('renders custom clear selection styling', () => { + jest.useFakeTimers(); + const customTheme = { + select: { + clear: { + container: { + pad: { + vertical: '6px', + horizontal: '12px', + }, + background: undefined, + hover: { + background: 'blue', + }, + }, // any box props + text: { + color: 'text-strong', + weight: 600, + }, // any text props + }, + }, + }; + + const { asFragment, getByRole, getByPlaceholderText } = render( + + + + +
+ + + +
+ + + + +`; + +exports[`Select renders custom clear selection styling 2`] = ` +.c0 { + display: flex; + box-sizing: border-box; + max-width: 100%; + min-width: 0; + min-height: 0; + flex-direction: column; + overflow: auto; + box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.20); +} + +.c2 { + display: flex; + box-sizing: border-box; + max-width: 100%; + min-width: 0; + min-height: 0; + flex-direction: column; +} + +.c11 { + display: flex; + box-sizing: border-box; + max-width: 100%; + align-items: flex-start; + min-width: 0; + min-height: 0; + flex-direction: column; + padding: 12px; +} + +.c15 { + display: flex; + box-sizing: border-box; + max-width: 100%; + min-width: 0; + min-height: 0; + flex-direction: column; + height: 0px; + flex: 0 0 auto; +} + +.c6 { + display: flex; + box-sizing: border-box; + max-width: 100%; + align-items: flex-start; + background: blue; + min-width: 0; + min-height: 0; + flex-direction: column; + padding-left: 12px; + padding-right: 12px; + padding-top: 6px; + padding-bottom: 6px; +} + +.c1 { + font-size: 18px; + line-height: 24px; + box-sizing: border-box; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + border-radius: 0px; + position: fixed; + z-index: 20; + outline: none; + background-color: #FFFFFF; + color: #444444; + opacity: 0; + transform-origin: top left; + animation: kPQHBD 0.1s forwards; + animation-delay: 0.01s; +} + +.c7 { + font-size: 18px; + line-height: 24px; + color: #000000; + font-weight: 600; +} + +.c12 { + margin: 0px; + font-size: 18px; + line-height: 24px; +} + +.c9 { + display: inline-block; + box-sizing: border-box; + cursor: pointer; + font: inherit; + text-decoration: none; + margin: 0; + background: transparent; + overflow: visible; + text-transform: none; + color: inherit; + outline: none; + border: none; + padding: 0; + text-align: inherit; +} + +.c9:focus:not(:focus-visible) { + outline: none; + box-shadow: none; +} + +.c9:focus:not(:focus-visible) >circle, +.c9:focus:not(:focus-visible) >ellipse, +.c9:focus:not(:focus-visible) >line, +.c9:focus:not(:focus-visible) >path, +.c9:focus:not(:focus-visible) >polygon, +.c9:focus:not(:focus-visible) >polyline, +.c9:focus:not(:focus-visible) >rect { + outline: none; + box-shadow: none; +} + +.c9:focus:not(:focus-visible) ::-moz-focus-inner { + border: 0; +} + +.c13 { + display: inline-block; + box-sizing: border-box; + cursor: pointer; + font: inherit; + text-decoration: none; + margin: 0; + background: transparent; + overflow: visible; + text-transform: none; + color: inherit; + outline: none; + border: none; + padding: 0; + text-align: inherit; +} + +.c13:focus:not(:focus-visible) { + outline: none; + box-shadow: none; +} + +.c13:focus:not(:focus-visible) >circle, +.c13:focus:not(:focus-visible) >ellipse, +.c13:focus:not(:focus-visible) >line, +.c13:focus:not(:focus-visible) >path, +.c13:focus:not(:focus-visible) >polygon, +.c13:focus:not(:focus-visible) >polyline, +.c13:focus:not(:focus-visible) >rect { + outline: none; + box-shadow: none; +} + +.c13:focus:not(:focus-visible) ::-moz-focus-inner { + border: 0; +} + +.c4 { + display: inline-block; + box-sizing: border-box; + cursor: pointer; + font: inherit; + text-decoration: none; + margin: 0; + background: transparent; + overflow: visible; + text-transform: none; + color: inherit; + outline: none; + border: none; + padding: 0; + text-align: inherit; + width: 100%; +} + +.c4:focus:not(:focus-visible) { + outline: none; + box-shadow: none; +} + +.c4:focus:not(:focus-visible) >circle, +.c4:focus:not(:focus-visible) >ellipse, +.c4:focus:not(:focus-visible) >line, +.c4:focus:not(:focus-visible) >path, +.c4:focus:not(:focus-visible) >polygon, +.c4:focus:not(:focus-visible) >polyline, +.c4:focus:not(:focus-visible) >rect { + outline: none; + box-shadow: none; +} + +.c4:focus:not(:focus-visible) ::-moz-focus-inner { + border: 0; +} + +.c3 { + max-height: inherit; +} + +.c8 { + position: relative; + scroll-behavior: smooth; + overflow: auto; + outline: none; +} + +.c10 { + display: block; + width: 100%; +} + +.c14 { + background-color: #7D4CDB; + color: #FFFFFF; + display: block; + width: 100%; +} + +.c5:focus { + background-color: rgba(221, 221, 221, 0.4); + color: #000000; +} + +@media only screen and (max-width: 768px) { + +} + +@media only screen and (max-width: 768px) { + +} + +@media only screen and (max-width: 768px) { + +} + +@media only screen and (max-width: 768px) { + .c11 { + padding: 6px; + } +} + +@media only screen and (max-width: 768px) { + .c6 { + padding-left: 12px; + padding-right: 12px; + } +} + +@media only screen and (max-width: 768px) { + .c6 { + padding-top: 6px; + padding-bottom: 6px; + } +} + +@media screen and (-ms-high-contrast:active),(-ms-high-contrast:none) { + .c1 { + display: flex; + align-items: stretch; + } +} + +@media screen and (-ms-high-contrast:active),(-ms-high-contrast:none) { + .c3 { + width: 100%; + } +} + +
+
+ +
+ + + +
+
+
+
+`; + +exports[`Select renders custom clear selection styling 3`] = ` +"@media only screen and (max-width: 768px) { + .iWRaaC { + margin-left: 6px; + margin-right: 6px; + } +}" +`; + exports[`Select renders custom icon 1`] = ` .c9 { display: inline-block; diff --git a/src/js/themes/base.d.ts b/src/js/themes/base.d.ts index 17dd84ecfe8..c095a21327e 100644 --- a/src/js/themes/base.d.ts +++ b/src/js/themes/base.d.ts @@ -1449,7 +1449,7 @@ export interface ThemeType { select?: { background?: BackgroundType; clear?: { - container?: BoxProps; + container?: BoxProps & { hover?: BoxProps }; text?: TextProps; }; container?: { diff --git a/src/js/themes/base.js b/src/js/themes/base.js index da96ac5e52b..30233d43230 100644 --- a/src/js/themes/base.js +++ b/src/js/themes/base.js @@ -1686,6 +1686,9 @@ export const generate = (baseSpacing = 24, scale = 6) => { container: { pad: 'small', background: 'background-contrast', + // hover: { + // // any box props + // }, }, // any box props text: { color: 'text-weak', From 8c971bee3a9af7db351817d030870ff43e7202fd Mon Sep 17 00:00:00 2001 From: taysea Date: Thu, 24 Oct 2024 14:23:45 -0700 Subject: [PATCH 2/2] Avoid passing hover object to Box --- src/js/components/Select/SelectContainer.js | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/js/components/Select/SelectContainer.js b/src/js/components/Select/SelectContainer.js index a55ba1382fe..58743a2f331 100644 --- a/src/js/components/Select/SelectContainer.js +++ b/src/js/components/Select/SelectContainer.js @@ -55,15 +55,19 @@ const ClearButton = forwardRef( {...passThemeFlag} {...rest} > - {({ hover }) => ( - - {buttonLabel} - - )} + {({ hover }) => { + const boxProps = { ...theme.select.clear.container }; + delete boxProps.hover; // avoid passing hover object to Box + return ( + + {buttonLabel} + + ); + }} ); },