Skip to content

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import clsx from 'clsx';
2626
import type { HTMLAttributes } from 'react';
2727
import { forwardRef, useCallback, useEffect, useState } from 'react';
2828

29+
import { useCatchEventCallback } from '../../hooks/use-catch-event-hook';
2930
import * as styles from './styles.css';
3031

3132
const CloudWorkspaceStatus = () => {
@@ -262,6 +263,14 @@ export const WorkspaceCard = forwardRef<
262263

263264
const name = information?.name ?? UNTITLED_WORKSPACE_NAME;
264265

266+
const onEnableCloud = useCatchEventCallback(() => {
267+
onClickEnableCloud?.(workspaceMetadata);
268+
}, [onClickEnableCloud, workspaceMetadata]);
269+
270+
const onOpenSettings = useCatchEventCallback(() => {
271+
onClickOpenSettings?.(workspaceMetadata);
272+
}, [onClickOpenSettings, workspaceMetadata]);
273+
265274
return (
266275
<div
267276
className={clsx(
@@ -301,32 +310,26 @@ export const WorkspaceCard = forwardRef<
301310
<Skeleton width={100} />
302311
)}
303312
</div>
304-
{onClickEnableCloud &&
305-
workspaceMetadata.flavour === WorkspaceFlavour.LOCAL ? (
306-
<Button
307-
className={styles.showOnCardHover}
308-
onClick={e => {
309-
e.stopPropagation();
310-
onClickEnableCloud(workspaceMetadata);
311-
}}
312-
>
313-
Enable Cloud
314-
</Button>
315-
) : null}
316-
{hideCollaborationIcon || information?.isOwner ? null : (
317-
<CollaborationIcon />
318-
)}
319-
{onClickOpenSettings && (
320-
<div
321-
className={styles.settingButton}
322-
onClick={e => {
323-
e.stopPropagation();
324-
onClickOpenSettings(workspaceMetadata);
325-
}}
326-
>
327-
<SettingsIcon width={16} height={16} />
328-
</div>
329-
)}
313+
<div className={styles.showOnCardHover}>
314+
{onClickEnableCloud &&
315+
workspaceMetadata.flavour === WorkspaceFlavour.LOCAL ? (
316+
<Button
317+
className={styles.enableCloudButton}
318+
onClick={onEnableCloud}
319+
>
320+
Enable Cloud
321+
</Button>
322+
) : null}
323+
{hideCollaborationIcon || information?.isOwner ? null : (
324+
<CollaborationIcon />
325+
)}
326+
{onClickOpenSettings && (
327+
<div className={styles.settingButton} onClick={onOpenSettings}>
328+
<SettingsIcon width={16} height={16} />
329+
</div>
330+
)}
331+
</div>
332+
330333
{showArrowDownIcon && <ArrowDownSmallIcon />}
331334
</div>
332335
);

packages/frontend/core/src/components/workspace-selector/workspace-card/styles.css.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ export const workspaceTitleContainer = style({
125125
overflow: 'hidden',
126126
});
127127

128+
export const enableCloudButton = style({
129+
opacity: 0,
130+
selectors: {
131+
[`.${container}:hover &`]: {
132+
opacity: 1,
133+
},
134+
},
135+
});
136+
128137
export const settingButton = style({
129138
transition: 'all 0.13s ease',
130139
width: 0,
@@ -152,12 +161,14 @@ export const settingButton = style({
152161
});
153162

154163
export const showOnCardHover = style({
155-
visibility: 'hidden',
156-
opacity: 0,
164+
position: 'absolute',
165+
right: 0,
166+
display: 'flex',
167+
gap: 8,
168+
alignItems: 'center',
157169
selectors: {
158170
[`.${container}:hover &`]: {
159-
visibility: 'visible',
160-
opacity: 1,
171+
position: 'relative',
161172
},
162173
},
163174
});

0 commit comments

Comments
 (0)