From 8d4bda1dcc882173ffba111375d5f52407b23347 Mon Sep 17 00:00:00 2001 From: pengx17 Date: Wed, 18 Sep 2024 02:10:46 +0000 Subject: [PATCH] fix(core): enable cloud button should not take space by default (#8270) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit before
🎥 Video uploaded on Graphite:
--- after
🎥 Video uploaded on Graphite:
--- .../workspace-card/index.tsx | 55 ++++++++++--------- .../workspace-card/styles.css.ts | 19 +++++-- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx b/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx index a3007b61b1..3785ded797 100644 --- a/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx +++ b/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx @@ -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 = () => { @@ -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 (
)}
- {onClickEnableCloud && - workspaceMetadata.flavour === WorkspaceFlavour.LOCAL ? ( - - ) : null} - {hideCollaborationIcon || information?.isOwner ? null : ( - - )} - {onClickOpenSettings && ( -
{ - e.stopPropagation(); - onClickOpenSettings(workspaceMetadata); - }} - > - -
- )} +
+ {onClickEnableCloud && + workspaceMetadata.flavour === WorkspaceFlavour.LOCAL ? ( + + ) : null} + {hideCollaborationIcon || information?.isOwner ? null : ( + + )} + {onClickOpenSettings && ( +
+ +
+ )} +
+ {showArrowDownIcon && } ); diff --git a/packages/frontend/core/src/components/workspace-selector/workspace-card/styles.css.ts b/packages/frontend/core/src/components/workspace-selector/workspace-card/styles.css.ts index e10927868a..d29f153ac8 100644 --- a/packages/frontend/core/src/components/workspace-selector/workspace-card/styles.css.ts +++ b/packages/frontend/core/src/components/workspace-selector/workspace-card/styles.css.ts @@ -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, @@ -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', }, }, });