From fc5b5621674b04972f94e2668fd8ea89d3c46366 Mon Sep 17 00:00:00 2001 From: Damir Battalov Date: Fri, 5 Sep 2025 13:16:25 +0300 Subject: [PATCH] feat(SharePopover): add button props --- src/components/SharePopover/README.md | 34 +++++++++++--------- src/components/SharePopover/SharePopover.tsx | 4 +++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/components/SharePopover/README.md b/src/components/SharePopover/README.md index ec47589a..cc06574f 100644 --- a/src/components/SharePopover/README.md +++ b/src/components/SharePopover/README.md @@ -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` | | `[]` | 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` | | `[]` | 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` | | | pass props to a share button | ### Examples diff --git a/src/components/SharePopover/SharePopover.tsx b/src/components/SharePopover/SharePopover.tsx index 3c009de0..00aaa102 100644 --- a/src/components/SharePopover/SharePopover.tsx +++ b/src/components/SharePopover/SharePopover.tsx @@ -60,6 +60,8 @@ export interface SharePopoverProps extends ShareListProps, Partial; /** custom onClick handler */ onClick?: (event?: React.MouseEvent) => void; /** custom copy link button title */ @@ -104,6 +106,7 @@ export const SharePopover = (props: SharePopoverProps) => { children, onClick, buttonAriaLabel, + buttonProps, } = props; const [isOpen, setIsOpen] = React.useState(false); const buttonRef = React.useRef(null); @@ -182,6 +185,7 @@ export const SharePopover = (props: SharePopoverProps) => { aria-describedby={tooltipId} aria-label={buttonAriaLabel} onClick={onClickInner} + {...(buttonProps ?? {})} ref={buttonRef} >