Skip to content

Commit d8f2d65

Browse files
Merge pull request #825 from sudhanshutech/action/info
fix positioning and add info action
2 parents f192415 + 367ba54 commit d8f2d65

File tree

3 files changed

+79
-46
lines changed

3 files changed

+79
-46
lines changed

src/custom/CatalogDetail/ActionButton.tsx

+70-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { CircularProgress } from '../../base';
3-
import { CopyIcon, KanvasIcon, PublishIcon } from '../../icons';
3+
import { CopyIcon, EditIcon, KanvasIcon, PublishIcon } from '../../icons';
44
import Download from '../../icons/Download/Download';
55
import { charcoal, useTheme } from '../../theme';
66
import { Pattern } from '../CustomCatalog/CustomCard';
@@ -19,6 +19,8 @@ interface ActionButtonsProps {
1919
showUnpublishAction: boolean;
2020
showOpenPlaygroundAction: boolean;
2121
onOpenPlaygroundClick: (designId: string, name: string) => void;
22+
showInfoAction?: boolean;
23+
handleInfoClick?: () => void;
2224
}
2325

2426
const ActionButtons: React.FC<ActionButtonsProps> = ({
@@ -31,12 +33,34 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
3133
showUnpublishAction,
3234
handleUnpublish,
3335
showOpenPlaygroundAction,
34-
onOpenPlaygroundClick
36+
onOpenPlaygroundClick,
37+
showInfoAction,
38+
handleInfoClick
3539
}) => {
3640
const cleanedType = type.replace('my-', '').replace(/s$/, '');
3741
const theme = useTheme();
3842
return (
3943
<StyledActionWrapper>
44+
{showOpenPlaygroundAction && (
45+
<ActionButton
46+
sx={{
47+
borderRadius: '0.2rem',
48+
backgroundColor: theme.palette.background.cta?.default,
49+
color: theme.palette.text.inverse,
50+
gap: '10px',
51+
width: '100%'
52+
}}
53+
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
54+
>
55+
<KanvasIcon
56+
width={24}
57+
height={24}
58+
primaryFill={theme.palette.icon.inverse}
59+
fill={theme.palette.icon.default}
60+
/>
61+
Open in Playground
62+
</ActionButton>
63+
)}
4064
{actionItems && (
4165
<div
4266
style={{
@@ -49,17 +73,18 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
4973
<ActionButton
5074
sx={{
5175
borderRadius: '0.2rem',
52-
backgroundColor: theme.palette.background.brand?.default,
76+
backgroundColor: 'transparent',
77+
border: `1px solid ${theme.palette.border.normal}`,
5378
gap: '10px',
54-
color: charcoal[100]
79+
color: charcoal[10]
5580
}}
5681
onClick={() =>
5782
cleanedType === RESOURCE_TYPES.FILTERS
5883
? downloadFilter(details.id, details.name)
5984
: downloadYaml(details.pattern_file, details.name)
6085
}
6186
>
62-
<Download width={24} height={24} fill={charcoal[100]} />
87+
<Download width={24} height={24} fill={charcoal[10]} />
6388
Download
6489
</ActionButton>
6590

@@ -68,8 +93,9 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
6893
sx={{
6994
borderRadius: '0.2rem',
7095
gap: '10px',
71-
color: charcoal[100],
72-
backgroundColor: theme.palette.background.cta?.default
96+
color: theme.palette.text.default,
97+
backgroundColor: 'transparent',
98+
border: `1px solid ${theme.palette.border.normal}`
7399
}}
74100
onClick={() => handleClone(details?.name, details?.id)}
75101
disabled={isCloneDisabled}
@@ -78,49 +104,51 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
78104
<CircularProgress size={24} color={'inherit'} />
79105
) : (
80106
<>
81-
<CopyIcon width={24} height={24} fill={charcoal[100]} />
107+
<CopyIcon width={24} height={24} fill={charcoal[10]} />
82108
Clone
83109
</>
84110
)}
85111
</ActionButton>
86112
)}
87113
</div>
88114
)}
89-
{showOpenPlaygroundAction && (
90-
<ActionButton
91-
sx={{
92-
borderRadius: '0.2rem',
93-
backgroundColor: 'transparent',
94-
border: `1px solid ${theme.palette.border.normal}`,
95-
color: theme.palette.text.default,
96-
gap: '10px',
97-
width: '100%'
98-
}}
99-
onClick={() => onOpenPlaygroundClick(details.id, details.name)}
100-
>
101-
<KanvasIcon
102-
width={24}
103-
height={24}
104-
primaryFill={theme.palette.icon.default}
105-
fill={theme.palette.icon.default}
106-
/>
107-
Open in Playground
108-
</ActionButton>
109-
)}
110115

