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

refactor(colorpickers, grid, loaders, notifications, tags tooltips): use transient props where appropriate #1968

Merged
merged 17 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export const ColorWell: React.FC<IColorWellProps> = React.memo(
onMouseDown={handleMouseDown}
>
<StyledColorWellThumb
top={mouseActiveRef.current ? topFromMouse : topPosition}
left={mouseActiveRef.current ? leftFromMouse : leftPosition}
$top={mouseActiveRef.current ? topFromMouse : topPosition}
$left={mouseActiveRef.current ? leftFromMouse : leftPosition}
/>
</StyledColorWell>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { retrieveComponentStyles, getColor } from '@zendeskgarden/react-theming'
const COMPONENT_ID = 'colorpickers.colorpicker_colorwell_thumb';

interface IStyledSaturationPointerProps {
top: number;
left: number;
$top: number;
$left: number;
}

const colorStyles = ({ theme }: ThemeProps<DefaultTheme>) => {
Expand Down Expand Up @@ -45,8 +45,8 @@ export const StyledColorWellThumb = styled.div.attrs<IStyledSaturationPointerPro
'data-garden-version': PACKAGE_VERSION,
'data-test-id': 'colorwell-thumb',
style: {
top: `${props.top}%`,
left: `${props.left}%`
top: `${props.$top}%`,
left: `${props.$left}%`
}
}))<IStyledSaturationPointerProps>`
position: absolute;
Expand Down
92 changes: 79 additions & 13 deletions packages/grid/src/elements/Col.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,86 @@ import useGridContext from '../utils/useGridContext';
*
* @extends HTMLAttributes<HTMLDivElement>
*/
export const Col = React.forwardRef<HTMLDivElement, IColProps>(({ size, ...props }, ref) => {
const { columns, gutters, debug } = useGridContext();
export const Col = React.forwardRef<HTMLDivElement, IColProps>(
(
{
alignSelf,
alignSelfLg,
alignSelfMd,
alignSelfSm,
alignSelfXl,
alignSelfXs,
lg,
md,
offset,
offsetLg,
offsetMd,
offsetSm,
offsetXl,
offsetXs,
order,
orderLg,
orderMd,
orderSm,
orderXl,
orderXs,
size,
sm,
textAlign,
textAlignLg,
textAlignMd,
textAlignSm,
textAlignXl,
textAlignXs,
xl,
xs,
...other
},
ref
) => {
const { columns, gutters, debug } = useGridContext();

return (
<StyledCol
sizeAll={size}
columns={columns}
gutters={gutters}
debug={debug}
ref={ref}
{...props}
/>
);
});
return (
<StyledCol
$xs={xs}
$sm={sm}
$md={md}
$lg={lg}
$xl={xl}
$alignSelf={alignSelf}
$alignSelfXs={alignSelfXs}
$alignSelfSm={alignSelfSm}
$alignSelfMd={alignSelfMd}
$alignSelfLg={alignSelfLg}
$alignSelfXl={alignSelfXl}
$textAlign={textAlign}
$textAlignXs={textAlignXs}
$textAlignSm={textAlignSm}
$textAlignMd={textAlignMd}
$textAlignLg={textAlignLg}
$textAlignXl={textAlignXl}
$offset={offset}
$offsetXs={offsetXs}
$offsetSm={offsetSm}
$offsetMd={offsetMd}
$offsetLg={offsetLg}
$offsetXl={offsetXl}
$order={order}
$orderXs={orderXs}
$orderSm={orderSm}
$orderMd={orderMd}
$orderLg={orderLg}
$orderXl={orderXl}
$sizeAll={size}
$columns={columns}
$gutters={gutters}
$debug={debug}
ref={ref}
{...other}
/>
);
}
);

Col.displayName = 'Grid.Col';

Expand Down
58 changes: 54 additions & 4 deletions packages/grid/src/elements/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,61 @@ import { StyledRow } from '../styled';
*
* @extends HTMLAttributes<HTMLDivElement>
*/
export const Row = React.forwardRef<HTMLDivElement, IRowProps>(({ wrap, ...props }, ref) => {
const { gutters, debug } = useGridContext();
export const Row = React.forwardRef<HTMLDivElement, IRowProps>(
(
{
alignItems,
alignItemsXs,
alignItemsSm,
alignItemsMd,
alignItemsLg,
alignItemsXl,
justifyContent,
justifyContentXs,
justifyContentSm,
justifyContentMd,
justifyContentLg,
justifyContentXl,
wrap,
wrapXs,
wrapSm,
wrapMd,
wrapLg,
wrapXl,
...props
},
ref
) => {
const { gutters, debug } = useGridContext();

return <StyledRow gutters={gutters} debug={debug} wrapAll={wrap} ref={ref} {...props} />;
});
return (
<StyledRow
$gutters={gutters}
$debug={debug}
$alignItems={alignItems}
$alignItemsXs={alignItemsXs}
$alignItemsSm={alignItemsSm}
$alignItemsMd={alignItemsMd}
$alignItemsLg={alignItemsLg}
$alignItemsXl={alignItemsXl}
$justifyContent={justifyContent}
$justifyContentXs={justifyContentXs}
$justifyContentSm={justifyContentSm}
$justifyContentMd={justifyContentMd}
$justifyContentLg={justifyContentLg}
$justifyContentXl={justifyContentXl}
$wrapAll={wrap}
$wrapXs={wrapXs}
$wrapSm={wrapSm}
$wrapMd={wrapMd}
$wrapLg={wrapLg}
$wrapXl={wrapXl}
ref={ref}
{...props}
/>
);
}
);

Row.displayName = 'Grid.Row';

Expand Down
4 changes: 2 additions & 2 deletions packages/grid/src/elements/pane/components/Splitter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ const SplitterComponent = forwardRef<HTMLDivElement, ISplitterProps>(
)}
>
<StyledPaneSplitter
isFixed={isFixed}
orientation={orientation}
$isFixed={isFixed}
$orientation={orientation}
{...separatorProps}
{...props}
ref={mergeRefs([separatorRef, ref])}
Expand Down
10 changes: 5 additions & 5 deletions packages/grid/src/elements/pane/components/SplitterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const SplitterButtonComponent = forwardRef<HTMLButtonElement, ISplitterButtonPro

return (
<StyledPaneSplitterButtonContainer
orientation={orientation!}
placement={placement!}
splitterSize={size || 0}
$orientation={orientation!}
$placement={placement!}
$splitterSize={size || 0}
>
<Tooltip
content={label}
Expand All @@ -76,8 +76,8 @@ const SplitterButtonComponent = forwardRef<HTMLButtonElement, ISplitterButtonPro
<StyledPaneSplitterButton
aria-label={label}
{...props}
orientation={orientation!}
isRotated={isMin}
$orientation={orientation!}
$isRotated={isMin}
ref={ref}
onClick={onClick}
onKeyDown={onKeyDown}
Expand Down
Loading