🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
💄 style: simplify home greeting and announcement layout (#19203)
YuTengjing73c35f4c6859
diff --git a/locales/en-US/home.json b/locales/en-US/home.jsonindex 00ff765f669..d9100ca5f7c 100644--- a/locales/en-US/home.json+++ b/locales/en-US/home.json@@ -48,7 +48,6 @@"dashboard.chat.recents": "Recent topics","dashboard.chat.running": "Running topics","dashboard.customize.decrease": "Decrease {{label}}",- "dashboard.customize.entry": "Customize","dashboard.customize.group.agent": "Agent","dashboard.customize.group.listSize": "List size","dashboard.customize.group.rail": "Sidebar",diff --git a/locales/zh-CN/home.json b/locales/zh-CN/home.jsonindex 1897e5478e8..630dda01094 100644--- a/locales/zh-CN/home.json+++ b/locales/zh-CN/home.json@@ -48,7 +48,6 @@"dashboard.chat.recents": "最近话题","dashboard.chat.running": "正在运行","dashboard.customize.decrease": "减少{{label}}",- "dashboard.customize.entry": "自定义","dashboard.customize.group.agent": "Agent","dashboard.customize.group.listSize": "列表条数","dashboard.customize.group.rail": "侧边栏",diff --git a/packages/locales/src/default/home.ts b/packages/locales/src/default/home.tsindex e6b87d385c6..f7e8a5e4700 100644--- a/packages/locales/src/default/home.ts+++ b/packages/locales/src/default/home.ts@@ -53,7 +53,6 @@ export default {'dashboard.chat.recents': 'Recent topics','dashboard.chat.running': 'Running topics','dashboard.customize.decrease': 'Decrease {{label}}',- 'dashboard.customize.entry': 'Customize','dashboard.customize.group.listSize': 'List size','dashboard.customize.group.agent': 'Agent','dashboard.customize.group.rail': 'Sidebar',diff --git a/src/features/Home/CustomizeButton.tsx b/src/features/Home/CustomizeButton.tsxindex 47a9d5d18b1..6eaa91cdcda 100644--- a/src/features/Home/CustomizeButton.tsx+++ b/src/features/Home/CustomizeButton.tsx@@ -1,42 +1,23 @@-import { Icon } from '@lobehub/ui';-import { Button } from '@lobehub/ui/base-ui';-import { createStaticStyles } from 'antd-style';+import { ActionIcon } from '@lobehub/ui/base-ui';import { SlidersHorizontal } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';import { openHomeCustomizeModal } from './CustomizeModal';-const styles = createStaticStyles(({ css }) => ({- // Floats in the page corner where the portrait can stand behind it — frost- // what shows through, like the rail cards do.- glass: css`- backdrop-filter: saturate(150%) blur(12px);- `,- label: css`- @media (width <= 1100px) {- display: none;- }- `,-}));-const CustomizeButton = memo(() => {const { t } = useTranslation('home');- const label = t('dashboard.customize.entry');+ const label = t('dashboard.customize.title');return (- <Button+ <ActionIconaria-label={label}- className={styles.glass}- icon={<Icon icon={SlidersHorizontal} size={14} />}- shape={'round'}+ icon={SlidersHorizontal}size={'small'}title={label}- type={'fill'}+ variant={'borderless'}onClick={() => openHomeCustomizeModal()}- >- <span className={styles.label}>{label}</span>- </Button>+ />);});diff --git a/src/features/Home/HomeHeader.tsx b/src/features/Home/HomeHeader.tsxindex e73e0787790..8ff091a84a0 100644--- a/src/features/Home/HomeHeader.tsx+++ b/src/features/Home/HomeHeader.tsx@@ -10,17 +10,16 @@ import { authSelectors, userProfileSelectors } from '@/store/user/slices/auth/seimport AgentSelect from './AgentSelect';const styles = createStaticStyles(({ css }) => ({- // The measure comes from the layout (`--home-greeting-measure`), which derives- // it from the container width: it has to clear the portrait's bubble, and it- // must not depend on the rail, or collapsing would re-wrap the headline and- // shove the composer and the whole task list down by a line.+ root: css`+ /* Unbroken names must stay inside the start-aligned header's text lane. */+ max-width: 100%;+ `,greeting: css`overflow: hidden;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;- max-width: var(--home-greeting-measure, none);margin: 0;font-size: 22px;@@ -59,7 +58,7 @@ const HomeHeader = memo<HomeHeaderProps>(({ centered }) => {// who speaks, the greeting answers below — but drops the toolbar chrome and// its 48px lane, so the pair reads as one compact block flush with the// composer. The layout's lift math (MINIMAL_LIFT) counts on these heights.- <Flexbox gap={centered ? 8 : 16} justify={'center'}>+ <Flexbox className={styles.root} gap={centered ? 8 : 16} justify={'center'}>{centered ? (<AgentSelect />) : (diff --git a/src/features/Home/HomePortrait.tsx b/src/features/Home/HomePortrait.tsxindex 3453e80bff2..4291a645e0d 100644--- a/src/features/Home/HomePortrait.tsx+++ b/src/features/Home/HomePortrait.tsx@@ -7,29 +7,23 @@ import { useAgentStore } from '@/store/agent';import { agentSelectors } from '@/store/agent/selectors';import { useResolvedHomeAgentId } from './AgentSelect/useResolvedHomeAgentId';+import { HOME_PORTRAIT_INSET } from './portraitFraming';const styles = createStaticStyles(({ css }) => ({/**- * One frame for every character. Generated artwork arrives cropped to the- * subject, and the built-in catalog draws its character across the frame with- * a few percent of margin, so sizing by height lands both at the same stature.- * Anchored deep enough that the lower body passes behind the first card — the- * character leans on the surface instead of standing on it. The offset is what- * sets how much shows: 94px leaves `HOME_PORTRAIT_VISIBLE_RATIO` of the- * character above the card (see ./portraitFraming), which clears the catalog- * mascot's head — it is half its own height — and reaches the hem on a- * standing figure, where 57% cut both at the collar and the waist. Change one- * and the studio's preview frame stops matching what home shows.+ * The speech layout owns image dimensions and overlap. Both sizes reveal+ * the same fraction used by the artwork studio preview, with the lower+ * body passing behind the supporting card.*/image: css`pointer-events: none;position: absolute;- inset-block-end: -94px;- inset-inline-end: 12px;+ inset-block-end: var(--home-portrait-overlap);+ inset-inline-end: ${HOME_PORTRAIT_INSET}px;- width: 176px;- height: 200px;+ width: var(--home-portrait-width);+ height: var(--home-portrait-height);object-fit: contain;object-position: bottom;diff --git a/src/features/Home/PortraitBubble/index.tsx b/src/features/Home/PortraitBubble/index.tsxindex 7233a4c745e..1fac35c866e 100644--- a/src/features/Home/PortraitBubble/index.tsx+++ b/src/features/Home/PortraitBubble/index.tsx@@ -12,13 +12,11 @@ const styles = createStaticStyles(({ css, cssVar }) => ({// Prose, not a row of chips: a flex container would make the brief's entity// links their own flex items and break the sentence into side-by-side columns.bubble: css`- position: relative;-overflow: hidden;display: block;max-width: 100%;- padding-block: 8px;+ padding-block: 6px;padding-inline: 12px;border: 1px solid ${cssVar.colorBorderSecondary};border-radius: 14px;@@ -28,41 +26,18 @@ const styles = createStaticStyles(({ css, cssVar }) => ({color: ${cssVar.colorTextSecondary};background: ${cssVar.colorBgContainer};- box-shadow: ${cssVar.boxShadowTertiary};-- /* The tail is what makes this read as the agent's line rather than one more- toolbar chip, so the layout switches it off via --home-bubble-tail wherever- it parks the bubble below the greeting instead of beside him. */- &::after {- content: '';-- position: absolute;- inset-block-start: 50%;- inset-inline-end: -5px;- transform: translateY(-50%) rotate(45deg);-- display: var(--home-bubble-tail, none);-- width: 9px;- height: 9px;- border-block-start: 1px solid ${cssVar.colorBorderSecondary};- border-inline-end: 1px solid ${cssVar.colorBorderSecondary};-- background: ${cssVar.colorBgContainer};- }-- &:dir(rtl)::after {- inset-inline: -5px auto;- transform: translateY(-50%) rotate(225deg);- }`,- // The bubble is anchored by its bottom edge, so an unbounded line grows- // upward into the toolbar row.+ /**+ * Match the 24px action row when a brief replaces an announcement. Limit+ * prose to two lines so optional content cannot push the composer far down.+ */line: css`overflow: hidden;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;++ min-height: 24px;`,}));diff --git a/src/features/Home/index.tsx b/src/features/Home/index.tsxindex 78c58f97240..81eb1d866bc 100644--- a/src/features/Home/index.tsx+++ b/src/features/Home/index.tsx@@ -23,6 +23,13 @@ import HomeModeContent from './HomeModeContent';import HomePortrait from './HomePortrait';import InputArea from './InputArea';import PortraitBubble from './PortraitBubble';+import {+ getHomePortraitOverlap,+ HOME_PORTRAIT_CARD_GAP,+ HOME_PORTRAIT_HEIGHT,+ HOME_PORTRAIT_INSET,+ HOME_PORTRAIT_WIDTH,+} from './portraitFraming';import { RAIL_INBOX_PROPS, resolveRailVisibility } from './railVisibility';import type { HomeMode } from './types';@@ -62,24 +69,22 @@ const RAIL_COLUMN_GAP = 28;const RAIL_EXIT_OFFSET = 24;const RAIL_TRANSITION_DURATION = 220;const RAIL_RECLAIMED_WIDTH = RAIL_CARD_WIDTH + RAIL_GUTTER + RAIL_COLUMN_GAP;-/** Share of the vacated rail track the content keeps; the rest is split as margin. */-const COLLAPSED_CONTENT_GAIN = 140;+/** Portrait width plus its inline inset and the gap it keeps from the text. */+const PORTRAIT_LANE = HOME_PORTRAIT_WIDTH + HOME_PORTRAIT_INSET + 16;+/** Reclaim the artwork's full lane so collapsing never narrows the text above. */+const COLLAPSED_CONTENT_GAIN = PORTRAIT_LANE;const COLLAPSED_CONTENT_OFFSET = (RAIL_RECLAIMED_WIDTH - COLLAPSED_CONTENT_GAIN) / 2;-/** Portrait width plus its inline inset and the gap the bubble keeps from it. */-const PORTRAIT_LANE = 152 + 12 + 16;-const BUBBLE_MAX_WIDTH = 360;-const BUBBLE_GAP = 16;-/**- * What the greeting must leave alone so the bubble never lands on it, measured- * in the tighter of the two states: the collapsed content is inset by- * COLLAPSED_CONTENT_OFFSET on both sides, and the bubble occupies the portrait's- * lane plus its own width. Subtracted from the *container* width, because the- * bubble tracks the container's trailing edge while the greeting starts at its- * leading edge — a fixed measure only happens to clear it at full width.- */-const GREETING_LANE = COLLAPSED_CONTENT_OFFSET * 2 + PORTRAIT_LANE + BUBBLE_MAX_WIDTH + BUBBLE_GAP;-/** Under this the greeting, the bubble and the portrait cannot share a line. */-const BUBBLE_INLINE_MIN = 1080;+const SPEECH_BUBBLE_MIN = 320;+const SPEECH_GREETING_GAP = 24;+const SPEECH_GREETING_MIN = 320;+const SPEECH_RESERVED_WIDTH =+ COLLAPSED_CONTENT_OFFSET * 2 + SPEECH_GREETING_GAP + SPEECH_BUBBLE_MIN + PORTRAIT_LANE;+/** Use the tighter rail state so its animation cannot switch rows or rewrap text. */+const SPEECH_INLINE_MIN = SPEECH_RESERVED_WIDTH + SPEECH_GREETING_MIN;+const COMPACT_PORTRAIT_HEIGHT = 150;+const COMPACT_PORTRAIT_WIDTH =+ HOME_PORTRAIT_WIDTH * (COMPACT_PORTRAIT_HEIGHT / HOME_PORTRAIT_HEIGHT);+const COMPACT_PORTRAIT_OVERLAP = getHomePortraitOverlap(COMPACT_PORTRAIT_HEIGHT);const MINIMAL_STACK_GAP = 24;/*** The minimal header stacks the agent switcher (24px avatar + 2px paddings,@@ -106,7 +111,7 @@ const styles = createStaticStyles(({ css }) => ({display: grid;grid-template-columns: minmax(0, 1fr) ${RAIL_CARD_WIDTH + RAIL_GUTTER}px;grid-template-rows: auto auto;- gap: 24px ${RAIL_COLUMN_GAP}px;+ gap: ${HOME_PORTRAIT_CARD_GAP}px ${RAIL_COLUMN_GAP}px;width: 100%;@@ -140,57 +145,105 @@ const styles = createStaticStyles(({ css }) => ({}}`,- header: css`- --home-greeting-measure: none;+ hero: css`+ display: grid;+ grid-area: 1 / 1 / 2 / -1;+ grid-template-columns: minmax(0, 1fr);+ gap: 16px;+ align-items: end;- position: relative;- grid-area: 1 / 1;+ width: 100%;+ min-width: 0;++ transition: transform ${RAIL_TRANSITION_DURATION}ms ease-out;- @container home (width >= ${BUBBLE_INLINE_MIN}px) {- --home-greeting-measure: calc(100cqw - ${GREETING_LANE}px);+ @media (width > 1100px) {+ width: calc(100% - ${COLLAPSED_CONTENT_OFFSET * 2}px);+ }++ @media (prefers-reduced-motion: reduce) {+ transition: none;}`,- // Parks beside the portrait when the row is wide enough for the three of them;- // otherwise it drops below the greeting, where it is just another line and- // needs no anchoring.- bubbleSlot: css`- --home-bubble-tail: none;+ heroCollapsed: css`+ @media (width > 1100px) {+ transform: translateX(${COLLAPSED_CONTENT_OFFSET}px);- margin-block-start: 16px;+ &:dir(rtl) {+ transform: translateX(-${COLLAPSED_CONTENT_OFFSET}px);+ }+ }+ `,+ heroWithSpeech: css`+ @container home (width >= ${SPEECH_INLINE_MIN}px) {+ /* Size both text columns in a stable frame; only artwork placement+ moves when the rail toggles. Short speech leaves room for the name. */+ grid-template-columns: minmax(0, 1fr) max-content;+ column-gap: ${SPEECH_GREETING_GAP}px;+ }+ `,+ header: css`+ min-width: 0;+ `,+ speech: css`+ --home-portrait-width: ${COMPACT_PORTRAIT_WIDTH}px;+ --home-portrait-height: ${COMPACT_PORTRAIT_HEIGHT}px;+ --home-portrait-overlap: -${COMPACT_PORTRAIT_OVERLAP}px;- @container home (width >= ${BUBBLE_INLINE_MIN}px) {- --home-bubble-tail: block;+ display: flex;+ gap: 16px;+ align-items: flex-end;+ justify-self: end;- position: absolute;- inset-block-end: 4px;+ width: max-content;+ max-width: 100%;+ min-height: ${COMPACT_PORTRAIT_HEIGHT - COMPACT_PORTRAIT_OVERLAP}px;- /* Anchored to the header's trailing edge, which itself widens and slides- on collapse — so the slot only has to make up the difference, and it- makes it up with a transform, in step with the portrait it belongs to. */- inset-inline-end: ${PORTRAIT_LANE - RAIL_RECLAIMED_WIDTH}px;+ transition: transform ${RAIL_TRANSITION_DURATION}ms ease-out;- display: flex;- justify-content: flex-end;+ @media (width > 1100px) {+ transform: translateX(${COLLAPSED_CONTENT_OFFSET * 2}px);- max-width: ${BUBBLE_MAX_WIDTH}px;- margin-block-start: 0;+ &:dir(rtl) {+ transform: translateX(-${COLLAPSED_CONTENT_OFFSET * 2}px);+ }- transition: transform ${RAIL_TRANSITION_DURATION}ms ease-out;+ &[data-collapsed='true'] {+ transform: none;+ }}@media (prefers-reduced-motion: reduce) {transition: none;}- `,- bubbleSlotCollapsed: css`- @container home (width >= ${BUBBLE_INLINE_MIN}px) {- transform: translateX(-${RAIL_RECLAIMED_WIDTH}px);- &:dir(rtl) {- transform: translateX(${RAIL_RECLAIMED_WIDTH}px);- }+ @container home (width >= ${SPEECH_INLINE_MIN}px) {+ --home-portrait-width: ${HOME_PORTRAIT_WIDTH}px;+ --home-portrait-height: ${HOME_PORTRAIT_HEIGHT}px;+ --home-portrait-overlap: -${getHomePortraitOverlap(HOME_PORTRAIT_HEIGHT)}px;++ grid-area: 1 / 2;+ align-self: stretch;++ /* Use all room left by the greeting in the tighter rail state. */+ max-width: calc(+ 100cqw - ${COLLAPSED_CONTENT_OFFSET * 2 + SPEECH_GREETING_MIN + SPEECH_GREETING_GAP}px+ );+ min-height: 0;}`,+ bubbleSlot: css`+ width: max-content;+ min-width: 0;+ max-width: 100%;+ margin-block-end: 4px;+ `,+ portrait: css`+ pointer-events: none;+ flex: none;+ align-self: stretch;+ width: calc(var(--home-portrait-width) + ${HOME_PORTRAIT_INSET}px);+ `,inputArea: css`position: relative;min-width: 0;@@ -214,31 +267,6 @@ const styles = createStaticStyles(({ css }) => ({margin-inline: auto;padding-block-end: ${MINIMAL_LIFT}px;`,- portrait: css`- pointer-events: none;- grid-area: 1 / 2;- transition: transform ${RAIL_TRANSITION_DURATION}ms ease-out;-- @media (prefers-reduced-motion: reduce) {- transition: none;- }-- @media (width <= 1100px) {- display: none;- }- `,- // With the rail gone the agent has nothing to lean into, so it slides over the- // composer instead of disappearing with the cards — keeping the same dip, so- // the same half of it stays behind the surface it leans on.- portraitCollapsed: css`- @media (width > 1100px) {- transform: translateX(-${COLLAPSED_CONTENT_OFFSET}px);-- &:dir(rtl) {- transform: translateX(${COLLAPSED_CONTENT_OFFSET}px);- }- }- `,railSurface: css`transform: translateX(0);visibility: visible;@@ -361,23 +389,29 @@ const Home = memo(() => {return (<Flexbox className={styles.grid}>- <div className={cx(styles.header, styles.content, railCollapsed && styles.contentCollapsed)}>- <HomeHeader />- {/* The portrait has one voice: a live campaign temporarily speaks in- place of the daily brief, which returns when the campaign leaves. */}+ <div+ className={cx(+ styles.hero,+ portraitVisible && styles.heroWithSpeech,+ railCollapsed && styles.heroCollapsed,+ )}+ >+ <div className={styles.header}>+ <HomeHeader />+ </div>{portraitVisible && (- <div className={cx(styles.bubbleSlot, railCollapsed && styles.bubbleSlotCollapsed)}>- <PortraitBubble promo={promo} />+ <div className={styles.speech} data-collapsed={railCollapsed}>+ {/* Keep the agent's line and artwork together in both header layouts. */}+ <div className={styles.bubbleSlot}>+ <PortraitBubble promo={promo} />+ </div>+ <div className={styles.portrait}>+ <HomePortrait />+ </div></div>)}</div>- {portraitVisible && (- <div className={cx(styles.portrait, railCollapsed && styles.portraitCollapsed)}>- <HomePortrait />- </div>- )}-<FlexboxclassName={cx(styles.main, styles.content, railCollapsed && styles.contentCollapsed)}data-testid={'home-main'}diff --git a/src/features/Home/portraitFraming.ts b/src/features/Home/portraitFraming.tsindex 9657af5a84d..4bace3f2e46 100644--- a/src/features/Home/portraitFraming.ts+++ b/src/features/Home/portraitFraming.ts@@ -3,11 +3,22 @@** The home portrait hangs below its container so the lower body passes behind* the first card; what survives that overlap is this fraction of the character's- * height, measured against the real layout (image box 200px tall, card top- * 130px below the image's top edge).+ * height, measured from the image's top edge to the supporting card.** It lives here rather than inside the stylesheet because the artwork studio* draws the same fraction as a preview frame — if the two ever disagree, the* preview is lying about where home will cut.*/export const HOME_PORTRAIT_VISIBLE_RATIO = 0.65;++/** Shared with the greeting layout so text never enters the artwork's box. */+export const HOME_PORTRAIT_WIDTH = 176;+export const HOME_PORTRAIT_INSET = 12;++export const HOME_PORTRAIT_HEIGHT = 200;+/** Space between the hero row and the card that masks the portrait. */+export const HOME_PORTRAIT_CARD_GAP = 24;++/** Keep the visible fraction consistent with the artwork studio at every size. */+export const getHomePortraitOverlap = (height: number) =>+ height * (1 - HOME_PORTRAIT_VISIBLE_RATIO) + HOME_PORTRAIT_CARD_GAP;