Skip to content

Commit

Permalink
Merge pull request layer5io#731 from sudhanshutech/yash/addShareModal
Browse files Browse the repository at this point in the history
Share Modal
  • Loading branch information
sudhanshutech authored Nov 30, 2024
2 parents cc64f06 + cbc755a commit f2edeb6
Show file tree
Hide file tree
Showing 17 changed files with 752 additions and 33 deletions.
8 changes: 7 additions & 1 deletion src/custom/CatalogDetail/OverviewSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface OverviewSectionProps {
fontFamily?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
userProfile?: any;
showShareAction: boolean;
handleShare: () => void;
}

const OverviewSection: React.FC<OverviewSectionProps> = ({
Expand All @@ -37,7 +39,9 @@ const OverviewSection: React.FC<OverviewSectionProps> = ({
classes,
handleCopyUrl,
fontFamily,
userProfile
userProfile,
showShareAction,
handleShare
}) => {
return (
<OverviewContainer>
Expand All @@ -58,6 +62,8 @@ const OverviewSection: React.FC<OverviewSectionProps> = ({
title={title}
getUrl={getUrl}
handleCopyUrl={handleCopyUrl}
showShareAction={showShareAction}
handleShare={handleShare}
/>
</div>
<Grid container spacing={2}>
Expand Down
8 changes: 7 additions & 1 deletion src/custom/CatalogDetail/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ interface RightPanelProps {
technologySVGSubpath: string;
orgName: string;
fetchingOrgError: boolean;
showShareAction: boolean;
handleShare: () => void;
}

const RightPanel: React.FC<RightPanelProps> = ({
Expand All @@ -47,7 +49,9 @@ const RightPanel: React.FC<RightPanelProps> = ({
technologySVGPath,
technologySVGSubpath,
orgName,
fetchingOrgError
fetchingOrgError,
showShareAction,
handleShare
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
const { data: userProfile } = useGetUserProfileByIdQuery({
Expand All @@ -69,6 +73,8 @@ const RightPanel: React.FC<RightPanelProps> = ({
handleCopyUrl={handleCopyUrl}
fontFamily={fontFamily}
userProfile={userProfile}
showShareAction={showShareAction}
handleShare={handleShare}
/>
{showCaveats && <CaveatsSection details={details} />}
<RelatedDesigns
Expand Down
35 changes: 25 additions & 10 deletions src/custom/CatalogDetail/SocialSharePopper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTheme } from '../../theme';
import { Pattern } from '../CustomCatalog/CustomCard';
import { CustomTooltip } from '../CustomTooltip';
import { ErrorBoundary } from '../ErrorBoundary';
import { CopyShareIconWrapper, VisibilityChip } from './style';
import { ActionButton, CopyShareIconWrapper, VisibilityChip } from './style';

interface SocialSharePopperProps {
details: Pattern;
Expand All @@ -15,6 +15,8 @@ interface SocialSharePopperProps {
title: string;
getUrl: (type: string, id: string) => string;
handleCopyUrl: (type: string, name: string, id: string) => void;
showShareAction: boolean;
handleShare: () => void;
}

const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
Expand All @@ -23,7 +25,9 @@ const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
cardId,
title,
getUrl,
handleCopyUrl
handleCopyUrl,
showShareAction,
handleShare
}) => {
const theme = useTheme();
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
Expand All @@ -50,15 +54,26 @@ const SocialSharePopper: React.FC<SocialSharePopperProps> = ({
{details?.visibility}
</VisibilityChip>

{details?.visibility !== 'private' && (
<CustomTooltip title="Copy Link" placement="top" arrow>
<IconButton
sx={{ borderRadius: '0.1rem', padding: '0.5rem' }}
onClick={() => handleCopyUrl(cleanedType, details?.name, details?.id)}
>
<ChainIcon height={'24'} width={'24'} fill={theme.palette.icon.secondary} />
</IconButton>
{showShareAction ? (
<CustomTooltip title="Share" placement="top" arrow>
<ActionButton sx={{ borderRadius: '0.2rem', padding: '0.4rem' }} onClick={handleShare}>
<ChainIcon height={'24'} width={'24'} fill={theme.palette.icon.inverse} />
Share
</ActionButton>
</CustomTooltip>
) : (
<>
{details?.visibility !== 'private' && (
<CustomTooltip title="Copy Link" placement="top" arrow>
<IconButton
sx={{ borderRadius: '0.1rem', padding: '0.5rem' }}
onClick={() => handleCopyUrl(cleanedType, details?.name, details?.id)}
>
<ChainIcon height={'24'} width={'24'} fill={theme.palette.icon.secondary} />
</IconButton>
</CustomTooltip>
)}
</>
)}

{(details?.visibility === 'published' || details?.visibility === 'public') && (
Expand Down
4 changes: 2 additions & 2 deletions src/custom/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { CustomTooltip } from '../CustomTooltip';
interface ModalProps extends DialogProps {
closeModal: () => void;
title: string;
headerIcon: React.ReactNode;
reactNode: React.ReactNode;
headerIcon?: React.ReactNode;
reactNode?: React.ReactNode;
}

interface ModalFooterProps {
Expand Down
Loading

0 comments on commit f2edeb6

Please sign in to comment.