Skip to content

Commit

Permalink
Merge pull request #806 from amitamrutiya/open-playground
Browse files Browse the repository at this point in the history
add 'Open in Playground' action button conditionally
  • Loading branch information
amitamrutiya authored Nov 12, 2024
2 parents 983711b + e92d6a8 commit fea308e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
43 changes: 23 additions & 20 deletions src/custom/CatalogDetail/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ActionButtonsProps {
handleUnpublish: () => void;
isCloneDisabled: boolean;
showUnpublishAction: boolean;
showOpenPlaygroundAction: boolean;
onOpenPlaygroundClick: (designId: string, name: string) => void;
}

Expand All @@ -29,6 +30,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
isCloneDisabled,
showUnpublishAction,
handleUnpublish,
showOpenPlaygroundAction,
onOpenPlaygroundClick
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
Expand Down Expand Up @@ -84,26 +86,27 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
)}
</div>
)}

<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
color: theme.palette.text.default,
gap: '10px',
width: '100%'
}}
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
>
<KanvasIcon
width={24}
height={24}
primaryFill={theme.palette.icon.default}
fill={theme.palette.icon.default}
/>
Open in Playground
</ActionButton>
{showOpenPlaygroundAction && (
<ActionButton
sx={{
borderRadius: '0.2rem',
backgroundColor: 'transparent',
border: `1px solid ${theme.palette.border.normal}`,
color: theme.palette.text.default,
gap: '10px',
width: '100%'
}}
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
>
<KanvasIcon
width={24}
height={24}
primaryFill={theme.palette.icon.default}
fill={theme.palette.icon.default}
/>
Open in Playground
</ActionButton>
)}

{showUnpublishAction && (
<UnpublishAction
Expand Down
3 changes: 3 additions & 0 deletions src/custom/CatalogDetail/LeftPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface LeftPanelProps {
fontFamily?: string;
handleUnpublish: () => void;
showUnpublishAction?: boolean;
showOpenPlaygroundAction?: boolean;
onOpenPlaygroundClick: (designId: string, name: string) => void;
}

Expand All @@ -38,6 +39,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
technologySVGSubpath,
fontFamily,
showUnpublishAction = false,
showOpenPlaygroundAction = true,
onOpenPlaygroundClick
}) => {
const theme = useTheme();
Expand Down Expand Up @@ -79,6 +81,7 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
showUnpublishAction={showUnpublishAction}
handleUnpublish={handleUnpublish}
isCloneDisabled={isCloneDisabled}
showOpenPlaygroundAction={showOpenPlaygroundAction}
onOpenPlaygroundClick={onOpenPlaygroundClick}
/>
{showTechnologies && (
Expand Down
2 changes: 1 addition & 1 deletion src/custom/CustomTooltip/customTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function CustomTooltip({
onClick={onClick}
{...props}
>
<span>{children}</span>
{children}
</Tooltip>
);
}
Expand Down

0 comments on commit fea308e

Please sign in to comment.