Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'Open in Playground' action button conditionally #806

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading