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

feat(component): rename popover offset props and defaults #447

Merged
merged 2 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions packages/big-design/src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface PopoverProps extends BoxPropsWithoutMargins {
isOpen: boolean;
label: string;
matchAnchorElementWidth?: boolean;
offsetX?: number;
offsetY?: number;
skidding?: number;
distance?: number;
onClose?(): void;
placement?: Placement;
}
Expand Down Expand Up @@ -58,8 +58,8 @@ const InternalPopover: React.FC<InternalPopoverProps> = ({
id,
label,
matchAnchorElementWidth = false,
offsetX = 0,
offsetY = 0,
skidding = 0,
distance = 4,
onClose = () => null,
placement = 'auto',
role,
Expand All @@ -73,7 +73,7 @@ const InternalPopover: React.FC<InternalPopoverProps> = ({
{
name: 'offset',
options: {
offset: [offsetX, offsetY],
offset: [skidding, distance],
},
},
{
Expand All @@ -93,7 +93,7 @@ const InternalPopover: React.FC<InternalPopoverProps> = ({
},
} as Modifier<unknown, unknown>,
],
[offsetX, offsetY, matchAnchorElementWidth],
[skidding, distance, matchAnchorElementWidth],
);

const { styles, attributes } = usePopper(anchorElement, popperElement, {
Expand Down
2 changes: 1 addition & 1 deletion packages/big-design/src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Tooltip: React.FC<TooltipProps> = memo(({ children, inline = true,

return [
{ name: 'eventListeners', options: { scroll: isVisible, resize: isVisible } },
{ name: 'offset', options: { offset: [0, 8] } },
{ name: 'offset', options: { offset: [0, 4] } },
...mods,
];
}, [isVisible, modifiers]);
Expand Down
8 changes: 4 additions & 4 deletions packages/docs/PropTables/PopoverPropTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ const popoverProps: Prop[] = [
description: 'If set to true, the Popover will have the same width as its anchor element.',
},
{
name: 'offsetX',
name: 'skidding',
types: 'number',
defaultValue: '0',
description: 'Determines the popover offset on the X axis.',
description: 'Determines the offset along the anchorElement.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍹 I'd specify the direction of the offset, eg for skidding Determines the horizontal offset along the anchorElement
and for distance I'd say Determines the vertical offset along the anchorElement. I think it's a bit more clear

Copy link
Member Author

@deini deini Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, there is no concept of horizontal/vertical since a Popover can be placed in any direction (top, right, etc).

},
{
name: 'offsetY',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you rename this to distance also?

types: 'number',
defaultValue: '0',
description: 'Determines the popover offset on the Y axis.',
defaultValue: '4',
description: 'Determines the offset away from the anchorElement.',
},
{
name: 'onClose',
Expand Down