Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 18 additions & 16 deletions src/components/SharePopover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ Sharing component

### PropTypes

| Property | Type | Required | Default | Description |
| :--------------- | :-------------------- | :------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url | `String` | ✔ | | share link |
| title | `String` | | | link title |
| text | `String` | | | link text |
| shareOptions | `Array<ShareOptions>` | | `[]` | share options list |
| withCopyLink | `Boolean` | | `true` | display copy button |
| useWebShareApi | `Boolean` | | `false` | [Web Share API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) usage setting. If turned on default share dialog will be shown (if bbrowser supports it) |
| placement | `Array` | | `['bottom-end']` | tooltip openening direction |
| openByHover | `Boolean` | | `true` | should open tooltip with hover |
| autoclosable | `Boolean` | | `true` | should close tooltip when cursor is outside |
| closeDelay | `Number` | | `300` | delay before tooltip will be hidden when cursor is otside |
| iconSize | `Number` | | | icon-control size |
| iconClass | `String` | | | icon-control mixin |
| tooltipClassName | `String` | | | tooltip mixin |
| className | `String` | | | css class for control |
| Property | Type | Required | Default | Description |
| :--------------- | :---------------------------------------------- | :------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url | `String` | ✔ | | share link |
| title | `String` | | | link title |
| text | `String` | | | link text |
| shareOptions | `Array<ShareOptions>` | | `[]` | share options list |
| withCopyLink | `Boolean` | | `true` | display copy button |
| useWebShareApi | `Boolean` | | `false` | [Web Share API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) usage setting. If turned on default share dialog will be shown (if bbrowser supports it) |
| placement | `Array` | | `['bottom-end']` | tooltip openening direction |
| openByHover | `Boolean` | | `true` | should open tooltip with hover |
| autoclosable | `Boolean` | | `true` | should close tooltip when cursor is outside |
| closeDelay | `Number` | | `300` | delay before tooltip will be hidden when cursor is otside |
| iconSize | `Number` | | | icon-control size |
| iconClass | `String` | | | icon-control mixin |
| tooltipClassName | `String` | | | tooltip mixin |
| className | `String` | | | css class for control |
| buttonAriaLabel | `String` | | | set an "aria-label" attribute to a share button |
| buttonProps | `React.ButtonHTMLAttributes<HTMLButtonElement>` | | | pass props to a share button |

### Examples

Expand Down
4 changes: 4 additions & 0 deletions src/components/SharePopover/SharePopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export interface SharePopoverProps extends ShareListProps, Partial<SharePopoverD
buttonTitle?: string | React.ReactNode;
/** aria-label of button */
buttonAriaLabel?: string;
/** button props */
buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
/** custom onClick handler */
onClick?: (event?: React.MouseEvent<HTMLSpanElement>) => void;
/** custom copy link button title */
Expand Down Expand Up @@ -104,6 +106,7 @@ export const SharePopover = (props: SharePopoverProps) => {
children,
onClick,
buttonAriaLabel,
buttonProps,
} = props;
const [isOpen, setIsOpen] = React.useState(false);
const buttonRef = React.useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -182,6 +185,7 @@ export const SharePopover = (props: SharePopoverProps) => {
aria-describedby={tooltipId}
aria-label={buttonAriaLabel}
onClick={onClickInner}
{...(buttonProps ?? {})}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be placed before all other props, otherwise props that we assigned can be overwritten. Also we should merge className and onClick from buttonProps with our props as well.

ref={buttonRef}
>
<div className={b('icon-container')}>
Expand Down
Loading