Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import clsx from 'clsx';
import type { HTMLAttributes } from 'react';
import { forwardRef, useCallback, useEffect, useState } from 'react';

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

const CloudWorkspaceStatus = () => {
Expand Down Expand Up @@ -262,6 +263,14 @@ export const WorkspaceCard = forwardRef<

const name = information?.name ?? UNTITLED_WORKSPACE_NAME;

const onEnableCloud = useCatchEventCallback(() => {
onClickEnableCloud?.(workspaceMetadata);
}, [onClickEnableCloud, workspaceMetadata]);

const onOpenSettings = useCatchEventCallback(() => {
onClickOpenSettings?.(workspaceMetadata);
}, [onClickOpenSettings, workspaceMetadata]);

return (
<div
className={clsx(
Expand Down Expand Up @@ -301,32 +310,26 @@ export const WorkspaceCard = forwardRef<
<Skeleton width={100} />
)}
</div>
{onClickEnableCloud &&
workspaceMetadata.flavour === WorkspaceFlavour.LOCAL ? (
<Button
className={styles.showOnCardHover}
onClick={e => {
e.stopPropagation();
onClickEnableCloud(workspaceMetadata);
}}
>
Enable Cloud
</Button>
) : null}
{hideCollaborationIcon || information?.isOwner ? null : (
<CollaborationIcon />
)}
{onClickOpenSettings && (
<div
className={styles.settingButton}
onClick={e => {
e.stopPropagation();
onClickOpenSettings(workspaceMetadata);
}}
>
<SettingsIcon width={16} height={16} />
</div>
)}
<div className={styles.showOnCardHover}>
{onClickEnableCloud &&
workspaceMetadata.flavour === WorkspaceFlavour.LOCAL ? (
<Button
className={styles.enableCloudButton}
onClick={onEnableCloud}
>
Enable Cloud
</Button>
) : null}
{hideCollaborationIcon || information?.isOwner ? null : (
<CollaborationIcon />
)}
{onClickOpenSettings && (
<div className={styles.settingButton} onClick={onOpenSettings}>
<SettingsIcon width={16} height={16} />
</div>
)}
</div>

{showArrowDownIcon && <ArrowDownSmallIcon />}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ export const workspaceTitleContainer = style({
overflow: 'hidden',
});

export const enableCloudButton = style({
opacity: 0,
selectors: {
[`.${container}:hover &`]: {
opacity: 1,
},
},
});

export const settingButton = style({
transition: 'all 0.13s ease',
width: 0,
Expand Down Expand Up @@ -152,12 +161,14 @@ export const settingButton = style({
});

export const showOnCardHover = style({
visibility: 'hidden',
opacity: 0,
position: 'absolute',
right: 0,
display: 'flex',
gap: 8,
alignItems: 'center',
selectors: {
[`.${container}:hover &`]: {
visibility: 'visible',
opacity: 1,
position: 'relative',
},
},
});

0 comments on commit 8d4bda1

Please sign in to comment.