From fcabd3236d0c13d33b63250ac9f1b9f8e74adc17 Mon Sep 17 00:00:00 2001 From: kkmch Date: Fri, 3 Nov 2023 14:43:44 +0100 Subject: [PATCH 1/2] feat: shareUrlTitles for socual media links --- src/components/SharePopover/ShareList/ShareList.tsx | 5 ++++- src/components/SharePopover/ShareListItem/ShareListItem.tsx | 5 ++++- src/components/SharePopover/SharePopover.tsx | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/SharePopover/ShareList/ShareList.tsx b/src/components/SharePopover/ShareList/ShareList.tsx index c52e78ba..f6be2f06 100644 --- a/src/components/SharePopover/ShareList/ShareList.tsx +++ b/src/components/SharePopover/ShareList/ShareList.tsx @@ -18,6 +18,8 @@ const isShareListItemComponent = isOfType(ShareListItem); export interface ShareListDefaultProps { /** share options list */ shareOptions: ShareOptions[]; + /** share link titles */ + shareUrlTitles?: Partial>; /** should show copy button */ withCopyLink: boolean; } @@ -93,7 +95,7 @@ export class ShareList extends React.PureComponent {shareOptions.map((type) => ( @@ -105,6 +107,7 @@ export class ShareList extends React.PureComponent ))} diff --git a/src/components/SharePopover/ShareListItem/ShareListItem.tsx b/src/components/SharePopover/ShareListItem/ShareListItem.tsx index c891c76f..d9422ce5 100644 --- a/src/components/SharePopover/ShareListItem/ShareListItem.tsx +++ b/src/components/SharePopover/ShareListItem/ShareListItem.tsx @@ -17,6 +17,7 @@ export interface ShareListItemProps extends ShareOptionsData { type?: ShareOptions; icon?: IconData; label?: string; + urlTitle?: string; className?: string; direction?: LayoutDirection; @@ -25,7 +26,7 @@ export interface ShareListItemProps extends ShareOptionsData { export class ShareListItem extends React.PureComponent { render() { - const {type, direction, className, label, getShareLink, ...rest} = this.props; + const {type, direction, className, label, getShareLink, urlTitle, ...rest} = this.props; const icon = this.props.icon || (type && icons[type]); const url = getShareLink?.(rest) ?? (type && this.getShareLink(type)); const typeModifier = type?.toLowerCase(); @@ -44,6 +45,7 @@ export class ShareListItem extends React.PureComponent { target="_blank" width="max" className={b(null, className)} + title={urlTitle} extraProps={{'aria-label': i18n('label_share', {name})}} > {icon && ( @@ -61,6 +63,7 @@ export class ShareListItem extends React.PureComponent { target="_blank" className={b(null, className)} extraProps={{'aria-label': i18n('label_share', {name})}} + title={urlTitle} > {icon && } diff --git a/src/components/SharePopover/SharePopover.tsx b/src/components/SharePopover/SharePopover.tsx index a11b808d..bb2b7bb2 100644 --- a/src/components/SharePopover/SharePopover.tsx +++ b/src/components/SharePopover/SharePopover.tsx @@ -100,6 +100,7 @@ export const SharePopover = (props: SharePopoverProps) => { renderCopy, children, onClick, + shareUrlTitles, } = props; const [isOpen, setIsOpen] = React.useState(false); const tooltipId = useUniqId(); @@ -116,6 +117,7 @@ export const SharePopover = (props: SharePopoverProps) => { copyTitle={copyTitle} copyIcon={copyIcon} renderCopy={renderCopy} + shareUrlTitles={shareUrlTitles} > {children} From 2584c7163cd8ac21340b2906e74b660c2f7e5c3c Mon Sep 17 00:00:00 2001 From: kkmch Date: Fri, 3 Nov 2023 14:46:35 +0100 Subject: [PATCH 2/2] feat: added 1 use case for story --- .../__stories__/Showcase/index.tsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/components/SharePopover/__stories__/Showcase/index.tsx b/src/components/SharePopover/__stories__/Showcase/index.tsx index be8b178f..178f541d 100644 --- a/src/components/SharePopover/__stories__/Showcase/index.tsx +++ b/src/components/SharePopover/__stories__/Showcase/index.tsx @@ -25,6 +25,14 @@ export function SharePopoverDemo() { ShareOptions.LinkedIn, ShareOptions.Mail, ]; + const shareUrlTitles = { + [ShareOptions.Telegram]: 'Opens in a new tab', + [ShareOptions.Facebook]: 'Opens in a new tab', + [ShareOptions.Twitter]: 'Opens in a new tab', + [ShareOptions.VK]: 'Opens in a new tab', + [ShareOptions.LinkedIn]: 'Opens in a new tab', + [ShareOptions.Mail]: 'Opens in a new tab', + }; const ShareTitle =
Share
; @@ -201,6 +209,19 @@ export function SharePopoverDemo() { )} /> + +
+ Share options with url title + +
); }