111-
{showUnpublishAction && (
112-
<UnpublishAction
113-
sx={{
114-
borderRadius: '0.2rem',
115-
gap: '10px',
116-
width: '100%'
117-
}}
118-
onClick={handleUnpublish}
119-
>
120-
<PublishIcon width={24} height={24} fill={charcoal[10]} />
121-
Unpublish
122-
</UnpublishAction>
123-
)}
116+
<div
117+
style={{
118+
display: 'flex',
119+
flexDirection: 'row',
120+
gap: '0.75rem',
121+
width: '100%'
122+
}}
123+
>
124+
{showInfoAction && (
125+
<ActionButton
126+
sx={{
127+
borderRadius: '0.2rem',
128+
backgroundColor: 'transparent',
129+
border: `1px solid ${theme.palette.border.normal}`,
130+
gap: '10px',
131+
color: charcoal[10]
132+
}}
133+
onClick={handleInfoClick}
134+
>
135+
<EditIcon width={24} height={24} fill={charcoal[10]} />
136+
Edit
137+
</ActionButton>
138+
)}
139+
{showUnpublishAction && (
140+
<UnpublishAction
141+
sx={{
142+
borderRadius: '0.2rem',
143+
gap: '10px'
144+
}}
145+
onClick={handleUnpublish}
146+
>
147+
<PublishIcon width={24} height={24} fill={charcoal[100]} />
148+
Unpublish
149+
</UnpublishAction>
150+
)}
151+
</div>
124152
</StyledActionWrapper>
125153
);
126154
};

src/custom/CatalogDetail/LeftPanel.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ interface LeftPanelProps {
2323
showUnpublishAction?: boolean;
2424
showOpenPlaygroundAction?: boolean;
2525
onOpenPlaygroundClick: (designId: string, name: string) => void;
26+
showInfoAction?: boolean;
27+
handleInfoClick?: () => void;
2628
}
2729

2830
const LeftPanel: React.FC<LeftPanelProps> = ({
@@ -40,7 +42,9 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
4042
fontFamily,
4143
showUnpublishAction = false,
4244
showOpenPlaygroundAction = true,
43-
onOpenPlaygroundClick
45+
onOpenPlaygroundClick,
46+
showInfoAction = false,
47+
handleInfoClick
4448
}) => {
4549
const theme = useTheme();
4650

@@ -83,6 +87,8 @@ const LeftPanel: React.FC<LeftPanelProps> = ({
8387
isCloneDisabled={isCloneDisabled}
8488
showOpenPlaygroundAction={showOpenPlaygroundAction}
8589
onOpenPlaygroundClick={onOpenPlaygroundClick}
90+
showInfoAction={showInfoAction}
91+
handleInfoClick={handleInfoClick}
8692
/>
8793
{showTechnologies && (
8894
<TechnologySection

src/custom/CatalogDetail/style.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ export const UnpublishAction = styled('div')<ActionButtonProps>(({ disabled = fa
4343
justifyContent: 'center',
4444
alignItems: 'center',
4545
borderRadius: '0.5rem',
46-
backgroundColor: 'transparent',
47-
border: `1px solid ${theme.palette.border.normal}`,
46+
backgroundColor: theme.palette.background.error?.default,
4847
padding: '0.5rem',
49-
color: theme.palette.text.default,
48+
color: theme.palette.text.inverse,
5049
gap: '0.625rem',
5150
flex: '1'
5251
}));

0 commit comments

Comments
 (0)