From 2c6d103abe1c6a26777f6642d18422b2370395bf Mon Sep 17 00:00:00 2001 From: Tsahi Matsliah Date: Tue, 21 Jul 2026 20:48:04 +0300 Subject: [PATCH] feat(share): sharing-visibility foundation (PR 1) Reusable ShareActions primitive (icon/inline variants, desktop popover + mobile native share) plus the initiative's flags and a flag-gated core copy-icon swap. - add ShareActions + Storybook story, useSharingVisibility gate - add feature_sharing_visibility (master kill-switch) and share_copy_icon - gate LinkIcon->CopyIcon swap behind share_copy_icon (default off == main) in ShareMobile, ActionButtons.v2, BriefPostHeaderActions - add share-surface Origin values Co-Authored-By: Claude Opus 4.8 --- .claude/launch.json | 11 ++ .../shared/src/components/ShareMobile.tsx | 6 +- .../cards/common/ActionButtons.v2.tsx | 5 +- .../post/brief/BriefPostHeaderActions.tsx | 7 +- .../components/share/ShareActions.spec.tsx | 81 +++++++++ .../src/components/share/ShareActions.tsx | 161 ++++++++++++++++++ packages/shared/src/hooks/useShareCopyIcon.ts | 14 ++ .../shared/src/hooks/useSharingVisibility.ts | 22 +++ packages/shared/src/lib/featureManagement.ts | 15 ++ packages/shared/src/lib/log.ts | 7 + .../components/ShareActions.stories.tsx | 113 ++++++++++++ 11 files changed, 437 insertions(+), 5 deletions(-) create mode 100644 .claude/launch.json create mode 100644 packages/shared/src/components/share/ShareActions.spec.tsx create mode 100644 packages/shared/src/components/share/ShareActions.tsx create mode 100644 packages/shared/src/hooks/useShareCopyIcon.ts create mode 100644 packages/shared/src/hooks/useSharingVisibility.ts create mode 100644 packages/storybook/stories/components/ShareActions.stories.tsx diff --git a/.claude/launch.json b/.claude/launch.json new file mode 100644 index 00000000000..8ae9d3b6d54 --- /dev/null +++ b/.claude/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.0.1", + "configurations": [ + { + "name": "storybook", + "runtimeExecutable": "pnpm", + "runtimeArgs": ["--filter", "storybook", "dev"], + "port": 6006 + } + ] +} diff --git a/packages/shared/src/components/ShareMobile.tsx b/packages/shared/src/components/ShareMobile.tsx index c5eef681837..e84795f2eeb 100644 --- a/packages/shared/src/components/ShareMobile.tsx +++ b/packages/shared/src/components/ShareMobile.tsx @@ -1,7 +1,8 @@ import type { ReactElement } from 'react'; import React, { useContext } from 'react'; -import { LinkIcon, ShareIcon } from './icons'; +import { CopyIcon, LinkIcon, ShareIcon } from './icons'; import { useCopyPostLink } from '../hooks/useCopyPostLink'; +import { useShareCopyIcon } from '../hooks/useShareCopyIcon'; import { Button, ButtonColor, @@ -35,6 +36,7 @@ export function ShareMobile({ const { openSharePost } = useSharePost(origin); const { logEvent } = useLogContext(); const { logOpts } = useContext(ActiveFeedContext); + const showCopyIcon = useShareCopyIcon(); const onShare = () => { logEvent( @@ -51,7 +53,7 @@ export function ShareMobile({ size={ButtonSize.Small} onClick={onCopyPostLink} pressed={copying} - icon={} + icon={showCopyIcon ? : } variant={ButtonVariant.Tertiary} color={ButtonColor.Avocado} > diff --git a/packages/shared/src/components/cards/common/ActionButtons.v2.tsx b/packages/shared/src/components/cards/common/ActionButtons.v2.tsx index 3bdf0f9270c..ee2f27641a6 100644 --- a/packages/shared/src/components/cards/common/ActionButtons.v2.tsx +++ b/packages/shared/src/components/cards/common/ActionButtons.v2.tsx @@ -7,6 +7,7 @@ import { CardActionBar } from '../../buttons/CardActionBar'; import { AnalyticsIcon, DiscussIcon as CommentIcon, + CopyIcon, LinkIcon, DownvoteIcon, } from '../../icons'; @@ -21,6 +22,7 @@ import { PostTagsPanel } from '../../post/block/PostTagsPanel'; import { LinkWithTooltip } from '../../tooltips/LinkWithTooltip'; import { useCardActions } from '../../../hooks/cards/useCardActions'; import { useBrandSponsorship } from '../../../hooks/useBrandSponsorship'; +import { useShareCopyIcon } from '../../../hooks/useShareCopyIcon'; import { usePostImpressionsModal } from '../../../hooks/post/usePostImpressionsModal'; import { usePostImpressions } from '../../../hooks/post/usePostImpressions'; @@ -73,6 +75,7 @@ const ActionButtons = ({ }: ActionButtonsProps): ReactElement | null => { const config = variantConfig[variant]; const isFeedPreview = useFeedPreviewMode(); + const showCopyIcon = useShareCopyIcon(); // When impressions are enabled, awards are hidden below laptop (tablet + // mobile) to make room for the extra action. const isLaptop = useViewSize(ViewSize.Laptop); @@ -227,7 +230,7 @@ const ActionButtons = ({ } + icon={showCopyIcon ? : } label="Copy link" onClick={onCopyLink} color={ButtonColor.Cabbage} diff --git a/packages/shared/src/components/post/brief/BriefPostHeaderActions.tsx b/packages/shared/src/components/post/brief/BriefPostHeaderActions.tsx index d1cb33406be..d31a26c0abb 100644 --- a/packages/shared/src/components/post/brief/BriefPostHeaderActions.tsx +++ b/packages/shared/src/components/post/brief/BriefPostHeaderActions.tsx @@ -6,8 +6,9 @@ import type { PostHeaderActionsProps } from '../common'; import Link from '../../utilities/Link'; import { Button, ButtonSize } from '../../buttons/Button'; import { settingsUrl } from '../../../lib/constants'; -import { LinkIcon, SettingsIcon } from '../../icons'; +import { CopyIcon, LinkIcon, SettingsIcon } from '../../icons'; import { useSharePost } from '../../../hooks/useSharePost'; +import { useShareCopyIcon } from '../../../hooks/useShareCopyIcon'; import type { Origin } from '../../../lib/log'; const Container = classed('div', 'flex flex-row items-center'); @@ -27,15 +28,17 @@ export const BriefPostHeaderActions = ({ showShareButton?: boolean; }): ReactElement => { const { copyLink } = useSharePost(origin); + const showCopyIcon = useShareCopyIcon(); return (
{showShareButton && (