Skip to content

Commit f097e35

Browse files
authored
refactor(colorpickers, grid, loaders, notifications, tags, tooltips): use transient props where appropriate (#1968)
1 parent a50689f commit f097e35

File tree

59 files changed

+603
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+603
-412
lines changed

packages/.template/src/styled/Styled{{capitalize component}}.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const colorStyles = (props: IStyled{{capitalize component}}Props) => {
2828
background-color: ${backgroundColor};
2929
color: ${foregroundColor};
3030
31-
:hover {
31+
&:hover {
3232
background-color: ${hoverBackgroundColor};
3333
}
3434
@@ -65,7 +65,7 @@ export const Styled{{capitalize component}} = styled.div.attrs<IStyled{{capitali
6565
6666
${props => sizeStyles(props)};
6767
68-
:focus {
68+
&:focus {
6969
outline: none;
7070
}
7171

packages/avatars/src/elements/Avatar.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ import { Text } from './components/Text';
2121
const AvatarComponent = forwardRef<HTMLElement, IAvatarProps>(
2222
(
2323
{
24+
backgroundColor,
25+
badge,
26+
children,
27+
foregroundColor,
2428
isSystem,
2529
size,
2630
status,
27-
children,
28-
badge,
31+
statusLabel,
2932
surfaceColor,
30-
backgroundColor,
31-
foregroundColor,
32-
...props
33+
...other
3334
},
3435
ref
3536
) => {
@@ -59,9 +60,9 @@ const AvatarComponent = forwardRef<HTMLElement, IAvatarProps>(
5960
}, [computedStatus, badge]);
6061

6162
const shouldValidate = computedStatus !== undefined;
62-
const statusLabel = useText(
63+
const ariaLabel = useText(
6364
AvatarComponent,
64-
props,
65+
{ statusLabel },
6566
'statusLabel',
6667
defaultStatusLabel,
6768
shouldValidate
@@ -78,15 +79,15 @@ const AvatarComponent = forwardRef<HTMLElement, IAvatarProps>(
7879
$foregroundColor={foregroundColor}
7980
aria-atomic="true"
8081
aria-live="polite"
81-
{...props}
82+
{...other}
8283
>
8384
{Children.only(children)}
8485
{!!computedStatus && (
8586
<StyledStatusIndicator
8687
$size={size}
8788
$type={computedStatus}
8889
$surfaceColor={surfaceColor}
89-
aria-label={statusLabel}
90+
aria-label={ariaLabel}
9091
as="figcaption"
9192
>
9293
{computedStatus === 'active' ? (

packages/chrome/src/styled/body/StyledMain.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const StyledMain = styled.main.attrs({
1919
background-color: ${props => getColor({ theme: props.theme, variable: 'background.default' })};
2020
overflow: auto;
2121
22-
:focus {
22+
&:focus {
2323
outline: none;
2424
}
2525

packages/colorpickers/src/elements/ColorPicker/ColorWell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export const ColorWell: React.FC<IColorWellProps> = React.memo(
9797
onMouseDown={handleMouseDown}
9898
>
9999
<StyledColorWellThumb
100-
top={mouseActiveRef.current ? topFromMouse : topPosition}
101-
left={mouseActiveRef.current ? leftFromMouse : leftPosition}
100+
$top={mouseActiveRef.current ? topFromMouse : topPosition}
101+
$left={mouseActiveRef.current ? leftFromMouse : leftPosition}
102102
/>
103103
</StyledColorWell>
104104
);

packages/colorpickers/src/styled/ColorPicker/StyledColorWellThumb.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { retrieveComponentStyles, getColor } from '@zendeskgarden/react-theming'
1212
const COMPONENT_ID = 'colorpickers.colorpicker_colorwell_thumb';
1313

1414
interface IStyledSaturationPointerProps {
15-
top: number;
16-
left: number;
15+
$top: number;
16+
$left: number;
1717
}
1818

1919
const colorStyles = ({ theme }: ThemeProps<DefaultTheme>) => {
@@ -45,8 +45,8 @@ export const StyledColorWellThumb = styled.div.attrs<IStyledSaturationPointerPro
4545
'data-garden-version': PACKAGE_VERSION,
4646
'data-test-id': 'colorwell-thumb',
4747
style: {
48-
top: `${props.top}%`,
49-
left: `${props.left}%`
48+
top: `${props.$top}%`,
49+
left: `${props.$left}%`
5050
}
5151
}))<IStyledSaturationPointerProps>`
5252
position: absolute;

packages/colorpickers/src/styled/ColorPicker/StyledHexField.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const COMPONENT_ID = 'colorpickers.colorpicker_hex_field';
1717
export const StyledHexField = styled(Field as unknown as 'div').attrs({
1818
'data-garden-id': COMPONENT_ID,
1919
'data-garden-version': PACKAGE_VERSION,
20-
spellcheck: false
20+
spellCheck: false
2121
})`
2222
display: flex;
2323
flex-basis: 0; /* [1] */

packages/datepickers/src/styled/StyledHeaderPaddle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ const colorStyles = ({ theme }: ThemeProps<DefaultTheme>) => {
5656
return css`
5757
color: ${foreground};
5858
59-
:hover {
59+
&:hover {
6060
background-color: ${backgroundHover};
6161
color: ${foregroundHover};
6262
}
6363
64-
:active {
64+
&:active {
6565
background-color: ${backgroundActive};
6666
color: ${foregroundActive};
6767
}

packages/dropdowns.legacy/src/elements/Autocomplete/Autocomplete.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const Autocomplete = forwardRef<HTMLDivElement, IAutocompleteProps>(
111111
{!isOpen && <StyledSelect>{children}</StyledSelect>}
112112
<StyledInput
113113
{...getInputProps({
114-
isHidden: !isOpen,
114+
$isHidden: !isOpen,
115115
disabled: props.disabled,
116116
onFocus: () => {
117117
setIsFocused(true);

packages/dropdowns.legacy/src/elements/Menu/Items/HeaderIcon.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77

88
import React, { HTMLAttributes } from 'react';
99
import { StyledHeaderIcon } from '../../../styled';
10-
import useMenuContext from '../../../utils/useMenuContext';
1110

1211
/**
1312
* @extends HTMLAttributes<HTMLDivElement>
1413
*/
1514
export const HeaderIcon = React.forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
1615
(props, ref) => {
17-
const { isCompact } = useMenuContext();
18-
19-
return <StyledHeaderIcon ref={ref} isCompact={isCompact} {...props} />;
16+
return <StyledHeaderIcon ref={ref} {...props} />;
2017
}
2118
);
2219

packages/dropdowns.legacy/src/elements/Multiselect/Multiselect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export const Multiselect = React.forwardRef<HTMLDivElement, IMultiselectProps>(
373373
}
374374
}
375375
},
376-
isVisible: isFocused || inputValue || selectedItems.length === 0,
376+
$isVisible: isFocused || inputValue || selectedItems.length === 0,
377377
isCompact: props.isCompact,
378378
role: 'combobox',
379379
ref: mergeRefs([inputRef, externalInputRef]),

0 commit comments

Comments
 (0)