Skip to content

Commit

Permalink
feat: add 'Open in Playground' action button conditionally
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Amrutiya <[email protected]>
  • Loading branch information
amitamrutiya committed Nov 12, 2024
1 parent 983711b commit 63b0dff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 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

0 comments on commit 63b0dff

Please sign in to comment.