Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(working-panel): swap tab icon for close button on hover (#21426)

AmAzing-e98f21cc860a
diff --git a/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx b/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
index 32831b73eba..42f6be1b7d9 100644
--- a/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
+++ b/src/features/Conversation/WorkingSidebar/WorkspaceTab.tsx
@@ -5,11 +5,12 @@ import { memo, type ReactNode } from 'react';
const styles = createStaticStyles(({ css, cssVar }) => ({
close: css`
+ pointer-events: none;
cursor: pointer;
position: absolute;
inset-block-start: 50%;
- inset-inline-end: 4px;
+ inset-inline-start: 7px;
transform: translateY(-50%);
display: grid;
@@ -48,10 +49,30 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
background: ${cssVar.colorFillSecondary};
}
+ /* the close button takes over the leading icon's slot instead of reserving
+ its own trailing space; while hidden it must not swallow taps on the icon */
&:hover [data-tab-close],
- &:focus-within [data-tab-close] {
+ & [data-tab-close]:focus-visible {
+ pointer-events: auto;
+ opacity: 1;
+ }
+
+ /* keyboard focus on the select button keeps the icon, so the visible glyph
+ always matches the action Enter/Space would run */
+ &:hover [data-tab-icon],
+ &:has([data-tab-close]:focus-visible) [data-tab-icon] {
+ opacity: 0;
+ }
+
+ /* keyboard focus on the select button outranks hover */
+ &:has([data-tab-key]:focus-visible) [data-tab-icon] {
opacity: 1;
}
+
+ &:has([data-tab-key]:focus-visible) [data-tab-close] {
+ pointer-events: none;
+ opacity: 0;
+ }
`,
containerActive: css`
background: ${cssVar.colorFillTertiary};
@@ -69,6 +90,10 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
color: ${cssVar.colorTextSecondary};
`,
+ icon: css`
+ display: flex;
+ transition: opacity 0.15s;
+ `,
label: css`
overflow: hidden;
max-width: 160px;
@@ -100,7 +125,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
color: ${cssVar.colorText};
}
`,
- tabClosable: css`
+ tabPinned: css`
padding-inline-end: 30px;
`,
trigger: css`
@@ -145,13 +170,15 @@ const WorkspaceTab = memo<WorkspaceTabProps>(
>
<button
aria-pressed={active}
- className={`${styles.tab} ${onClose || pinned ? styles.tabClosable : ''}`}
+ className={`${styles.tab} ${pinned ? styles.tabPinned : ''}`}
data-tab-key={tabKey}
type="button"
onClick={onSelect}
>
<span className={styles.trigger}>
- {iconNode ?? <Icon icon={icon} size={14} />}
+ <span className={styles.icon} data-tab-icon={onClose && !pinned ? '' : undefined}>
+ {iconNode ?? <Icon icon={icon} size={14} />}
+ </span>
<span className={styles.label}>{label}</span>
</span>
</button>