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.

♻️ refactor(styles): migrate ChatInput, Acceptance, shared-tool-ui, share and workbench to StyleX (#22687)

Inneif285d0a632d2
diff --git a/apps/share/src/features/artifact/SharedArtifactView.tsx b/apps/share/src/features/artifact/SharedArtifactView.tsx
index c8d422900d4..20a4a4d9aa4 100644
--- a/apps/share/src/features/artifact/SharedArtifactView.tsx
+++ b/apps/share/src/features/artifact/SharedArtifactView.tsx
@@ -1,6 +1,7 @@
'use client';
-import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { useParams } from 'react-router';
import useSWR from 'swr';
@@ -9,14 +10,15 @@ import { lambdaClient } from '@/libs/trpc/client';
import ShareLayout from '../../shell/ShareLayout';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- frame: css`
- width: 100%;
- height: 100%;
- border: 0;
- background: ${cssVar.colorBgLayout};
- `,
-}));
+const styles = stylex.create({
+ frame: {
+ width: '100%',
+ height: '100%',
+ borderStyle: 'none',
+ backgroundColor: cssVar.colorBgLayout,
+ backgroundImage: 'none',
+ },
+});
const SharedArtifactView = () => {
const { id } = useParams<{ id: string }>();
@@ -33,7 +35,7 @@ const SharedArtifactView = () => {
<ShareLayout error={error || (!loading && !data)} loading={loading} title={data?.title}>
{data && (
<iframe
- className={styles.frame}
+ {...stylex.props(styles.frame)}
referrerPolicy={'no-referrer'}
sandbox={'allow-scripts'}
src={data.iframeSrc}
diff --git a/apps/share/src/features/topic/SharePortal.tsx b/apps/share/src/features/topic/SharePortal.tsx
index 66a0fc8dd27..c7d3fd8e38f 100644
--- a/apps/share/src/features/topic/SharePortal.tsx
+++ b/apps/share/src/features/topic/SharePortal.tsx
@@ -1,6 +1,8 @@
'use client';
-import { createStaticStyles, DraggablePanel } from '@lobehub/ui';
+import { DraggablePanel } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { lazy, memo, Suspense, useState } from 'react';
import { CHAT_PORTAL_TOOL_UI_WIDTH } from '@/const/layoutTokens';
@@ -9,35 +11,33 @@ import { chatPortalSelectors } from '@/store/chat/selectors';
import ShareLoading from '../../shell/ShareLoading';
-const styles = createStaticStyles(({ cssVar, css }) => ({
- body: css`
- overflow: hidden;
- display: flex;
- flex: 1;
- flex-direction: column;
-
- height: 0;
- padding-block-end: 12px;
- `,
- content: css`
- position: relative;
-
- overflow: hidden;
- display: flex;
- flex-direction: column;
-
- height: 100%;
- min-height: 100%;
- max-height: 100%;
-
- background: ${cssVar.colorBgContainer};
- `,
- drawer: css`
- z-index: 10;
- height: 100%;
- background: ${cssVar.colorBgContainer};
- `,
-}));
+const styles = stylex.create({
+ body: {
+ overflow: 'hidden',
+ display: 'flex',
+ flex: '1',
+ flexDirection: 'column',
+ height: '0',
+ paddingBlockEnd: '12px',
+ },
+ content: {
+ position: 'relative',
+ overflow: 'hidden',
+ display: 'flex',
+ flexDirection: 'column',
+ height: '100%',
+ minHeight: '100%',
+ maxHeight: '100%',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ drawer: {
+ zIndex: 10,
+ height: '100%',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+});
// Every portal view (artifacts, documents, tasks, goals…) ships with the router,
// about 1MB gzipped, for a panel that starts collapsed. Loading it on first open
@@ -55,8 +55,8 @@ const SharePortal = memo(() => {
return (
<DraggablePanel
- className={styles.drawer}
- classNames={{ content: styles.content }}
+ className={stylex.props(styles.drawer).className}
+ classNames={{ content: stylex.props(styles.content).className }}
defaultSize={{ width: CHAT_PORTAL_TOOL_UI_WIDTH }}
expand={showPortal}
expandable={false}
@@ -68,7 +68,7 @@ const SharePortal = memo(() => {
>
{opened && (
<Suspense fallback={<ShareLoading />}>
- <PortalContent renderBody={(body) => <div className={styles.body}>{body}</div>} />
+ <PortalContent renderBody={(body) => <div {...stylex.props(styles.body)}>{body}</div>} />
</Suspense>
)}
</DraggablePanel>
diff --git a/apps/share/src/shell/ShareLayout.tsx b/apps/share/src/shell/ShareLayout.tsx
index b0a22cda276..88aa6673097 100644
--- a/apps/share/src/shell/ShareLayout.tsx
+++ b/apps/share/src/shell/ShareLayout.tsx
@@ -1,6 +1,8 @@
'use client';
-import { ActionIcon, copyToClipboard, createStaticStyles, Flexbox, Text, toast } from '@lobehub/ui';
+import { ActionIcon, copyToClipboard, Flexbox, Text, toast } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { LinkIcon } from 'lucide-react';
import { type ComponentType, type CSSProperties, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
@@ -10,6 +12,7 @@ import { ProductLogo } from '@/components/Branding';
import Loading from '@/components/Loading/BrandTextLoading';
import { DESKTOP_HEADER_ICON_SMALL_SIZE } from '@/const/layoutTokens';
import ShareErrorView, { type ShareNotFoundCopy } from '@/features/Share/ErrorView';
+import { sx } from '@/styles/sx';
type HeaderActionsProps = {
actions?: ReactNode;
@@ -43,85 +46,76 @@ const GUTTER_MIN_WIDTH = 316;
// header — the backdrop collapses and the body's top offset goes with it.
// Scroll content that starts under a floating header pads itself by
// `--share-header-overlap` (see ShareHero).
-const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- position: relative;
- overflow: hidden;
- padding-block-start: var(--share-bar-height);
- `,
- divider: css`
- flex: none;
- width: 1px;
- height: 16px;
- background: ${cssVar.colorFill};
- `,
- header: css`
- pointer-events: none;
-
- position: absolute;
- z-index: 10;
- inset-block-start: 0;
- inset-inline: 0;
-
- display: flex;
- gap: 12px;
- align-items: center;
- justify-content: space-between;
-
- height: ${HEADER_HEIGHT}px;
- padding-inline: 12px;
-
- &::before {
- content: '';
-
- position: absolute;
- z-index: -1;
- inset-block-start: 0;
- inset-inline: 0;
-
- height: var(--share-bar-height);
-
- background: ${cssVar.colorBgContainer};
- box-shadow: inset 0 -1px 0 ${cssVar.colorBorderSecondary};
- }
-
- > * {
- pointer-events: auto;
- }
- `,
- lane: css`
- --share-bar-height: clamp(
+const styles = stylex.create({
+ actions: { pointerEvents: 'auto' },
+ body: {
+ position: 'relative',
+ overflow: 'hidden',
+ paddingBlockStart: 'var(--share-bar-height)',
+ },
+ divider: {
+ flex: 'none',
+ width: '1px',
+ height: '16px',
+ backgroundColor: cssVar.colorFill,
+ backgroundImage: 'none',
+ },
+ header: {
+ 'pointerEvents': 'none',
+ 'position': 'absolute',
+ 'zIndex': 10,
+ 'insetBlockStart': 0,
+ 'insetInline': 0,
+ 'display': 'flex',
+ 'gap': '12px',
+ 'alignItems': 'center',
+ 'justifyContent': 'space-between',
+ 'height': `${HEADER_HEIGHT}px`,
+ 'paddingInline': '12px',
+ '::before': {
+ content: '""',
+ position: 'absolute',
+ zIndex: -1,
+ insetBlockStart: 0,
+ insetInline: 0,
+ height: 'var(--share-bar-height)',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ boxShadow: `inset 0 -1px 0 ${cssVar.colorBorderSecondary}`,
+ },
+ },
+ lane: {
+ '--share-bar-height': `clamp(
0px,
calc((var(--share-float-min, 100000px) - 100cqw) * 1000),
${HEADER_HEIGHT}px
- );
- --share-header-overlap: calc(${HEADER_HEIGHT}px - var(--share-bar-height));
-
- position: relative;
-
- container-type: inline-size;
- overflow: hidden;
- display: flex;
- flex: 1;
- flex-direction: column;
-
- min-width: 0;
-
- background: ${cssVar.colorBgContainer};
- `,
- lead: css`
- display: flex;
- flex: 0 1 auto;
- gap: 10px;
- align-items: center;
-
- min-width: 0;
- max-width: max(
+ )`,
+ '--share-header-overlap': `calc(${HEADER_HEIGHT}px - var(--share-bar-height))`,
+ 'position': 'relative',
+ 'containerType': 'inline-size',
+ 'overflow': 'hidden',
+ 'display': 'flex',
+ 'flex': '1',
+ 'flexDirection': 'column',
+ 'minWidth': '0',
+ 'backgroundColor': cssVar.colorBgContainer,
+ 'backgroundImage': 'none',
+ },
+ lead: {
+ pointerEvents: 'auto',
+ display: 'flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '10px',
+ alignItems: 'center',
+ minWidth: '0',
+ maxWidth: `max(
calc((100cqw - var(--share-content-width, 0px)) / 2 - 24px),
calc(var(--share-bar-height) * 1000)
- );
- `,
-}));
+ )`,
+ },
+});
export interface ShareLayoutProps {
actions?: ReactNode;
@@ -179,15 +173,15 @@ const ShareLayout = ({
return (
<Flexbox horizontal height={'100%'} style={{ overflow: 'hidden' }} width={'100%'}>
- <div className={styles.lane} style={laneStyle}>
- <header className={styles.header}>
- <div className={styles.lead}>
+ <div {...sx(styles.lane, undefined, laneStyle)}>
+ <header {...stylex.props(styles.header)}>
+ <div {...stylex.props(styles.lead)}>
<ShareLogoLink>
<ProductLogo size={24} />
</ShareLogoLink>
{title && !error && (
<>
- <span className={styles.divider} />
+ <span {...stylex.props(styles.divider)} />
<Text
ellipsis={{ tooltipWhenOverflow: true }}
fontSize={14}
@@ -199,7 +193,13 @@ const ShareLayout = ({
</>
)}
</div>
- <Flexbox horizontal align={'center'} flex={'none'} gap={2}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.actions).className}
+ flex={'none'}
+ gap={2}
+ >
<ShareHeaderActions
actions={!error && !loading ? actions : undefined}
compactActions={!error && !loading ? compactActions : undefined}
@@ -207,7 +207,7 @@ const ShareLayout = ({
/>
</Flexbox>
</header>
- <Flexbox className={styles.body} flex={1}>
+ <Flexbox className={stylex.props(styles.body).className} flex={1}>
{body}
</Flexbox>
</div>
diff --git a/apps/workbench/src/features/acceptance/AcceptanceDetail.tsx b/apps/workbench/src/features/acceptance/AcceptanceDetail.tsx
index 976bac70662..19095061250 100644
--- a/apps/workbench/src/features/acceptance/AcceptanceDetail.tsx
+++ b/apps/workbench/src/features/acceptance/AcceptanceDetail.tsx
@@ -1,8 +1,8 @@
'use client';
-import { Flexbox } from '@lobehub/ui';
-import { Text } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router';
@@ -20,40 +20,33 @@ import { useAcceptanceBundle } from '@/features/Acceptance/Viewer/useAcceptanceB
import { WorkbenchHeader } from '../../shell/WorkbenchHeader';
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- overflow: auto;
- flex: 1;
- min-height: 0;
- `,
- header: css`
- flex: none;
-
- min-height: 48px;
- padding-inline: 12px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgContainer};
- `,
- page: css`
- width: 100%;
- height: 100dvh;
- background: ${cssVar.colorBgContainer};
- `,
- report: css`
- width: 100%;
- max-width: 920px;
- margin-block: 0;
- margin-inline: auto;
- padding-block: 20px;
- padding-inline: 24px;
-
- @media (width <= 768px) {
- padding-block: 16px;
- padding-inline: 12px;
- }
- `,
-}));
+const styles = stylex.create({
+ body: { overflow: 'auto', flex: '1', minHeight: '0' },
+ header: {
+ flex: 'none',
+ minHeight: '48px',
+ paddingInline: '12px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ page: {
+ width: '100%',
+ height: '100dvh',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ report: {
+ width: '100%',
+ maxWidth: '920px',
+ marginBlock: '0',
+ marginInline: 'auto',
+ paddingBlock: { 'default': '20px', '@media (width <= 768px)': '16px' },
+ paddingInline: { 'default': '24px', '@media (width <= 768px)': '12px' },
+ },
+});
const Title = () => {
const { acceptanceId } = useParams<{ acceptanceId: string }>();
@@ -73,15 +66,15 @@ const WorkbenchAcceptanceDetail = () => {
return (
<AcceptanceScope acceptanceId={acceptanceId}>
- <Flexbox className={styles.page}>
- <Flexbox className={styles.header} justify={'center'}>
+ <Flexbox className={stylex.props(styles.page).className}>
+ <Flexbox className={stylex.props(styles.header).className} justify={'center'}>
<WorkbenchHeader>
<Title />
</WorkbenchHeader>
</Flexbox>
- <div className={styles.body}>
+ <div {...stylex.props(styles.body)}>
<AcceptanceBundleGate height={'100%'}>
- <Flexbox className={styles.report} gap={16}>
+ <Flexbox className={stylex.props(styles.report).className} gap={16}>
<Flexbox horizontal align={'flex-start'} gap={16} justify={'space-between'}>
<Flexbox flex={1} style={{ minWidth: 0 }}>
<AcceptanceIdentity />
diff --git a/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx b/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx
index 35cb2544acc..39c0e15d566 100644
--- a/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx
+++ b/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx
@@ -1,5 +1,7 @@
-import { Flexbox } from '@lobehub/ui';
-import { createStaticStyles, cssVar } from '@lobehub/ui';
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- Markdown evidence h1s get no className
+import { createStaticStyles, Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { useState } from 'react';
import { useParams } from 'react-router';
@@ -21,29 +23,32 @@ import AcceptanceTabs, {
import ReadChecks from '@/features/Acceptance/Viewer/ReadOnly/Checks';
import ReadDiscussion from '@/features/Acceptance/Viewer/ReadOnly/Discussion';
import { useAcceptanceBundle } from '@/features/Acceptance/Viewer/useAcceptanceBundle';
+import { sx } from '@/styles/sx';
-const styles = createStaticStyles(({ css }) => ({
- page: css`
- overflow: auto;
- width: 100%;
- height: 100dvh;
- background: ${cssVar.colorBgContainer};
- `,
- content: css`
- width: 100%;
- max-width: 1040px;
- margin-inline: auto;
- padding: 24px;
+const styles = stylex.create({
+ content: {
+ width: '100%',
+ maxWidth: '1040px',
+ marginInline: 'auto',
+ paddingBlock: { 'default': '24px', '@media (width <= 767px)': '16px' },
+ paddingInline: { 'default': '24px', '@media (width <= 767px)': '16px' },
+ },
+ page: {
+ overflow: 'auto',
+ width: '100%',
+ height: '100dvh',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+});
+const fallback = createStaticStyles(({ css }) => ({
+ content: css`
h1 {
overflow: visible;
overflow-wrap: anywhere;
white-space: normal;
}
-
- @media (width <= 767px) {
- padding: 16px;
- }
`,
}));
@@ -61,7 +66,7 @@ const EmbedContent = () => {
);
return (
- <Flexbox className={styles.content} gap={24}>
+ <Flexbox gap={24} {...sx(styles.content, fallback.content)}>
<AcceptanceIdentity />
<AcceptanceGoal />
<AcceptanceTabs
@@ -98,7 +103,7 @@ const AcceptanceEmbed = () => {
return (
<AcceptanceScope embedded acceptanceId={acceptanceId} key={acceptanceId}>
- <div data-acceptance-embed className={styles.page}>
+ <div data-acceptance-embed {...stylex.props(styles.page)}>
<AcceptanceBundleGate>
<EmbedContent />
</AcceptanceBundleGate>
diff --git a/apps/workbench/src/features/verify/VerifyReportUnavailable.tsx b/apps/workbench/src/features/verify/VerifyReportUnavailable.tsx
index 3bb2f1e703b..1a629ee1d80 100644
--- a/apps/workbench/src/features/verify/VerifyReportUnavailable.tsx
+++ b/apps/workbench/src/features/verify/VerifyReportUnavailable.tsx
@@ -2,34 +2,32 @@
import Empty from '@lobehub/ui/es/Empty/index';
import { Center, Flexbox } from '@lobehub/ui/es/Flex/index';
-import { createStaticStyles, cssVar } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ClipboardX } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { WorkbenchHeader } from '../../shell/WorkbenchHeader';
-const styles = createStaticStyles(({ css }) => ({
- body: css`
- flex: 1;
- min-height: 0;
- padding-block: 24px;
- padding-inline: 16px;
- `,
- header: css`
- flex: none;
-
- min-height: 48px;
- padding-inline: 12px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgContainer};
- `,
- page: css`
- width: 100%;
- height: 100dvh;
- background: ${cssVar.colorBgContainer};
- `,
-}));
+const styles = stylex.create({
+ body: { flex: '1', minHeight: '0', paddingBlock: '24px', paddingInline: '16px' },
+ header: {
+ flex: 'none',
+ minHeight: '48px',
+ paddingInline: '12px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ page: {
+ width: '100%',
+ height: '100dvh',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+});
/**
* What an old `/verify/:runId` link shows when it has nowhere to go: the run is
@@ -40,11 +38,11 @@ export const VerifyReportUnavailable = () => {
const { t } = useTranslation('verify');
return (
- <Flexbox className={styles.page}>
- <Flexbox className={styles.header} justify={'center'}>
+ <Flexbox className={stylex.props(styles.page).className}>
+ <Flexbox className={stylex.props(styles.header).className} justify={'center'}>
<WorkbenchHeader />
</Flexbox>
- <Center className={styles.body}>
+ <Center className={stylex.props(styles.body).className}>
<Empty
description={t('report.unavailable.description')}
icon={ClipboardX}
diff --git a/apps/workbench/src/shell/WorkbenchBrandLink.tsx b/apps/workbench/src/shell/WorkbenchBrandLink.tsx
index 8b5a4741816..11a21afcda8 100644
--- a/apps/workbench/src/shell/WorkbenchBrandLink.tsx
+++ b/apps/workbench/src/shell/WorkbenchBrandLink.tsx
@@ -1,38 +1,35 @@
'use client';
import { BRANDING_NAME } from '@lobechat/business-const';
-import { createStaticStyles, cssVar } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { ProductLogo } from '@/components/Branding';
-const styles = createStaticStyles(({ css }) => ({
- brand: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- box-sizing: content-box;
- padding: 4px;
- border-radius: ${cssVar.borderRadius};
-
- line-height: 0;
-
- transition: background 120ms ease;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- divider: css`
- flex: none;
- width: 1px;
- height: 16px;
- background: ${cssVar.colorBorderSecondary};
- `,
-}));
+const styles = stylex.create({
+ brand: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ boxSizing: 'content-box',
+ padding: '4px',
+ borderRadius: cssVar.borderRadius,
+ lineHeight: 0,
+ transition: 'background 120ms ease',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ divider: {
+ flex: 'none',
+ width: '1px',
+ height: '16px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+});
const WorkbenchBrandLink = memo(() => {
const { t } = useTranslation('verify');
@@ -40,10 +37,10 @@ const WorkbenchBrandLink = memo(() => {
return (
<>
- <a aria-label={label} className={styles.brand} href={'/'} title={label}>
+ <a aria-label={label} {...stylex.props(styles.brand)} href={'/'} title={label}>
<ProductLogo size={22} />
</a>
- <div className={styles.divider} />
+ <div {...stylex.props(styles.divider)} />
</>
);
});
diff --git a/apps/workbench/src/shell/WorkbenchHeader.tsx b/apps/workbench/src/shell/WorkbenchHeader.tsx
index 3a1fc6503b4..db1af83cafe 100644
--- a/apps/workbench/src/shell/WorkbenchHeader.tsx
+++ b/apps/workbench/src/shell/WorkbenchHeader.tsx
@@ -3,21 +3,13 @@
import { BRANDING_NAME } from '@lobechat/business-const';
import { Button } from '@lobehub/ui';
import { Flexbox } from '@lobehub/ui/es/Flex/index';
-import { createStaticStyles } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import WorkbenchBrandLink from './WorkbenchBrandLink';
-const styles = createStaticStyles(({ css }) => ({
- cta: css`
- flex: none;
- `,
- title: css`
- flex: 1;
- min-width: 0;
- `,
-}));
+const styles = stylex.create({ cta: { flex: 'none' }, title: { flex: '1', minWidth: '0' } });
interface WorkbenchHeaderProps {
children?: ReactNode;
@@ -29,8 +21,8 @@ export const WorkbenchHeader = ({ children }: WorkbenchHeaderProps) => {
return (
<Flexbox horizontal align={'center'} gap={8} width={'100%'}>
<WorkbenchBrandLink />
- <div className={styles.title}>{children}</div>
- <Button className={styles.cta} href={'/'} type={'primary'}>
+ <div {...stylex.props(styles.title)}>{children}</div>
+ <Button className={stylex.props(styles.cta).className} href={'/'} type={'primary'}>
{t('actions.goToApp', { name: BRANDING_NAME })}
</Button>
</Flexbox>
diff --git a/packages/shared-tool-ui/src/AskUserQuestion/AskUserQuestionView.tsx b/packages/shared-tool-ui/src/AskUserQuestion/AskUserQuestionView.tsx
index 93efca99031..ad62b2e7373 100644
--- a/packages/shared-tool-ui/src/AskUserQuestion/AskUserQuestionView.tsx
+++ b/packages/shared-tool-ui/src/AskUserQuestion/AskUserQuestionView.tsx
@@ -1,8 +1,7 @@
'use client';
-import { Flexbox, Hotkey, Icon, KeyMapEnum } from '@lobehub/ui';
-import { Button, Tabs, Text, TextArea } from '@lobehub/ui';
-import { createStaticStyles } from '@lobehub/ui';
+import { Button, Flexbox, Hotkey, Icon, KeyMapEnum, Tabs, Text, TextArea } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { Check, PenLine, Replace, Send, X } from 'lucide-react';
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
@@ -13,21 +12,14 @@ import QuestionPanel from './QuestionPanel';
import type { AskUserQuestionItem } from './types';
import type { AskUserFormApi } from './useAskUserForm';
+const styles = stylex.create({
+ tab: { marginInlineStart: { 'default': null, ':has([data-replace-all])': 'auto' } },
+ tabList: { width: '100%' },
+});
+
const optionValue = (option: AskUserQuestionItem['options'][number]): string =>
option.id ?? option.label;
-const styles = createStaticStyles(({ css }) => ({
- tabs: css`
- [role='tablist'] {
- width: 100%;
-
- > [role='tab']:has([data-replace-all]) {
- margin-inline-start: auto;
- }
- }
- `,
-}));
-
/**
* A focused interactive control keeps its native key activation — hijacking
* Enter/Space away from a tabbed-to button or link would invert the keyboard
@@ -326,8 +318,11 @@ export const AskUserQuestionView = memo<AskUserQuestionViewProps>((props) => {
{questions.length > 0 && (
<Tabs
activeKey={escapeActive ? 'escape' : supplementActive ? 'supplement' : activeTab}
- className={styles.tabs}
variant="square"
+ classNames={{
+ list: stylex.props(styles.tabList).className,
+ tab: stylex.props(styles.tab).className,
+ }}
items={[
...questions.map((q, idx) => {
const done = isQuestionAnswered(q, picks, custom);
diff --git a/packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx b/packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx
index 286e96b0938..aca0a668e61 100644
--- a/packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx
+++ b/packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx
@@ -1,112 +1,98 @@
'use client';
import type { BuiltinInspector, BuiltinInspectorProps } from '@lobechat/types';
-import { createStaticStyles, cx } from '@lobehub/ui';
+import { cx } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { GitBranch, Hash } from 'lucide-react';
import { memo } from 'react';
import { inspectorTextStyles, shinyTextStyles } from '../../styles';
import { parseGitHubToolName, staticGitHubLabelFor } from './labels';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- branchBadge: css`
- display: inline-flex;
- flex-shrink: 0;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
- margin-inline-start: 6px;
- padding-block: 2px;
- padding-inline: 8px;
- border-radius: 999px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- branchBadgeText: css`
- overflow: hidden;
- max-width: 220px;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- chip: css`
- overflow: hidden;
- display: inline-flex;
- flex-shrink: 1;
- align-items: stretch;
-
- min-width: 0;
- margin-inline-start: 6px;
- border-radius: 999px;
-
- font-size: 12px;
- line-height: 18px;
-
- background: ${cssVar.colorFillTertiary};
- `,
- chipAction: css`
- flex-shrink: 0;
- padding-block: 2px;
- padding-inline: 10px;
- color: ${cssVar.colorText};
- `,
- chipDivider: css`
- flex-shrink: 0;
- align-self: stretch;
- width: 1px;
- background: ${cssVar.colorBorderSecondary};
- `,
- chipIcon: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextDescription};
- `,
- chipKey: css`
- color: ${cssVar.colorTextDescription};
- `,
- chipValue: css`
- overflow: hidden;
- display: inline-flex;
- flex-shrink: 1;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
- padding-block: 2px;
- padding-inline: 10px;
-
- font-family: ${cssVar.fontFamilyCode};
- color: ${cssVar.colorText};
- `,
- chipValueText: css`
- overflow: hidden;
- min-width: 0;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- icon: css`
- flex-shrink: 0;
- margin-inline-end: 6px;
- color: ${cssVar.colorTextDescription};
- `,
- productPrefix: css`
- flex-shrink: 0;
-
- margin-inline-end: 2px;
-
- font-size: 13px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- `,
-}));
+const styles = stylex.create({
+ branchBadge: {
+ display: 'inline-flex',
+ flexShrink: 0,
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: '0',
+ marginInlineStart: '6px',
+ paddingBlock: '2px',
+ paddingInline: '8px',
+ borderRadius: '999px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorText,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ branchBadgeText: {
+ overflow: 'hidden',
+ maxWidth: '220px',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ chip: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexShrink: 1,
+ alignItems: 'stretch',
+ minWidth: '0',
+ marginInlineStart: '6px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ lineHeight: '18px',
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ chipAction: {
+ flexShrink: 0,
+ paddingBlock: '2px',
+ paddingInline: '10px',
+ color: cssVar.colorText,
+ },
+ chipDivider: {
+ flexShrink: 0,
+ alignSelf: 'stretch',
+ width: '1px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ chipIcon: { flexShrink: 0, color: cssVar.colorTextDescription },
+ chipKey: { color: cssVar.colorTextDescription },
+ chipValue: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexShrink: 1,
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: '0',
+ paddingBlock: '2px',
+ paddingInline: '10px',
+ fontFamily: cssVar.fontFamilyCode,
+ color: cssVar.colorText,
+ },
+ chipValueText: {
+ overflow: 'hidden',
+ minWidth: '0',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ icon: { flexShrink: 0, marginInlineEnd: '6px', color: cssVar.colorTextDescription },
+ productPrefix: {
+ flexShrink: 0,
+ marginInlineEnd: '2px',
+ fontSize: '13px',
+ fontWeight: 500,
+ color: cssVar.colorTextSecondary,
+ },
+});
const GitHubMark = memo<{ size?: number }>(({ size = 14 }) => (
<svg
aria-hidden="true"
- className={styles.icon}
+ {...stylex.props(styles.icon)}
height={size}
viewBox="0 0 98 96"
width={size}
@@ -224,32 +210,32 @@ const GitHubInspectorImpl = memo<BuiltinInspectorProps<Record<string, unknown>>>
<GitHubMark />
<span
className={cx(
- styles.productPrefix,
+ stylex.props(styles.productPrefix).className,
(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
)}
>
GitHub
</span>
- <span className={styles.chip}>
- <span className={styles.chipAction}>{label}</span>
+ <span {...stylex.props(styles.chip)}>
+ <span {...stylex.props(styles.chipAction)}>{label}</span>
{primary && (
<>
- <span className={styles.chipDivider} />
- <span className={styles.chipValue}>
+ <span {...stylex.props(styles.chipDivider)} />
+ <span {...stylex.props(styles.chipValue)}>
{primary.iconType === 'number' ? (
- <Hash className={styles.chipIcon} size={12} />
+ <Hash className={stylex.props(styles.chipIcon).className} size={12} />
) : (
- primary.key && <span className={styles.chipKey}>{primary.key}:</span>
+ primary.key && <span {...stylex.props(styles.chipKey)}>{primary.key}:</span>
)}
- <span className={styles.chipValueText}>{primary.value}</span>
+ <span {...stylex.props(styles.chipValueText)}>{primary.value}</span>
</span>
</>
)}
</span>
{branch && (
- <span className={styles.branchBadge} title={branch}>
- <GitBranch className={styles.chipIcon} size={12} />
- <span className={styles.branchBadgeText}>{branch}</span>
+ <span {...stylex.props(styles.branchBadge)} title={branch}>
+ <GitBranch className={stylex.props(styles.chipIcon).className} size={12} />
+ <span {...stylex.props(styles.branchBadgeText)}>{branch}</span>
</span>
)}
</div>
diff --git a/packages/shared-tool-ui/src/Inspector/Linear/Inspector.tsx b/packages/shared-tool-ui/src/Inspector/Linear/Inspector.tsx
index 19503be0e93..acbabc1dcb9 100644
--- a/packages/shared-tool-ui/src/Inspector/Linear/Inspector.tsx
+++ b/packages/shared-tool-ui/src/Inspector/Linear/Inspector.tsx
@@ -1,109 +1,92 @@
'use client';
import type { BuiltinInspector, BuiltinInspectorProps } from '@lobechat/types';
-import { createStaticStyles, cx } from '@lobehub/ui';
+import { cx } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { CornerLeftUp } from 'lucide-react';
import { memo } from 'react';
import { inspectorTextStyles, shinyTextStyles } from '../../styles';
import { capitalize, type ParsedTool, parseToolName } from './labels';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- chip: css`
- overflow: hidden;
- display: inline-flex;
- flex-shrink: 1;
- align-items: stretch;
-
- min-width: 0;
- margin-inline-start: 6px;
- border-radius: 999px;
-
- font-size: 12px;
- line-height: 18px;
-
- background: ${cssVar.colorFillTertiary};
- `,
- chipAction: css`
- flex-shrink: 0;
- padding-block: 2px;
- padding-inline: 10px;
- color: ${cssVar.colorText};
- `,
- chipDivider: css`
- flex-shrink: 0;
- align-self: stretch;
- width: 1px;
- background: ${cssVar.colorBorderSecondary};
- `,
- chipIcon: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextDescription};
- `,
- chipKey: css`
- color: ${cssVar.colorTextDescription};
- `,
- chipValue: css`
- overflow: hidden;
- display: inline-flex;
- flex-shrink: 1;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
- padding-block: 2px;
- padding-inline: 10px;
-
- font-family: ${cssVar.fontFamilyCode};
- color: ${cssVar.colorText};
- `,
- chipValueText: css`
- overflow: hidden;
- min-width: 0;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- icon: css`
- flex-shrink: 0;
- margin-inline-end: 6px;
- color: ${cssVar.colorTextDescription};
- `,
- parentBadge: css`
- display: inline-flex;
- flex-shrink: 0;
- gap: 4px;
- align-items: center;
-
- margin-inline-start: 6px;
- padding-block: 2px;
- padding-inline: 8px;
- border-radius: 999px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- parentBadgeIcon: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextDescription};
- `,
- productPrefix: css`
- flex-shrink: 0;
-
- margin-inline-end: 2px;
-
- font-size: 13px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- `,
-}));
+const styles = stylex.create({
+ chip: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexShrink: 1,
+ alignItems: 'stretch',
+ minWidth: '0',
+ marginInlineStart: '6px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ lineHeight: '18px',
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ chipAction: {
+ flexShrink: 0,
+ paddingBlock: '2px',
+ paddingInline: '10px',
+ color: cssVar.colorText,
+ },
+ chipDivider: {
+ flexShrink: 0,
+ alignSelf: 'stretch',
+ width: '1px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ chipIcon: { flexShrink: 0, color: cssVar.colorTextDescription },
+ chipKey: { color: cssVar.colorTextDescription },
+ chipValue: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexShrink: 1,
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: '0',
+ paddingBlock: '2px',
+ paddingInline: '10px',
+ fontFamily: cssVar.fontFamilyCode,
+ color: cssVar.colorText,
+ },
+ chipValueText: {
+ overflow: 'hidden',
+ minWidth: '0',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ icon: { flexShrink: 0, marginInlineEnd: '6px', color: cssVar.colorTextDescription },
+ parentBadge: {
+ display: 'inline-flex',
+ flexShrink: 0,
+ gap: '4px',
+ alignItems: 'center',
+ marginInlineStart: '6px',
+ paddingBlock: '2px',
+ paddingInline: '8px',
+ borderRadius: '999px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorText,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ parentBadgeIcon: { flexShrink: 0, color: cssVar.colorTextDescription },
+ productPrefix: {
+ flexShrink: 0,
+ marginInlineEnd: '2px',
+ fontSize: '13px',
+ fontWeight: 500,
+ color: cssVar.colorTextSecondary,
+ },
+});
const LinearLogomark = memo<{ size?: number }>(({ size = 14 }) => (
<svg
aria-hidden="true"
- className={styles.icon}
+ {...stylex.props(styles.icon)}
height={size}
viewBox="0 0 100 100"
width={size}
@@ -247,31 +230,31 @@ const LinearInspectorImpl = memo<BuiltinInspectorProps<Record<string, unknown>>>
<LinearLogomark />
<span
className={cx(
- styles.productPrefix,
+ stylex.props(styles.productPrefix).className,
(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
)}
>
Linear
</span>
- <span className={styles.chip}>
- <span className={styles.chipAction}>{label}</span>
+ <span {...stylex.props(styles.chip)}>
+ <span {...stylex.props(styles.chipAction)}>{label}</span>
{primary && (
<>
- <span className={styles.chipDivider} />
- <span className={styles.chipValue}>
+ <span {...stylex.props(styles.chipDivider)} />
+ <span {...stylex.props(styles.chipValue)}>
{primary.iconType === 'parent' ? (
- <CornerLeftUp className={styles.chipIcon} size={12} />
+ <CornerLeftUp className={stylex.props(styles.chipIcon).className} size={12} />
) : (
- primary.key && <span className={styles.chipKey}>{primary.key}:</span>
+ primary.key && <span {...stylex.props(styles.chipKey)}>{primary.key}:</span>
)}
- <span className={styles.chipValueText}>{primary.value}</span>
+ <span {...stylex.props(styles.chipValueText)}>{primary.value}</span>
</span>
</>
)}
</span>
{parentId && (
- <span className={styles.parentBadge} title={`parent: ${parentId}`}>
- <CornerLeftUp className={styles.parentBadgeIcon} size={12} />
+ <span {...stylex.props(styles.parentBadge)} title={`parent: ${parentId}`}>
+ <CornerLeftUp className={stylex.props(styles.parentBadgeIcon).className} size={12} />
<span>{parentId}</span>
</span>
)}
diff --git a/packages/shared-tool-ui/src/Inspector/Twitter/Inspector.tsx b/packages/shared-tool-ui/src/Inspector/Twitter/Inspector.tsx
index d132dc40a7b..206b7fed71c 100644
--- a/packages/shared-tool-ui/src/Inspector/Twitter/Inspector.tsx
+++ b/packages/shared-tool-ui/src/Inspector/Twitter/Inspector.tsx
@@ -1,83 +1,74 @@
'use client';
import type { BuiltinInspector, BuiltinInspectorProps } from '@lobechat/types';
-import { createStaticStyles, cx } from '@lobehub/ui';
+import { cx } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { inspectorTextStyles, shinyTextStyles } from '../../styles';
import { type ParsedTwitterTool, parseTwitterToolName, staticTwitterLabelFor } from './labels';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- chip: css`
- overflow: hidden;
- display: inline-flex;
- flex-shrink: 1;
- align-items: stretch;
-
- min-width: 0;
- margin-inline-start: 6px;
- border-radius: 999px;
-
- font-size: 12px;
- line-height: 18px;
-
- background: ${cssVar.colorFillTertiary};
- `,
- chipAction: css`
- flex-shrink: 0;
- padding-block: 2px;
- padding-inline: 10px;
- color: ${cssVar.colorText};
- `,
- chipDivider: css`
- flex-shrink: 0;
- align-self: stretch;
- width: 1px;
- background: ${cssVar.colorBorderSecondary};
- `,
- chipKey: css`
- color: ${cssVar.colorTextDescription};
- `,
- chipValue: css`
- overflow: hidden;
- display: inline-flex;
- flex-shrink: 1;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
- padding-block: 2px;
- padding-inline: 10px;
-
- font-family: ${cssVar.fontFamilyCode};
- color: ${cssVar.colorText};
- `,
- chipValueText: css`
- overflow: hidden;
- min-width: 0;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- icon: css`
- flex-shrink: 0;
- margin-inline-end: 6px;
- color: ${cssVar.colorTextDescription};
- `,
- productPrefix: css`
- flex-shrink: 0;
-
- margin-inline-end: 2px;
-
- font-size: 13px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- `,
-}));
+const styles = stylex.create({
+ chip: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexShrink: 1,
+ alignItems: 'stretch',
+ minWidth: '0',
+ marginInlineStart: '6px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ lineHeight: '18px',
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ chipAction: {
+ flexShrink: 0,
+ paddingBlock: '2px',
+ paddingInline: '10px',
+ color: cssVar.colorText,
+ },
+ chipDivider: {
+ flexShrink: 0,
+ alignSelf: 'stretch',
+ width: '1px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ chipKey: { color: cssVar.colorTextDescription },
+ chipValue: {
+ overflow: 'hidden',
+ display: 'inline-flex',
+ flexShrink: 1,
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: '0',
+ paddingBlock: '2px',
+ paddingInline: '10px',
+ fontFamily: cssVar.fontFamilyCode,
+ color: cssVar.colorText,
+ },
+ chipValueText: {
+ overflow: 'hidden',
+ minWidth: '0',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ icon: { flexShrink: 0, marginInlineEnd: '6px', color: cssVar.colorTextDescription },
+ productPrefix: {
+ flexShrink: 0,
+ marginInlineEnd: '2px',
+ fontSize: '13px',
+ fontWeight: 500,
+ color: cssVar.colorTextSecondary,
+ },
+});
const XLogomark = memo<{ size?: number }>(({ size = 14 }) => (
<svg
aria-hidden="true"
- className={styles.icon}
+ {...stylex.props(styles.icon)}
height={size}
viewBox="0 0 1200 1227"
width={size}
@@ -160,20 +151,20 @@ const TwitterInspectorImpl = memo<BuiltinInspectorProps<Record<string, unknown>>
<XLogomark />
<span
className={cx(
- styles.productPrefix,
+ stylex.props(styles.productPrefix).className,
(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
)}
>
X (Twitter)
</span>
- <span className={styles.chip}>
- <span className={styles.chipAction}>{label}</span>
+ <span {...stylex.props(styles.chip)}>
+ <span {...stylex.props(styles.chipAction)}>{label}</span>
{primary && (
<>
- <span className={styles.chipDivider} />
- <span className={styles.chipValue}>
- {primary.key && <span className={styles.chipKey}>{primary.key}:</span>}
- <span className={styles.chipValueText}>{primary.value}</span>
+ <span {...stylex.props(styles.chipDivider)} />
+ <span {...stylex.props(styles.chipValue)}>
+ {primary.key && <span {...stylex.props(styles.chipKey)}>{primary.key}:</span>}
+ <span {...stylex.props(styles.chipValueText)}>{primary.value}</span>
</span>
</>
)}
diff --git a/packages/shared-tool-ui/src/Render/GitHub/index.tsx b/packages/shared-tool-ui/src/Render/GitHub/index.tsx
index 0ad032d89d8..57295e8d242 100644
--- a/packages/shared-tool-ui/src/Render/GitHub/index.tsx
+++ b/packages/shared-tool-ui/src/Render/GitHub/index.tsx
@@ -2,9 +2,9 @@
import type { BuiltinRenderProps } from '@lobechat/types';
import { fromNow } from '@lobechat/utils/time';
-import { Block, Flexbox, Highlighter, Icon, Markdown } from '@lobehub/ui';
-import { Tag, Text } from '@lobehub/ui';
-import { createStaticStyles } from '@lobehub/ui';
+import { Block, Flexbox, Highlighter, Icon, Markdown, Tag, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ExternalLink, Link2 } from 'lucide-react';
import type { ReactNode } from 'react';
import { memo, useMemo } from 'react';
@@ -18,131 +18,89 @@ import {
type GitHubLink,
} from './utils';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- overflow: hidden;
- min-width: 0;
- `,
- description: css`
- overflow: auto;
-
- max-height: 180px;
- padding-block: 8px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 6px;
-
- background: ${cssVar.colorFillQuaternary};
- `,
- entityHeader: css`
- display: flex;
- gap: 12px;
- align-items: center;
- justify-content: space-between;
-
- min-width: 0;
- `,
- headLeft: css`
- display: flex;
- gap: 6px;
- align-items: center;
- min-width: 0;
- `,
- linkRow: css`
- overflow: hidden;
- display: flex;
- gap: 8px;
- align-items: center;
-
- min-width: 0;
- padding-block: 6px;
- padding-inline: 8px;
- border-radius: 6px;
-
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillQuaternary};
-
- &:hover {
- color: ${cssVar.colorLink};
- background: ${cssVar.colorFillTertiary};
- }
- `,
- linkText: css`
- overflow: hidden;
- min-width: 0;
- `,
- metaItem: css`
- display: inline-flex;
- gap: 4px;
- align-items: baseline;
-
- min-width: 0;
-
- font-size: 12px;
- line-height: 1.5;
- `,
- metaLabel: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- metaRow: css`
- display: flex;
- flex-wrap: wrap;
- gap: 4px 16px;
- align-items: baseline;
-
- min-width: 0;
- `,
- metaValue: css`
- overflow: hidden;
-
- min-width: 0;
-
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- rawDetails: css`
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- summary {
- cursor: pointer;
- width: fit-content;
- margin-block-end: 6px;
- }
- `,
- sectionLabel: css`
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- timeItem: css`
- flex-shrink: 0;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- white-space: nowrap;
- `,
- titleLink: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
-
- color: inherit;
-
- &:hover {
- color: ${cssVar.colorLink};
- }
- `,
-}));
+const styles = stylex.create({
+ container: { overflow: 'hidden', minWidth: '0' },
+ description: {
+ overflow: 'auto',
+ maxHeight: '180px',
+ paddingBlock: '8px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '6px',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ entityHeader: {
+ display: 'flex',
+ gap: '12px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ minWidth: '0',
+ },
+ headLeft: { display: 'flex', gap: '6px', alignItems: 'center', minWidth: '0' },
+ linkRow: {
+ overflow: 'hidden',
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ minWidth: '0',
+ paddingBlock: '6px',
+ paddingInline: '8px',
+ borderRadius: '6px',
+ color: { 'default': cssVar.colorText, ':hover': cssVar.colorLink },
+ backgroundColor: { 'default': cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ linkText: { overflow: 'hidden', minWidth: '0' },
+ metaItem: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'baseline',
+ minWidth: '0',
+ fontSize: '12px',
+ lineHeight: 1.5,
+ },
+ metaLabel: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ metaRow: {
+ display: 'flex',
+ flexWrap: 'wrap',
+ rowGap: '4px',
+ columnGap: '16px',
+ alignItems: 'baseline',
+ minWidth: '0',
+ },
+ metaValue: {
+ overflow: 'hidden',
+ minWidth: '0',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ rawDetails: { fontSize: '12px', color: cssVar.colorTextSecondary },
+ rawSummary: { cursor: 'pointer', width: 'fit-content', marginBlockEnd: '6px' },
+ sectionLabel: { fontSize: '12px', color: cssVar.colorTextSecondary },
+ timeItem: {
+ flexShrink: 0,
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ whiteSpace: 'nowrap',
+ },
+ titleLink: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: '0',
+ color: { 'default': 'inherit', ':hover': cssVar.colorLink },
+ },
+});
const hasItems = <T,>(items: T[]) => items.length > 0;
const Section = memo<{ children: ReactNode; title: string }>(({ children, title }) => (
<Flexbox gap={6}>
- <Text className={styles.sectionLabel}>{title}</Text>
+ <Text className={stylex.props(styles.sectionLabel).className}>{title}</Text>
{children}
</Flexbox>
));
@@ -152,11 +110,11 @@ const MetaRow = memo<{ fields: GitHubField[] }>(({ fields }) => {
if (!hasItems(fields)) return null;
return (
- <div className={styles.metaRow}>
+ <div {...stylex.props(styles.metaRow)}>
{fields.map((field) => (
- <span className={styles.metaItem} key={`${field.key}:${field.value}`}>
- <span className={styles.metaLabel}>{field.label}</span>
- <span className={styles.metaValue} title={field.value}>
+ <span {...stylex.props(styles.metaItem)} key={`${field.key}:${field.value}`}>
+ <span {...stylex.props(styles.metaLabel)}>{field.label}</span>
+ <span {...stylex.props(styles.metaValue)} title={field.value}>
{field.value}
</span>
</span>
@@ -173,14 +131,14 @@ const LinkList = memo<{ links: GitHubLink[] }>(({ links }) => {
<Flexbox gap={4}>
{links.map((link) => (
<a
- className={styles.linkRow}
+ {...stylex.props(styles.linkRow)}
href={link.url}
key={`${link.title}:${link.url}`}
rel={'noreferrer'}
target={'_blank'}
>
<Icon icon={Link2} size={13} />
- <Text ellipsis className={styles.linkText} title={link.title}>
+ <Text ellipsis className={stylex.props(styles.linkText).className} title={link.title}>
{link.title}
</Text>
<Icon icon={ExternalLink} size={12} />
@@ -197,12 +155,17 @@ const EntityCard = memo<{ entity: GitHubEntity }>(({ entity }) => {
return (
<Block gap={8} padding={10} variant={'outlined'} width={'100%'}>
- <div className={styles.entityHeader}>
- <div className={styles.headLeft}>
+ <div {...stylex.props(styles.entityHeader)}>
+ <div {...stylex.props(styles.headLeft)}>
<Tag size={'small'}>{kind}</Tag>
{title &&
(url ? (
- <a className={styles.titleLink} href={url} rel={'noreferrer'} target={'_blank'}>
+ <a
+ {...stylex.props(styles.titleLink)}
+ href={url}
+ rel={'noreferrer'}
+ target={'_blank'}
+ >
<Text ellipsis weight={600}>
{title}
</Text>
@@ -221,14 +184,14 @@ const EntityCard = memo<{ entity: GitHubEntity }>(({ entity }) => {
)}
</div>
{updatedAt && (
- <span className={styles.timeItem} title={formatIsoDate(updatedAt)}>
+ <span {...stylex.props(styles.timeItem)} title={formatIsoDate(updatedAt)}>
{t('builtins.github.render.updatedAt', { time: fromNow(updatedAt) })}
</span>
)}
</div>
<MetaRow fields={entity.fields} />
{entity.description && (
- <div className={styles.description}>
+ <div {...stylex.props(styles.description)}>
<Markdown fontSize={13} variant={'chat'}>
{entity.description}
</Markdown>
@@ -253,7 +216,7 @@ const GitHubRender = memo<BuiltinRenderProps<Record<string, unknown>, unknown, u
if (!hasResult && !model.errorText) return null;
return (
- <Flexbox className={styles.container} gap={12}>
+ <Flexbox className={stylex.props(styles.container).className} gap={12}>
{hasItems(model.resultEntities) && (
<Flexbox gap={8}>
{model.resultEntities.map((entity, index) => (
@@ -276,8 +239,10 @@ const GitHubRender = memo<BuiltinRenderProps<Record<string, unknown>, unknown, u
</Highlighter>
)}
{model.rawResultJson && (
- <details className={styles.rawDetails}>
- <summary>{t('builtins.github.render.rawResult')}</summary>
+ <details {...stylex.props(styles.rawDetails)}>
+ <summary {...stylex.props(styles.rawSummary)}>
+ {t('builtins.github.render.rawResult')}
+ </summary>
<Highlighter
wrap
language={'json'}
diff --git a/packages/shared-tool-ui/src/Render/Linear/index.tsx b/packages/shared-tool-ui/src/Render/Linear/index.tsx
index c438b3c9177..0b3ff00c52a 100644
--- a/packages/shared-tool-ui/src/Render/Linear/index.tsx
+++ b/packages/shared-tool-ui/src/Render/Linear/index.tsx
@@ -2,9 +2,9 @@
import type { BuiltinRenderProps } from '@lobechat/types';
import { fromNow } from '@lobechat/utils/time';
-import { Block, Flexbox, Highlighter, Icon, Markdown } from '@lobehub/ui';
-import { Tag, Text } from '@lobehub/ui';
-import { createStaticStyles } from '@lobehub/ui';
+import { Block, Flexbox, Highlighter, Icon, Markdown, Tag, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ExternalLink, Inbox, Link2 } from 'lucide-react';
import type { ReactNode } from 'react';
import { memo, useMemo } from 'react';
@@ -19,146 +19,104 @@ import {
type LinearLink,
} from './utils';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- overflow: hidden;
- min-width: 0;
- `,
- description: css`
- overflow: auto;
-
- max-height: 180px;
- padding-block: 8px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 6px;
-
- background: ${cssVar.colorFillQuaternary};
- `,
- empty: css`
- display: flex;
- gap: 6px;
- align-items: center;
- justify-content: center;
-
- padding-block: 16px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 6px;
-
- font-size: 13px;
- color: ${cssVar.colorTextTertiary};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- entityHeader: css`
- display: flex;
- gap: 12px;
- align-items: center;
- justify-content: space-between;
-
- min-width: 0;
- `,
- headLeft: css`
- display: flex;
- gap: 6px;
- align-items: center;
- min-width: 0;
- `,
- timeItem: css`
- flex-shrink: 0;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- white-space: nowrap;
- `,
- metaItem: css`
- display: inline-flex;
- gap: 4px;
- align-items: baseline;
-
- min-width: 0;
-
- font-size: 12px;
- line-height: 1.5;
- `,
- metaLabel: css`
- flex-shrink: 0;
- color: ${cssVar.colorTextTertiary};
- `,
- metaRow: css`
- display: flex;
- flex-wrap: wrap;
- gap: 4px 16px;
- align-items: baseline;
-
- min-width: 0;
- `,
- metaValue: css`
- overflow: hidden;
-
- min-width: 0;
-
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- linkRow: css`
- overflow: hidden;
- display: flex;
- gap: 8px;
- align-items: center;
-
- min-width: 0;
- padding-block: 6px;
- padding-inline: 8px;
- border-radius: 6px;
-
- color: ${cssVar.colorText};
-
- background: ${cssVar.colorFillQuaternary};
-
- &:hover {
- color: ${cssVar.colorLink};
- background: ${cssVar.colorFillTertiary};
- }
- `,
- linkText: css`
- overflow: hidden;
- min-width: 0;
- `,
- rawDetails: css`
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- summary {
- cursor: pointer;
- width: fit-content;
- margin-block-end: 6px;
- }
- `,
- sectionLabel: css`
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- titleLink: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
-
- color: inherit;
-
- &:hover {
- color: ${cssVar.colorLink};
- }
- `,
-}));
+const styles = stylex.create({
+ container: { overflow: 'hidden', minWidth: '0' },
+ description: {
+ overflow: 'auto',
+ maxHeight: '180px',
+ paddingBlock: '8px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '6px',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ empty: {
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ justifyContent: 'center',
+ paddingBlock: '16px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '6px',
+ fontSize: '13px',
+ color: cssVar.colorTextTertiary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ entityHeader: {
+ display: 'flex',
+ gap: '12px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ minWidth: '0',
+ },
+ headLeft: { display: 'flex', gap: '6px', alignItems: 'center', minWidth: '0' },
+ timeItem: {
+ flexShrink: 0,
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ whiteSpace: 'nowrap',
+ },
+ metaItem: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'baseline',
+ minWidth: '0',
+ fontSize: '12px',
+ lineHeight: 1.5,
+ },
+ metaLabel: { flexShrink: 0, color: cssVar.colorTextTertiary },
+ metaRow: {
+ display: 'flex',
+ flexWrap: 'wrap',
+ rowGap: '4px',
+ columnGap: '16px',
+ alignItems: 'baseline',
+ minWidth: '0',
+ },
+ metaValue: {
+ overflow: 'hidden',
+ minWidth: '0',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ linkRow: {
+ overflow: 'hidden',
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ minWidth: '0',
+ paddingBlock: '6px',
+ paddingInline: '8px',
+ borderRadius: '6px',
+ color: { 'default': cssVar.colorText, ':hover': cssVar.colorLink },
+ backgroundColor: { 'default': cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ linkText: { overflow: 'hidden', minWidth: '0' },
+ rawDetails: { fontSize: '12px', color: cssVar.colorTextSecondary },
+ rawSummary: { cursor: 'pointer', width: 'fit-content', marginBlockEnd: '6px' },
+ sectionLabel: { fontSize: '12px', color: cssVar.colorTextSecondary },
+ titleLink: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ minWidth: '0',
+ color: { 'default': 'inherit', ':hover': cssVar.colorLink },
+ },
+});
const hasItems = <T,>(items: T[]) => items.length > 0;
const Section = memo<{ children: ReactNode; title: string }>(({ children, title }) => (
<Flexbox gap={6}>
- <Text className={styles.sectionLabel}>{title}</Text>
+ <Text className={stylex.props(styles.sectionLabel).className}>{title}</Text>
{children}
</Flexbox>
));
@@ -168,11 +126,11 @@ const MetaRow = memo<{ fields: LinearField[] }>(({ fields }) => {
if (!hasItems(fields)) return null;
return (
- <div className={styles.metaRow}>
+ <div {...stylex.props(styles.metaRow)}>
{fields.map((field) => (
- <span className={styles.metaItem} key={`${field.key}:${field.value}`}>
- <span className={styles.metaLabel}>{field.label}</span>
- <span className={styles.metaValue} title={field.value}>
+ <span {...stylex.props(styles.metaItem)} key={`${field.key}:${field.value}`}>
+ <span {...stylex.props(styles.metaLabel)}>{field.label}</span>
+ <span {...stylex.props(styles.metaValue)} title={field.value}>
{field.value}
</span>
</span>
@@ -189,14 +147,14 @@ const LinkList = memo<{ links: LinearLink[] }>(({ links }) => {
<Flexbox gap={4}>
{links.map((link) => (
<a
- className={styles.linkRow}
+ {...stylex.props(styles.linkRow)}
href={link.url}
key={`${link.title}:${link.url}`}
rel={'noreferrer'}
target={'_blank'}
>
<Icon icon={Link2} size={13} />
- <Text ellipsis className={styles.linkText} title={link.title}>
+ <Text ellipsis className={stylex.props(styles.linkText).className} title={link.title}>
{link.title}
</Text>
<Icon icon={ExternalLink} size={12} />
@@ -218,11 +176,16 @@ const EntityCard = memo<{ entity: LinearEntity }>(({ entity }) => {
return (
<Block gap={8} padding={10} variant={'outlined'} width={'100%'}>
- <div className={styles.entityHeader}>
- <div className={styles.headLeft}>
+ <div {...stylex.props(styles.entityHeader)}>
+ <div {...stylex.props(styles.headLeft)}>
{title &&
(url ? (
- <a className={styles.titleLink} href={url} rel={'noreferrer'} target={'_blank'}>
+ <a
+ {...stylex.props(styles.titleLink)}
+ href={url}
+ rel={'noreferrer'}
+ target={'_blank'}
+ >
<Text ellipsis weight={600}>
{title}
</Text>
@@ -235,7 +198,12 @@ const EntityCard = memo<{ entity: LinearEntity }>(({ entity }) => {
))}
{showId &&
(url && !title ? (
- <a className={styles.titleLink} href={url} rel={'noreferrer'} target={'_blank'}>
+ <a
+ {...stylex.props(styles.titleLink)}
+ href={url}
+ rel={'noreferrer'}
+ target={'_blank'}
+ >
<Tag size={'small'}>{id}</Tag>
<Icon icon={ExternalLink} size={12} />
</a>
@@ -249,14 +217,14 @@ const EntityCard = memo<{ entity: LinearEntity }>(({ entity }) => {
)}
</div>
{updatedAt && (
- <span className={styles.timeItem} title={formatIsoDate(updatedAt)}>
+ <span {...stylex.props(styles.timeItem)} title={formatIsoDate(updatedAt)}>
{t('builtins.linear.render.updatedAt', { time: fromNow(updatedAt) })}
</span>
)}
</div>
<MetaRow fields={entity.fields} />
{entity.description && (
- <div className={styles.description}>
+ <div {...stylex.props(styles.description)}>
<Markdown fontSize={13} variant={'chat'}>
{entity.description}
</Markdown>
@@ -286,7 +254,7 @@ const LinearRender = memo<BuiltinRenderProps<Record<string, unknown>, unknown, u
if (!hasResult && !model.errorText) return null;
return (
- <Flexbox className={styles.container} gap={12}>
+ <Flexbox className={stylex.props(styles.container).className} gap={12}>
{hasItems(model.resultEntities) && (
<Flexbox gap={8}>
{model.resultEntities.map((entity, index) => (
@@ -298,7 +266,7 @@ const LinearRender = memo<BuiltinRenderProps<Record<string, unknown>, unknown, u
</Flexbox>
)}
{model.emptyCollectionKey && (
- <div className={styles.empty}>
+ <div {...stylex.props(styles.empty)}>
<Icon icon={Inbox} size={14} />
<span>
{t('builtins.linear.render.empty', { collection: model.emptyCollectionKey })}
@@ -317,8 +285,8 @@ const LinearRender = memo<BuiltinRenderProps<Record<string, unknown>, unknown, u
</Highlighter>
)}
{model.rawResultJson && (
- <details className={styles.rawDetails}>
- <summary>Raw result</summary>
+ <details {...stylex.props(styles.rawDetails)}>
+ <summary {...stylex.props(styles.rawSummary)}>Raw result</summary>
<Highlighter
wrap
language={'json'}
diff --git a/packages/shared-tool-ui/src/components/FileChangeStats/index.tsx b/packages/shared-tool-ui/src/components/FileChangeStats/index.tsx
index 5567de35d81..32cc0986806 100644
--- a/packages/shared-tool-ui/src/components/FileChangeStats/index.tsx
+++ b/packages/shared-tool-ui/src/components/FileChangeStats/index.tsx
@@ -1,6 +1,8 @@
'use client';
-import { createStaticStyles, cssVar, cx } from '@lobehub/ui';
+import { cx } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
/**
@@ -13,51 +15,33 @@ import { memo } from 'react';
/** Change kind shared by the codex file-change and edited-files renderers. */
export type FileChangeKind = 'added' | 'deleted' | 'modified' | 'renamed';
-const styles = createStaticStyles(({ css }) => ({
- kindAdded: css`
- background: ${cssVar.colorSuccess};
- `,
- kindDeleted: css`
- background: ${cssVar.colorError};
- `,
- kindDot: css`
- flex-shrink: 0;
- width: 8px;
- height: 8px;
- border-radius: 999px;
- `,
- kindModified: css`
- background: ${cssVar.colorInfo};
- `,
- kindRenamed: css`
- background: ${cssVar.colorWarning};
- `,
- lineAdded: css`
- color: ${cssVar.colorSuccess};
- `,
- lineDeleted: css`
- color: ${cssVar.colorError};
- `,
- lineStats: css`
- display: inline-flex;
- flex-shrink: 0;
- gap: 6px;
- align-items: center;
-
- font-size: 12px;
- `,
-}));
+const styles = stylex.create({
+ kindAdded: { backgroundColor: cssVar.colorSuccess, backgroundImage: 'none' },
+ kindDeleted: { backgroundColor: cssVar.colorError, backgroundImage: 'none' },
+ kindDot: { flexShrink: 0, width: '8px', height: '8px', borderRadius: '999px' },
+ kindModified: { backgroundColor: cssVar.colorInfo, backgroundImage: 'none' },
+ kindRenamed: { backgroundColor: cssVar.colorWarning, backgroundImage: 'none' },
+ lineAdded: { color: cssVar.colorSuccess },
+ lineDeleted: { color: cssVar.colorError },
+ lineStats: {
+ display: 'inline-flex',
+ flexShrink: 0,
+ gap: '6px',
+ alignItems: 'center',
+ fontSize: '12px',
+ },
+});
-const KIND_CLASS: Record<FileChangeKind, string> = {
+const KIND_STYLE = {
added: styles.kindAdded,
deleted: styles.kindDeleted,
modified: styles.kindModified,
renamed: styles.kindRenamed,
-};
+} as const satisfies Record<FileChangeKind, unknown>;
/** A small color-coded dot indicating a file's change kind. */
export const KindDot = memo<{ className?: string; kind: FileChangeKind }>(({ className, kind }) => (
- <span className={cx(styles.kindDot, KIND_CLASS[kind], className)} />
+ <span className={cx(stylex.props(styles.kindDot, KIND_STYLE[kind]).className, className)} />
));
KindDot.displayName = 'FileChangeKindDot';
@@ -81,9 +65,9 @@ export const LineStats = memo<LineStatsProps>(
const showDeleted = !hideZeroDeltas || linesDeleted > 0;
return (
- <span className={cx(styles.lineStats, className)}>
- {showAdded && <span className={styles.lineAdded}>+{linesAdded}</span>}
- {showDeleted && <span className={styles.lineDeleted}>-{linesDeleted}</span>}
+ <span className={cx(stylex.props(styles.lineStats).className, className)}>
+ {showAdded && <span {...stylex.props(styles.lineAdded)}>+{linesAdded}</span>}
+ {showDeleted && <span {...stylex.props(styles.lineDeleted)}>-{linesDeleted}</span>}
</span>
);
},
diff --git a/scripts/stylexMigration/legacyFiles.json b/scripts/stylexMigration/legacyFiles.json
index 6e6846096ea..f4cb2697100 100644
--- a/scripts/stylexMigration/legacyFiles.json
+++ b/scripts/stylexMigration/legacyFiles.json
@@ -6,14 +6,6 @@
".agents/skills/lobe-design/tests/fixtures/good-outline.tsx",
".agents/skills/lobe-design/tests/fixtures/good-visual.tsx",
".agents/skills/lobe-design/tests/fixtures/good.tsx",
- "apps/share/src/features/artifact/SharedArtifactView.tsx",
- "apps/share/src/features/topic/SharePortal.tsx",
- "apps/share/src/shell/ShareLayout.tsx",
- "apps/workbench/src/features/acceptance/AcceptanceDetail.tsx",
- "apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx",
- "apps/workbench/src/features/verify/VerifyReportUnavailable.tsx",
- "apps/workbench/src/shell/WorkbenchBrandLink.tsx",
- "apps/workbench/src/shell/WorkbenchHeader.tsx",
"packages/alint/fixtures/ui-content-width/bad-full-width-settings.tsx",
"packages/alint/fixtures/ui-no-decorative-chrome/bad-boxed-section.tsx",
"packages/alint/fixtures/ui-restrained-color/bad-colored-type-and-link.tsx",
@@ -75,22 +67,7 @@
"packages/builtin-tools/src/codex/CollabToolRender.tsx",
"packages/builtin-tools/src/codex/ErrorInspector.tsx",
"packages/builtin-tools/src/github/RunCommandInspector.tsx",
- "packages/shared-tool-ui/src/AskUserQuestion/AskUserQuestionView.tsx",
- "packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx",
- "packages/shared-tool-ui/src/Inspector/Linear/Inspector.tsx",
- "packages/shared-tool-ui/src/Inspector/Twitter/Inspector.tsx",
- "packages/shared-tool-ui/src/Render/GitHub/index.tsx",
- "packages/shared-tool-ui/src/Render/Linear/index.tsx",
- "packages/shared-tool-ui/src/components/FileChangeStats/index.tsx",
"packages/shared-tool-ui/src/styles.ts",
- "src/features/Acceptance/CriterionList/CriterionRow.tsx",
- "src/features/Acceptance/Report/EvidenceComparisonCard.tsx",
- "src/features/Acceptance/Report/InteractionCost.tsx",
- "src/features/Acceptance/Report/MarkdownEvidence.tsx",
- "src/features/Acceptance/Report/ReportViewer.tsx",
- "src/features/Acceptance/Report/VisualizationRenderer.tsx",
- "src/features/Acceptance/Run/CheckerDock.tsx",
- "src/features/Acceptance/Run/RunResult.tsx",
"src/features/Acceptance/Viewer/AcceptanceOverview.tsx",
"src/features/Acceptance/Viewer/Checks/AcceptanceCheckInventory.tsx",
"src/features/Acceptance/Viewer/Checks/styles.ts",
@@ -150,13 +127,6 @@
"src/features/Acceptance/Viewer/Review/modals.tsx",
"src/features/Acceptance/Viewer/Review/rejectModalShell.ts",
"src/features/Acceptance/Viewer/index.tsx",
- "src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx",
- "src/features/Acceptance/Workspace/AcceptanceDeleteConfirm.tsx",
- "src/features/Acceptance/Workspace/AcceptanceListPanel.tsx",
- "src/features/Acceptance/Workspace/AcceptanceOnboarding.tsx",
- "src/features/Acceptance/Workspace/AcceptanceRow.tsx",
- "src/features/Acceptance/Workspace/MergeAcceptanceModal.tsx",
- "src/features/Acceptance/Workspace/index.tsx",
"src/features/AgentBreadcrumb/index.tsx",
"src/features/AgentBuilder/TopicSelector.tsx",
"src/features/AgentChannel/PlatformCard.tsx",
@@ -281,43 +251,6 @@
"src/features/BackgroundActivity/ProcessExplorer/style.ts",
"src/features/BackgroundActivity/TopicSection.tsx",
"src/features/Billboard/Carousel.tsx",
- "src/features/ChatInput/ActionBar/AgentMode/index.tsx",
- "src/features/ChatInput/ActionBar/Knowledge/useControls.tsx",
- "src/features/ChatInput/ActionBar/Memory/Controls.tsx",
- "src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx",
- "src/features/ChatInput/ActionBar/Params/Controls.tsx",
- "src/features/ChatInput/ActionBar/Plus/index.tsx",
- "src/features/ChatInput/ActionBar/Search/Controls.tsx",
- "src/features/ChatInput/ActionBar/Search/FCSearchModel.tsx",
- "src/features/ChatInput/ActionBar/Search/FunctionCallingModelSelect/index.tsx",
- "src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx",
- "src/features/ChatInput/ActionBar/Tools/ToolItemDetailPopover.tsx",
- "src/features/ChatInput/ActionBar/Tools/ToolsList.tsx",
- "src/features/ChatInput/ActionBar/Tools/useControls.tsx",
- "src/features/ChatInput/ActionBar/Upload/index.tsx",
- "src/features/ChatInput/ActionBar/components/ActionDropdown.tsx",
- "src/features/ChatInput/ActionBar/components/ActionPopover.tsx",
- "src/features/ChatInput/ChatInputNotice/Content.tsx",
- "src/features/ChatInput/Desktop/ContextContainer/ContextItem/Content.tsx",
- "src/features/ChatInput/Desktop/ContextContainer/ContextItem/index.tsx",
- "src/features/ChatInput/Desktop/ContextContainer/ContextList.tsx",
- "src/features/ChatInput/Desktop/ContextContainer/ElementItem.tsx",
- "src/features/ChatInput/Desktop/ContextContainer/SelectionItem.tsx",
- "src/features/ChatInput/Desktop/index.tsx",
- "src/features/ChatInput/Dictation/index.tsx",
- "src/features/ChatInput/InputEditor/ActionTag/style.ts",
- "src/features/ChatInput/InputEditor/InputHistoryPopup.tsx",
- "src/features/ChatInput/InputEditor/LocalFileTag/LocalFileTag.tsx",
- "src/features/ChatInput/InputEditor/index.tsx",
- "src/features/ChatInput/InputEditor/mentionStyle.ts",
- "src/features/ChatInput/Mobile/FilePreview/FileItem/File.tsx",
- "src/features/ChatInput/Mobile/FilePreview/FileItem/Image.tsx",
- "src/features/ChatInput/Mobile/FilePreview/index.tsx",
- "src/features/ChatInput/Mobile/index.tsx",
- "src/features/ChatInput/VoiceMessage/index.tsx",
- "src/features/ChatInput/components/SelectorTrigger.tsx",
- "src/features/ChatInput/components/UploadDetail/index.tsx",
- "src/features/ChatInput/components/buildSelectorSubmenu.tsx",
"src/features/ChatMiniMap/styles.ts",
"src/features/ChatTerminal/Content.tsx",
"src/features/ChatTerminal/SplitView.tsx",
diff --git a/scripts/stylexMigration/verification/fixtures/AcceptanceEvidenceData.ts b/scripts/stylexMigration/verification/fixtures/AcceptanceEvidenceData.ts
new file mode 100644
index 00000000000..faf56816a1a
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/AcceptanceEvidenceData.ts
@@ -0,0 +1,48 @@
+const svg = (width: number, height: number, fill: string) =>
+ `data:image/svg+xml;utf8,${encodeURIComponent(
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="${width}" height="${height}" fill="${fill}"/></svg>`,
+ )}`;
+
+interface Capture {
+ height?: number;
+ type: 'gif' | 'screenshot' | 'video';
+ width?: number;
+}
+
+const pair = (id: string, { height, type, width }: Capture) =>
+ (['before', 'after'] as const).map((role) => ({
+ description: `${role} capture`,
+ fileHeight: height ?? null,
+ fileName: null,
+ fileUrl:
+ type === 'video'
+ ? 'data:video/mp4;base64,AAAA'
+ : svg(width ?? 640, height ?? 400, role === 'before' ? '#d33' : '#3a3'),
+ fileWidth: width ?? null,
+ id: `${id}-${role}`,
+ metadata: { comparison: { id, label: `${id} ${role}`, role } },
+ type,
+ }));
+
+const captures: Record<string, Capture[]> = {
+ gif: [{ type: 'gif' }],
+ screenshot: [{ height: 400, type: 'screenshot', width: 640 }],
+ tall: [{ height: 1700, type: 'screenshot', width: 390 }],
+ unsized: [{ type: 'screenshot' }],
+ video: [{ type: 'video' }],
+};
+
+export const evidenceFor = (variant: string) =>
+ (captures[variant.replace(/^dark-/, '')] ?? []).flatMap((capture, index) =>
+ pair(`${capture.type}-${index}`, capture),
+ );
+
+export const useTextFileLoader = () => ({ error: null, fileData: null, loading: false });
+
+export const TerminalEvidenceCard = () => {
+ throw new Error('UNMOUNTED_SIBLING_RENDERED_IN_STYLE_FIXTURE');
+};
+
+export const useAcceptanceBundle = () => {
+ throw new Error('UNMOUNTED_SIBLING_RENDERED_IN_STYLE_FIXTURE');
+};
diff --git a/scripts/stylexMigration/verification/fixtures/AcceptanceEvidenceListFixture.tsx b/scripts/stylexMigration/verification/fixtures/AcceptanceEvidenceListFixture.tsx
new file mode 100644
index 00000000000..6d7566eb28a
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/AcceptanceEvidenceListFixture.tsx
@@ -0,0 +1,10 @@
+import { MemoryRouter } from 'react-router';
+import { AcceptanceEvidenceList } from 'verification:component';
+
+import { evidenceFor } from './AcceptanceEvidenceData';
+
+export const Fixture = ({ variant }: { variant: string }) => (
+ <MemoryRouter>
+ <AcceptanceEvidenceList evidence={evidenceFor(variant)} />
+ </MemoryRouter>
+);
diff --git a/scripts/stylexMigration/verification/fixtures/AcceptanceReportData.ts b/scripts/stylexMigration/verification/fixtures/AcceptanceReportData.ts
new file mode 100644
index 00000000000..05d68c2defd
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/AcceptanceReportData.ts
@@ -0,0 +1,64 @@
+const svg = (fill: string) =>
+ `data:image/svg+xml;utf8,${encodeURIComponent(
+ `<svg xmlns="http://www.w3.org/2000/svg" width="640" height="400"><rect width="640" height="400" fill="${fill}"/></svg>`,
+ )}`;
+
+const pair = (type: 'screenshot' | 'video', fileUrl: (role: string) => string, layout?: string) =>
+ (['before', 'after'] as const).map((role) => ({
+ description: `${role} capture`,
+ fileName: null,
+ fileUrl: fileUrl(role),
+ id: `${type}-${role}`,
+ metadata: { comparison: { id: type, label: `${type} ${role}`, layout, role } },
+ type,
+ }));
+
+const evidenceFor = (variant: string) => {
+ const layout = variant.startsWith('vertical') ? 'vertical' : undefined;
+ return [
+ ...pair('screenshot', (role) => svg(role === 'before' ? '#d33' : '#3a3'), layout),
+ ...pair('video', () => 'data:video/mp4;base64,AAAA', layout),
+ ];
+};
+
+const variant = () => new URL(location.href).searchParams.get('variant') ?? '';
+
+export const useVerifyReportBundle = () => ({
+ data: {
+ isOwner: false,
+ report: null,
+ results: [
+ {
+ checkItemId: 'comparison',
+ evidence: evidenceFor(variant()),
+ id: 'comparison-result',
+ metadata: null,
+ required: true,
+ status: 'passed',
+ suggestion: null,
+ title: 'Before and after',
+ toulmin: null,
+ verdict: 'passed',
+ },
+ ],
+ run: {
+ context: null,
+ goal: null,
+ id: 'fixture-run',
+ metadata: null,
+ plan: null,
+ scenario: 'web',
+ status: 'completed',
+ title: 'Comparison fixture',
+ },
+ },
+ error: undefined,
+ isLoading: false,
+ mutate: async () => {},
+});
+
+export const useTextFileLoader = () => ({ error: null, fileData: null, loading: false });
+
+export const TerminalEvidenceCard = () => {
+ throw new Error('UNMOUNTED_SIBLING_RENDERED_IN_STYLE_FIXTURE');
+};
diff --git a/scripts/stylexMigration/verification/fixtures/AcceptanceReportFixture.tsx b/scripts/stylexMigration/verification/fixtures/AcceptanceReportFixture.tsx
new file mode 100644
index 00000000000..ab8ac2c5991
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/AcceptanceReportFixture.tsx
@@ -0,0 +1,3 @@
+import { AcceptanceReport } from 'verification:component';
+
+export const Fixture = () => <AcceptanceReport runId="fixture-run" />;
diff --git a/scripts/stylexMigration/verification/fixtures/AskUserQuestionViewFixture.tsx b/scripts/stylexMigration/verification/fixtures/AskUserQuestionViewFixture.tsx
new file mode 100644
index 00000000000..89e33671952
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/AskUserQuestionViewFixture.tsx
@@ -0,0 +1,68 @@
+import { AskUserQuestionView } from 'verification:component';
+
+const noop = () => {};
+
+const questions = [
+ {
+ header: 'Scope',
+ multiSelect: true,
+ options: [{ label: 'Frontend' }, { label: 'Backend' }],
+ question: 'Which parts should change?',
+ },
+ {
+ header: 'Tests',
+ options: [{ label: 'Unit' }, { label: 'E2E' }],
+ question: 'Which tests should run?',
+ },
+];
+
+const labels = {
+ customPlaceholder: 'Other',
+ escapeBack: 'Back',
+ escapeEnter: 'Replace all',
+ escapePlaceholder: 'Answer in your own words',
+ multiSelectTag: 'Multiple',
+ recommendedTag: 'Recommended',
+ skip: 'Skip',
+ submit: 'Submit',
+ supplementEnter: 'Notes',
+ supplementPlaceholder: 'Add notes',
+ timeExpired: 'Time expired',
+ timeExpiredNoAnswer: 'Time expired without an answer',
+ timeRemaining: (time: string) => `${time} left`,
+};
+
+export const Fixture = ({ variant }: { variant: string }) => {
+ const escape = variant.endsWith('escape');
+ return (
+ <AskUserQuestionView
+ isMulti
+ isSubmitDisabled
+ activeQuestion={escape ? undefined : questions[0]}
+ activeTab={escape ? 'escape' : '0'}
+ autoSubmitted={false}
+ custom={{}}
+ escapeActive={escape}
+ escapeText=""
+ expired={false}
+ handleCustomChange={noop}
+ handleEscapeTextChange={noop}
+ handleSkip={noop}
+ handleSubmit={noop}
+ handleSupplementTextChange={noop}
+ handleToggle={noop}
+ labels={labels}
+ picks={{}}
+ questions={questions}
+ remainingMs={0}
+ setEscapeMode={noop}
+ setQuestionMode={noop}
+ setSupplementMode={noop}
+ showCountdown={false}
+ submissionFailed={false}
+ submitting={false}
+ supplementActive={false}
+ supplementText=""
+ />
+ );
+};
diff --git a/scripts/stylexMigration/verification/fixtures/VoiceMessageControlFixture.tsx b/scripts/stylexMigration/verification/fixtures/VoiceMessageControlFixture.tsx
new file mode 100644
index 00000000000..1b68da57a56
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/VoiceMessageControlFixture.tsx
@@ -0,0 +1,43 @@
+import { useEffect } from 'react';
+import { VoiceMessageControl } from 'verification:component';
+
+const noop = () => {};
+const waveform = [0.1, 0.4, 0.8, 1, 0.6, 0.3, 0.9, 0.2];
+
+const usePointerEnterSendButton = (enabled: boolean) => {
+ useEffect(() => {
+ if (!enabled) return;
+ const frame = requestAnimationFrame(() => {
+ document
+ .querySelector('[data-testid="voice-message-pill"] button')
+ ?.dispatchEvent(new PointerEvent('pointerover', { bubbles: true, pointerType: 'mouse' }));
+ });
+ return () => cancelAnimationFrame(frame);
+ }, [enabled]);
+};
+
+export const Fixture = ({ variant }: { variant: string }) => {
+ const kind = variant.replace(/^dark-/, '');
+ const busy = kind === 'busy';
+ const retry = kind.startsWith('retry');
+ usePointerEnterSendButton(kind.endsWith('hover-expanded'));
+ return (
+ <VoiceMessageControl
+ actionLabel={retry ? 'Retry' : 'Send'}
+ actionText={retry ? 'Retry' : busy ? 'Requesting microphone' : 'Send'}
+ cancelLabel="Cancel"
+ durationLabel="Duration 0:03"
+ errorText={retry ? 'Microphone permission was denied' : undefined}
+ expanded={busy}
+ groupLabel="Voice message"
+ isRetry={retry}
+ progress={kind === 'progress' ? 40 : undefined}
+ sendDisabled={kind === 'disabled' || busy}
+ statusAnnouncement="Recording"
+ tooltip={kind === 'disabled' ? 'Too short' : undefined}
+ waveform={waveform}
+ onAction={noop}
+ onCancel={noop}
+ />
+ );
+};
diff --git a/scripts/stylexMigration/verification/fixtures/VoiceMessageFixtureData.ts b/scripts/stylexMigration/verification/fixtures/VoiceMessageFixtureData.ts
new file mode 100644
index 00000000000..f536a3217c5
--- /dev/null
+++ b/scripts/stylexMigration/verification/fixtures/VoiceMessageFixtureData.ts
@@ -0,0 +1,13 @@
+const notExercised = () => {
+ throw new Error('BUSINESS_PATH_OUTSIDE_STYLE_FIXTURE');
+};
+
+export const ChatInputAction = notExercised;
+export const useAgentId = notExercised;
+export const useEffectiveModel = notExercised;
+export const useChatInputStore = notExercised;
+export const useStoreApi = notExercised;
+export const getVoiceMessageActionState = notExercised;
+export const getVoiceMessageIdleState = notExercised;
+export const useVoiceMessageCapability = notExercised;
+export const useVoiceMessageRecorder = notExercised;
diff --git a/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts b/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts
index b8a3cebbf20..da58e4d8428 100644
--- a/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts
+++ b/scripts/stylexMigration/verification/fixtures/fixtureRegistry.test.ts
@@ -74,7 +74,7 @@ describe('explicit fixture contract', () => {
});
it('connects all entries with explicit mounting and probe contracts', () => {
- expect(fixtureIds).toHaveLength(21);
+ expect(fixtureIds).toHaveLength(25);
for (const id of fixtureIds) {
const fixture = getStyleFixture(id);
expect(fixture.component.id).toBe(id);
diff --git a/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts b/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts
index 35b1f349d7e..1d343134a4b 100644
--- a/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts
+++ b/scripts/stylexMigration/verification/fixtures/migrationProfiles.ts
@@ -1,14 +1,56 @@
import type { FixtureProfile } from './fixtureRegistry';
export const migrationFixtures = [
+ ['AskUserQuestionView', 'packages/shared-tool-ui/src/AskUserQuestion/AskUserQuestionView.tsx'],
['SidebarGroupItem', 'src/features/HomeSidebar/Body/Agent/Modals/ConfigGroupModal/GroupItem.tsx'],
['ToolbarActionButton', 'src/features/Portal/LocalFile/PreviewToolbar.tsx'],
['PreviewToolbar', 'src/features/Portal/LocalFile/PreviewToolbar.tsx'],
['WorkPreview', 'src/features/WorkGallery/WorkPreview.tsx'],
['WorkPreviewStatus', 'src/features/WorkGallery/WorkPreview.tsx'],
+ ['AcceptanceReport', 'src/features/Acceptance/Report/ReportViewer.tsx'],
+ ['AcceptanceEvidenceList', 'src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx'],
+ ['VoiceMessageControl', 'src/features/ChatInput/VoiceMessage/index.tsx'],
] as const;
+const voiceMessageImporter = 'src/features/ChatInput/VoiceMessage/index.tsx';
+const voiceMessageData = 'fixtures/VoiceMessageFixtureData.ts';
+
export const migrationProfiles: Record<string, FixtureProfile> = {
+ AskUserQuestionView: {
+ dependencies: ['lucide-react', 'path-browserify-esm'],
+ exportName: 'AskUserQuestionView',
+ selector: '[data-component-mount] [role="tab"]',
+ settleFrames: 2,
+ variants: [
+ { id: 'questions', states: ['default', 'hover', 'focus-visible'] },
+ { id: 'escape' },
+ { id: 'dark-questions', appearance: 'dark' },
+ ],
+ },
+ VoiceMessageControl: {
+ dependencies: ['lucide-react', 'i18next', 'react-i18next'],
+ exportName: 'VoiceMessageControl',
+ selector: '[data-component-mount] [data-testid="voice-message-pill"] button',
+ settleFrames: 2,
+ variants: [
+ { id: 'recording', states: ['default', 'hover', 'focus-visible'] },
+ { id: 'busy' },
+ { id: 'retry', states: ['default', 'hover', 'focus-visible'] },
+ { id: 'hover-expanded' },
+ { id: 'retry-hover-expanded' },
+ { id: 'disabled', states: ['default', 'hover'] },
+ { id: 'progress' },
+ { id: 'dark-recording', appearance: 'dark', states: ['default', 'focus-visible'] },
+ ],
+ boundaries: [
+ '../ActionBar/components/ChatInputAction',
+ '../hooks/useAgentId',
+ '../hooks/useEffectiveModel',
+ '../store',
+ './useVoiceMessageCapability',
+ './useVoiceMessageRecorder',
+ ].map((source) => ({ importer: voiceMessageImporter, source, replacement: voiceMessageData })),
+ },
SidebarGroupItem: {
dependencies: ['lucide-react', 'i18next', 'react-i18next'],
i18n: true,
@@ -99,4 +141,63 @@ export const migrationProfiles: Record<string, FixtureProfile> = {
})),
),
},
+ AcceptanceReport: {
+ dependencies: [
+ 'lucide-react',
+ 'i18next',
+ 'react-i18next',
+ 'react-router',
+ 'path-browserify-esm',
+ 'es-toolkit',
+ ],
+ settleFrames: 2,
+ variants: [
+ { id: 'horizontal' },
+ { id: 'vertical' },
+ { id: 'dark-horizontal', appearance: 'dark' },
+ ],
+ boundaries: [
+ { importer: 'src/features/Acceptance/Report/ReportViewer.tsx', source: '../hooks' },
+ { importer: 'src/features/Acceptance/Report/ReportViewer.tsx', source: './TerminalEvidence' },
+ {
+ importer: 'src/features/Acceptance/Report/MarkdownEvidence.tsx',
+ source: '@/features/FileViewer/hooks/useTextFileLoader',
+ },
+ ].map((boundary) => ({ ...boundary, replacement: 'fixtures/AcceptanceReportData.ts' })),
+ },
+ AcceptanceEvidenceList: {
+ assets: ['fixtures/AcceptanceEvidenceData.ts'],
+ dependencies: [
+ 'lucide-react',
+ 'i18next',
+ 'react-i18next',
+ 'react-router',
+ 'path-browserify-esm',
+ 'es-toolkit',
+ ],
+ exportName: 'EvidenceList',
+ settleFrames: 2,
+ variants: [
+ { id: 'screenshot' },
+ { id: 'tall' },
+ { id: 'unsized' },
+ { id: 'gif' },
+ { id: 'video' },
+ { id: 'dark-screenshot', appearance: 'dark' },
+ ],
+ boundaries: [
+ {
+ importer: 'src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx',
+ source: '../../Report/TerminalEvidence',
+ },
+ {
+ importer: 'src/features/Acceptance/Report/MarkdownEvidence.tsx',
+ source: '@/features/FileViewer/hooks/useTextFileLoader',
+ },
+ {
+ importer: 'src/features/Acceptance/Viewer/AcceptanceScope.tsx',
+ source: './useAcceptanceBundle',
+ },
+ ].map((boundary) => ({ ...boundary, replacement: 'fixtures/AcceptanceEvidenceData.ts' })),
+ },
};
diff --git a/scripts/stylexMigration/verification/fixtures/modules.d.ts b/scripts/stylexMigration/verification/fixtures/modules.d.ts
index 50ec550862c..575957f4983 100644
--- a/scripts/stylexMigration/verification/fixtures/modules.d.ts
+++ b/scripts/stylexMigration/verification/fixtures/modules.d.ts
@@ -1,4 +1,5 @@
declare module 'verification:component' {
+ import type { AskUserQuestionViewProps } from '@lobechat/shared-tool-ui/ask-user';
import type { WorkSummaryItem } from '@lobechat/types';
import type { ListProps } from '@lobehub/ui';
import type { LucideIcon } from 'lucide-react';
@@ -87,6 +88,7 @@ declare module 'verification:component' {
onLineWrappingChange: () => void;
}>;
export const FilePathDisplay: ComponentType<{ filePath: string; isDirectory: boolean }>;
+ export const AskUserQuestionView: ComponentType<AskUserQuestionViewProps>;
export const OptionCard: ComponentType<{
description: string;
disabled: boolean;
@@ -97,6 +99,23 @@ declare module 'verification:component' {
selected: boolean;
onToggle: () => void;
}>;
+ export const VoiceMessageControl: ComponentType<{
+ actionLabel: string;
+ actionText?: string;
+ cancelLabel: string;
+ durationLabel: string;
+ errorText?: string;
+ expanded?: boolean;
+ groupLabel: string;
+ isRetry?: boolean;
+ onAction: () => void;
+ onCancel: () => void;
+ progress?: number;
+ sendDisabled?: boolean;
+ statusAnnouncement: string;
+ tooltip?: string;
+ waveform: number[];
+ }>;
export const OptionRow: ComponentType<{
active: boolean;
desc: string;
@@ -107,6 +126,8 @@ declare module 'verification:component' {
tag: string;
onClick: () => void;
}>;
+ export const AcceptanceReport: ComponentType<{ runId?: string }>;
+ export const AcceptanceEvidenceList: ComponentType<{ evidence: unknown[] }>;
}
declare module 'verification:locale/chat' {
diff --git a/src/features/Acceptance/CriterionList/CriterionRow.tsx b/src/features/Acceptance/CriterionList/CriterionRow.tsx
index 7f4a529ee2e..0d2c07e936b 100644
--- a/src/features/Acceptance/CriterionList/CriterionRow.tsx
+++ b/src/features/Acceptance/CriterionList/CriterionRow.tsx
@@ -1,36 +1,32 @@
'use client';
-import { Block, createStaticStyles, cssVar, cx, Flexbox, Tag, Text } from '@lobehub/ui';
+import { Block, Flexbox, Tag, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { HTMLAttributes, ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
-const styles = createStaticStyles(({ css }) => ({
- list: css`
- overflow: hidden;
- width: 100%;
- padding: 0;
- `,
- row: css`
- padding-block: 10px;
- padding-inline: 12px;
+import { sx } from '@/styles/sx';
- & + & {
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- }
- `,
- rowClickable: css`
- cursor: pointer;
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
- `,
- seq: css`
- flex: none;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
-}));
+const styles = stylex.create({
+ list: { overflow: 'hidden', width: '100%', padding: 0 },
+ row: {
+ paddingBlock: '10px',
+ paddingInline: '12px',
+ borderBlockStartWidth: { default: null, [stylex.when.siblingBefore(':is(*)')]: '1px' },
+ borderBlockStartStyle: { default: null, [stylex.when.siblingBefore(':is(*)')]: 'solid' },
+ borderBlockStartColor: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)')]: cssVar.colorBorderSecondary,
+ },
+ },
+ rowClickable: {
+ cursor: 'pointer',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ seq: { flex: 'none', fontSize: '12px', color: cssVar.colorTextTertiary },
+});
interface CriterionRequiredChipProps {
/** When set, the chip becomes the required/optional toggle. */
@@ -107,8 +103,8 @@ export const CriterionRow = ({
<Flexbox
horizontal
align={'center'}
- className={cx(styles.row, onOpen && styles.rowClickable, className)}
gap={10}
+ {...sx(styles.row, stylex.defaultMarker(), onOpen && styles.rowClickable, className)}
role={onOpen ? 'button' : undefined}
tabIndex={onOpen ? 0 : undefined}
onClick={onOpen}
@@ -116,7 +112,7 @@ export const CriterionRow = ({
{...rest}
>
{icon}
- {seq !== undefined && <span className={styles.seq}>C{seq}</span>}
+ {seq !== undefined && <span {...stylex.props(styles.seq)}>C{seq}</span>}
<Text ellipsis style={{ flex: 1, minWidth: 0 }}>
{title}
</Text>
@@ -132,7 +128,7 @@ interface CriterionListProps {
/** Outlined container that gives `CriterionRow` children their between-row borders. */
export const CriterionList = ({ children, className }: CriterionListProps) => (
- <Block className={cx(styles.list, className)} variant={'outlined'}>
+ <Block {...sx(styles.list, className)} variant={'outlined'}>
{children}
</Block>
);
diff --git a/src/features/Acceptance/Report/EvidenceComparisonCard.tsx b/src/features/Acceptance/Report/EvidenceComparisonCard.tsx
index 133a2402432..6d20f143239 100644
--- a/src/features/Acceptance/Report/EvidenceComparisonCard.tsx
+++ b/src/features/Acceptance/Report/EvidenceComparisonCard.tsx
@@ -1,9 +1,16 @@
'use client';
-import { createStaticStyles, cssVar, cx } from '@lobehub/ui';
+import {
+ // oxlint-disable-next-line stylex-migration/no-emotion-styles -- media inside markdown, document and video evidence renderers
+ createStaticStyles,
+} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { ReactNode } from 'react';
import { memo } from 'react';
+import { sx } from '@/styles/sx';
+
/** The `metadata.comparison` an evidence artifact may carry (authored at ingest). */
export interface EvidenceComparisonMeta {
id: string;
@@ -53,69 +60,68 @@ export const readEvidenceComparison = (metadata: unknown): EvidenceComparisonMet
};
};
-const styles = createStaticStyles(({ css }) => ({
+const styles = stylex.create({
/* One fused card: the pair is a single object, so no outer gap between the
halves — the 1px background seam is the divider in either direction, which
keeps the split correct when the grid collapses to one column. */
- card: css`
- overflow: hidden;
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: 1px;
-
- width: 100%;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBorderSecondary};
-
- @media (width <= 640px) {
- grid-template-columns: 1fr;
- }
- `,
- cardVertical: css`
- grid-template-columns: 1fr;
- `,
- side: css`
- display: flex;
- flex-direction: column;
- min-width: 0;
- background: ${cssVar.colorBgContainer};
- `,
+ card: {
+ overflow: 'hidden',
+ display: 'grid',
+ gridTemplateColumns: {
+ 'default': 'repeat(2, minmax(0, 1fr))',
+ '@media (width <= 640px)': '1fr',
+ },
+ gap: '1px',
+ width: '100%',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ cardVertical: { gridTemplateColumns: '1fr' },
+ side: {
+ display: 'flex',
+ flexDirection: 'column',
+ minWidth: '0',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
/* The role rides on a tinted band fused to its own capture, so which state
you're looking at survives being read at a glance. */
- label: css`
- display: flex;
- gap: 8px;
- align-items: baseline;
-
- padding-block: 7px;
- padding-inline: 10px;
-
- font-size: 12px;
- `,
- labelBefore: css`
- border-block-end: 1px solid ${cssVar.colorErrorBorder};
- color: ${cssVar.colorErrorText};
- background: ${cssVar.colorErrorBg};
- `,
- labelAfter: css`
- border-block-end: 1px solid ${cssVar.colorSuccessBorder};
- color: ${cssVar.colorSuccessText};
- background: ${cssVar.colorSuccessBg};
- `,
+ label: {
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'baseline',
+ paddingBlock: '7px',
+ paddingInline: '10px',
+ fontSize: '12px',
+ },
+ labelBefore: {
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorErrorBorder,
+ color: cssVar.colorErrorText,
+ backgroundColor: cssVar.colorErrorBg,
+ backgroundImage: 'none',
+ },
+ labelAfter: {
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorSuccessBorder,
+ color: cssVar.colorSuccessText,
+ backgroundColor: cssVar.colorSuccessBg,
+ backgroundImage: 'none',
+ },
/* The two captions are themselves a before/after contrast, so they must stay
readable side by side — wrap rather than ellipsize. */
- caption: css`
- min-width: 0;
- opacity: 0.85;
- `,
- /* The card frames the capture; an inner border/radius would double the frame,
- so whatever media the caller renders inside is flattened to the card edge. */
- content: css`
- flex: 1;
- min-width: 0;
+ caption: { minWidth: '0', opacity: 0.85 },
+ content: { flex: '1', minWidth: '0' },
+});
+const fallback = createStaticStyles(({ css }) => ({
+ content: css`
img,
video {
display: block;
@@ -126,6 +132,33 @@ const styles = createStaticStyles(({ css }) => ({
`,
}));
+const comparisonMediaStyles = stylex.create({
+ image: {
+ display: 'block',
+ width: '100%',
+ borderWidth: 'medium',
+ borderStyle: 'none',
+ borderColor: 'currentcolor',
+ borderRadius: 0,
+ },
+ video: {
+ display: 'block',
+ width: '100%',
+ borderWidth: 'medium',
+ borderStyle: 'none',
+ borderColor: 'currentcolor',
+ borderRadius: 0,
+ },
+});
+
+export const comparisonMedia = {
+ image: {
+ classNames: { image: stylex.props(comparisonMediaStyles.image).className },
+ variant: 'borderless' as const,
+ },
+ video: comparisonMediaStyles.video,
+};
+
export interface EvidenceComparisonSide {
/** Caption in the tinted band — the comparison label, or the evidence description. */
caption?: string;
@@ -145,25 +178,25 @@ interface EvidenceComparisonCardProps {
export const EvidenceComparisonCard = memo<EvidenceComparisonCardProps>(
({ after, before, layout = 'horizontal' }) => {
return (
- <div className={cx(styles.card, layout === 'vertical' && styles.cardVertical)}>
+ <div {...stylex.props(styles.card, layout === 'vertical' && styles.cardVertical)}>
{(
[
['before', before],
['after', after],
] as const
).map(([role, side]) => (
- <div className={styles.side} key={role}>
+ <div {...stylex.props(styles.side)} key={role}>
{side.caption && (
<div
- className={cx(
+ {...stylex.props(
styles.label,
role === 'before' ? styles.labelBefore : styles.labelAfter,
)}
>
- <span className={styles.caption}>{side.caption}</span>
+ <span {...stylex.props(styles.caption)}>{side.caption}</span>
</div>
)}
- <div className={styles.content}>{side.content}</div>
+ <div {...sx(styles.content, fallback.content)}>{side.content}</div>
</div>
))}
</div>
diff --git a/src/features/Acceptance/Report/InteractionCost.tsx b/src/features/Acceptance/Report/InteractionCost.tsx
index adf7344e627..b5b530610f3 100644
--- a/src/features/Acceptance/Report/InteractionCost.tsx
+++ b/src/features/Acceptance/Report/InteractionCost.tsx
@@ -1,10 +1,13 @@
'use client';
import type { VerifyInteractionCost } from '@lobechat/types';
-import { createStaticStyles, cssVar } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { sx } from '@/styles/sx';
+
import {
formatSeconds,
OPERATOR_KEYS,
@@ -25,216 +28,171 @@ export { formatSeconds, readInteractionCost } from './interactionCostModel';
* reviewer deciding whether a flow is worth accepting.
*/
-const styles = createStaticStyles(({ css }) => ({
- interactionCost: css`
- --klm-blue-1: color-mix(in srgb, ${cssVar.colorInfo} 70%, ${cssVar.colorBgContainer});
- --klm-blue-2: ${cssVar.colorInfo};
- --klm-blue-3: color-mix(in srgb, ${cssVar.colorInfo} 84%, ${cssVar.colorText});
- --klm-blue-4: color-mix(in srgb, ${cssVar.colorInfo} 68%, ${cssVar.colorText});
- --klm-blue-5: color-mix(in srgb, ${cssVar.colorInfo} 54%, ${cssVar.colorText});
- --klm-blue-6: color-mix(in srgb, ${cssVar.colorInfo} 42%, ${cssVar.colorText});
-
- display: flex;
- flex-direction: column;
- gap: 12px;
- width: 100%;
- `,
- interactionCostHeader: css`
- display: flex;
- flex-wrap: wrap;
- gap: 8px 12px;
- align-items: center;
- justify-content: flex-end;
- `,
- interactionCostModel: css`
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- interactionMetric: css`
- min-width: 0;
- padding-block: 9px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusSM};
- `,
- interactionMetricLabel: css`
- display: block;
- margin-block-end: 4px;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- interactionMetricValue: css`
- font-size: 18px;
- font-weight: 650;
- font-variant-numeric: tabular-nums;
- line-height: 1.2;
- color: ${cssVar.colorText};
- `,
- interactionMetrics: css`
- display: grid;
- grid-template-columns: repeat(3, minmax(0, 1fr));
- gap: 8px;
-
- @media (width <= 520px) {
- grid-template-columns: 1fr;
- }
- `,
- operatorChip: css`
- --operator-color: ${cssVar.colorTextSecondary};
-
- display: inline-flex;
- gap: 5px;
- align-items: baseline;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: color-mix(in srgb, var(--operator-color) 72%, ${cssVar.colorTextSecondary});
-
- &::before {
- content: '';
-
- flex: 0 0 auto;
-
- width: 6px;
- height: 6px;
- margin-block-start: 0.5em;
- border-radius: 50%;
-
- background: var(--operator-color);
- }
-
- b {
- font-weight: 650;
- color: var(--operator-color);
- }
-
- &[data-operator='K'] {
- --operator-color: var(--klm-blue-1);
- }
-
- &[data-operator='P'] {
- --operator-color: var(--klm-blue-2);
- }
-
- &[data-operator='M'] {
- --operator-color: var(--klm-blue-3);
- }
-
- &[data-operator='H'] {
- --operator-color: var(--klm-blue-4);
- }
-
- &[data-operator='T_chars'] {
- --operator-color: var(--klm-blue-5);
- }
-
- &[data-operator='R_ms'] {
- --operator-color: var(--klm-blue-6);
- }
- `,
- operatorList: css`
- display: flex;
- flex-wrap: wrap;
- gap: 8px 14px;
- `,
+const styles = stylex.create({
+ interactionCost: {
+ '--klm-blue-1': `color-mix(in srgb, ${cssVar.colorInfo} 70%, ${cssVar.colorBgContainer})`,
+ '--klm-blue-2': cssVar.colorInfo,
+ '--klm-blue-3': `color-mix(in srgb, ${cssVar.colorInfo} 84%, ${cssVar.colorText})`,
+ '--klm-blue-4': `color-mix(in srgb, ${cssVar.colorInfo} 68%, ${cssVar.colorText})`,
+ '--klm-blue-5': `color-mix(in srgb, ${cssVar.colorInfo} 54%, ${cssVar.colorText})`,
+ '--klm-blue-6': `color-mix(in srgb, ${cssVar.colorInfo} 42%, ${cssVar.colorText})`,
+ 'display': 'flex',
+ 'flexDirection': 'column',
+ 'gap': '12px',
+ 'width': '100%',
+ },
+ interactionCostHeader: {
+ display: 'flex',
+ flexWrap: 'wrap',
+ columnGap: '12px',
+ rowGap: '8px',
+ alignItems: 'center',
+ justifyContent: 'flex-end',
+ },
+ interactionCostModel: {
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ interactionMetric: {
+ minWidth: '0',
+ paddingBlock: '9px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadiusSM,
+ },
+ interactionMetricLabel: {
+ display: 'block',
+ marginBlockEnd: '4px',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ interactionMetricValue: {
+ fontSize: '18px',
+ fontWeight: 650,
+ fontVariantNumeric: 'tabular-nums',
+ lineHeight: 1.2,
+ color: cssVar.colorText,
+ },
+ interactionMetrics: {
+ display: 'grid',
+ gridTemplateColumns: {
+ 'default': 'repeat(3, minmax(0, 1fr))',
+ '@media (width <= 520px)': '1fr',
+ },
+ gap: '8px',
+ },
+ operatorChip: {
+ '--operator-color': cssVar.colorTextSecondary,
+ 'display': 'inline-flex',
+ 'gap': '5px',
+ 'alignItems': 'baseline',
+ 'fontFamily': cssVar.fontFamilyCode,
+ 'fontSize': '12px',
+ 'color': `color-mix(in srgb, var(--operator-color) 72%, ${cssVar.colorTextSecondary})`,
+ '::before': {
+ content: '""',
+ flexGrow: '0',
+ flexShrink: '0',
+ flexBasis: 'auto',
+ width: '6px',
+ height: '6px',
+ marginBlockStart: '0.5em',
+ borderRadius: '50%',
+ backgroundColor: 'var(--operator-color)',
+ backgroundImage: 'none',
+ },
+ },
+ operatorValue: { fontWeight: 650, color: 'var(--operator-color)' },
+ operatorK: { '--operator-color': 'var(--klm-blue-1)' },
+ operatorP: { '--operator-color': 'var(--klm-blue-2)' },
+ operatorM: { '--operator-color': 'var(--klm-blue-3)' },
+ operatorH: { '--operator-color': 'var(--klm-blue-4)' },
+ operatorTChars: { '--operator-color': 'var(--klm-blue-5)' },
+ operatorRMs: { '--operator-color': 'var(--klm-blue-6)' },
+ operatorList: { display: 'flex', flexWrap: 'wrap', columnGap: '14px', rowGap: '8px' },
/* Secondary to the phase name: it may be a long check title, so it is the part
that gives way and truncates rather than squeezing the name out of the row. */
- phaseCheck: css`
- overflow: hidden;
- flex: 1 1 auto;
-
- min-width: 0;
-
- font-size: 11px;
- color: ${cssVar.colorTextQuaternary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- phaseList: css`
- display: flex;
- flex-direction: column;
- gap: 8px;
- `,
- phaseName: css`
- overflow: hidden;
- display: flex;
- gap: 6px;
- align-items: baseline;
-
- min-width: 0;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- white-space: nowrap;
- `,
+ phaseCheck: {
+ overflow: 'hidden',
+ flexGrow: '1',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: '0',
+ fontSize: '11px',
+ color: cssVar.colorTextQuaternary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ phaseList: { display: 'flex', flexDirection: 'column', gap: '8px' },
+ phaseName: {
+ overflow: 'hidden',
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'baseline',
+ minWidth: '0',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ whiteSpace: 'nowrap',
+ },
/* The phase is what tells two rows apart, so it never shrinks — a long check
title must not collapse it to nothing and leave the rows looking identical. */
- phaseSlug: css`
- overflow: hidden;
- flex: 0 0 auto;
- max-width: 60%;
- text-overflow: ellipsis;
- `,
- phaseRow: css`
- display: grid;
- grid-template-columns: minmax(120px, 1fr) minmax(140px, 1.6fr) auto;
- gap: 10px;
- align-items: center;
-
- @media (width <= 640px) {
- grid-template-columns: 1fr;
- gap: 5px;
- }
- `,
- phaseSegment: css`
- --operator-color: ${cssVar.colorTextSecondary};
-
- flex: 0 0 auto;
- min-width: 2px;
- height: 100%;
- background: var(--operator-color);
-
- &[data-operator='K'] {
- --operator-color: var(--klm-blue-1);
- }
-
- &[data-operator='P'] {
- --operator-color: var(--klm-blue-2);
- }
-
- &[data-operator='M'] {
- --operator-color: var(--klm-blue-3);
- }
-
- &[data-operator='H'] {
- --operator-color: var(--klm-blue-4);
- }
-
- &[data-operator='T_chars'] {
- --operator-color: var(--klm-blue-5);
- }
-
- &[data-operator='R_ms'] {
- --operator-color: var(--klm-blue-6);
- }
- `,
- phaseTrack: css`
- overflow: hidden;
- display: flex;
+ phaseSlug: {
+ overflow: 'hidden',
+ flexGrow: '0',
+ flexShrink: '0',
+ flexBasis: 'auto',
+ maxWidth: '60%',
+ textOverflow: 'ellipsis',
+ },
+ phaseRow: {
+ display: 'grid',
+ gridTemplateColumns: {
+ 'default': 'minmax(120px, 1fr) minmax(140px, 1.6fr) auto',
+ '@media (width <= 640px)': '1fr',
+ },
+ gap: { 'default': '10px', '@media (width <= 640px)': '5px' },
+ alignItems: 'center',
+ },
+ phaseSegment: {
+ '--operator-color': cssVar.colorTextSecondary,
+ 'flexGrow': '0',
+ 'flexShrink': '0',
+ 'flexBasis': 'auto',
+ 'minWidth': '2px',
+ 'height': '100%',
+ 'backgroundColor': 'var(--operator-color)',
+ 'backgroundImage': 'none',
+ },
+ phaseTrack: {
+ overflow: 'hidden',
+ display: 'flex',
+ height: '8px',
+ borderRadius: '999px',
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ boxShadow: `inset 0 0 0 1px ${cssVar.colorBorderSecondary}`,
+ },
+ phaseValue: {
+ fontSize: '12px',
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorTextTertiary,
+ },
+});
- height: 8px;
- border-radius: 999px;
+const operatorStyles = {
+ H: styles.operatorH,
+ K: styles.operatorK,
+ M: styles.operatorM,
+ P: styles.operatorP,
+ R_ms: styles.operatorRMs,
+ T_chars: styles.operatorTChars,
+} as const;
- background: transparent;
- box-shadow: inset 0 0 0 1px ${cssVar.colorBorderSecondary};
- `,
- phaseValue: css`
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorTextTertiary};
- `,
-}));
+const operatorStyle = (key?: string) =>
+ key && key in operatorStyles ? operatorStyles[key as keyof typeof operatorStyles] : undefined;
export interface InteractionCostPanelProps {
/**
@@ -269,37 +227,41 @@ const InteractionCostPanel = memo<InteractionCostPanelProps>(
];
return (
- <section className={styles.interactionCost}>
- <div className={styles.interactionCostHeader}>
- {roundLabel && <span className={styles.interactionCostModel}>{roundLabel}</span>}
- <span className={styles.interactionCostModel}>{cost.model}</span>
+ <section {...stylex.props(styles.interactionCost)}>
+ <div {...stylex.props(styles.interactionCostHeader)}>
+ {roundLabel && <span {...stylex.props(styles.interactionCostModel)}>{roundLabel}</span>}
+ <span {...stylex.props(styles.interactionCostModel)}>{cost.model}</span>
</div>
- <div className={styles.interactionMetrics}>
+ <div {...stylex.props(styles.interactionMetrics)}>
{metrics.map((metric) => (
- <div className={styles.interactionMetric} key={metric.label}>
- <span className={styles.interactionMetricLabel}>{metric.label}</span>
- <span className={styles.interactionMetricValue}>{metric.value}</span>
+ <div {...stylex.props(styles.interactionMetric)} key={metric.label}>
+ <span {...stylex.props(styles.interactionMetricLabel)}>{metric.label}</span>
+ <span {...stylex.props(styles.interactionMetricValue)}>{metric.value}</span>
</div>
))}
</div>
- <div className={styles.operatorList}>
+ <div {...stylex.props(styles.operatorList)}>
{OPERATOR_KEYS.map((key) => {
const value = cost.operators[key];
if (value === undefined) return null;
return (
- <span className={styles.operatorChip} data-operator={key} key={key}>
+ <span
+ {...stylex.props(styles.operatorChip, operatorStyle(key))}
+ data-operator={key}
+ key={key}
+ >
<span>{t(`report.interaction.operator.${key}`)}</span>
- <b>{operatorValue(key, value)}</b>
+ <b {...stylex.props(styles.operatorValue)}>{operatorValue(key, value)}</b>
</span>
);
})}
</div>
{phases.length > 0 && (
- <div className={styles.phaseList}>
+ <div {...stylex.props(styles.phaseList)}>
{phases.map((phase) => {
const seconds = phaseSeconds(phase);
const activeSeconds = phase.activeSeconds ?? 0;
@@ -313,26 +275,25 @@ const InteractionCostPanel = memo<InteractionCostPanelProps>(
: undefined;
return (
- <div className={styles.phaseRow} key={phase.id}>
+ <div {...stylex.props(styles.phaseRow)} key={phase.id}>
<span
- className={styles.phaseName}
+ {...stylex.props(styles.phaseName)}
title={checkLabel ? `${name} · ${checkLabel}` : name}
>
- <span className={styles.phaseSlug}>{name}</span>
- {checkLabel && <span className={styles.phaseCheck}>{checkLabel}</span>}
+ <span {...stylex.props(styles.phaseSlug)}>{name}</span>
+ {checkLabel && <span {...stylex.props(styles.phaseCheck)}>{checkLabel}</span>}
</span>
- <span className={styles.phaseTrack}>
+ <span {...stylex.props(styles.phaseTrack)}>
{segments.length > 0 ? (
segments.map((segment) => (
<span
- className={styles.phaseSegment}
- data-operator={segment.key}
- key={segment.key}
- style={{
+ {...sx(styles.phaseSegment, operatorStyle(segment.key), {
width: `${
maxPhaseSeconds > 0 ? (segment.seconds / maxPhaseSeconds) * 100 : 0
}%`,
- }}
+ })}
+ data-operator={segment.key}
+ key={segment.key}
title={`${t(`report.interaction.operator.${segment.key}`)} ${formatSeconds(
segment.seconds,
)}`}
@@ -340,19 +301,17 @@ const InteractionCostPanel = memo<InteractionCostPanelProps>(
))
) : (
<>
+ <span {...sx(styles.phaseSegment, { width: `${activeWidth}%` })} />
<span
- className={styles.phaseSegment}
- style={{ width: `${activeWidth}%` }}
- />
- <span
- className={styles.phaseSegment}
+ {...sx(styles.phaseSegment, styles.operatorRMs, {
+ width: `${waitWidth}%`,
+ })}
data-operator={'R_ms'}
- style={{ width: `${waitWidth}%` }}
/>
</>
)}
</span>
- <span className={styles.phaseValue}>{formatSeconds(seconds)}</span>
+ <span {...stylex.props(styles.phaseValue)}>{formatSeconds(seconds)}</span>
</div>
);
})}
diff --git a/src/features/Acceptance/Report/MarkdownEvidence.tsx b/src/features/Acceptance/Report/MarkdownEvidence.tsx
index 3ae9e2adc54..2c768add8c5 100644
--- a/src/features/Acceptance/Report/MarkdownEvidence.tsx
+++ b/src/features/Acceptance/Report/MarkdownEvidence.tsx
@@ -1,16 +1,8 @@
'use client';
-import {
- Center,
- createStaticStyles,
- cssVar,
- cx,
- Flexbox,
- Highlighter,
- Icon,
- Markdown,
- Text,
-} from '@lobehub/ui';
+import { Center, Flexbox, Highlighter, Icon, Markdown, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronRight, FileText } from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -49,140 +41,103 @@ export const filenameFromUrl = (url: string): string => {
}
};
-const styles = createStaticStyles(({ css }) => ({
- foldBody: css`
- padding-block: 4px 8px;
- padding-inline: 22px 0;
-
- @media (width <= 767px) {
- padding-inline: 0;
- }
- `,
+const styles = stylex.create({
+ foldBody: {
+ paddingBlockStart: '4px',
+ paddingBlockEnd: '8px',
+ paddingInlineStart: { 'default': '22px', '@media (width <= 767px)': 0 },
+ paddingInlineEnd: 0,
+ },
/* Reviewer-directed: no fill, no border — the row is just a line of text
with a chevron; the surrounding check card provides the container. */
- foldCard: css`
- overflow: hidden;
- border-radius: ${cssVar.borderRadius};
- `,
- foldChevron: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
- transition: transform 160ms ease;
- `,
- foldChevronOpen: css`
- transform: rotate(90deg);
- `,
- foldHeader: css`
- cursor: pointer;
-
- display: flex;
- gap: 8px;
- align-items: center;
-
- width: 100%;
- padding-block: 4px;
- padding-inline: 0;
- border: none;
-
- text-align: start;
-
- background: transparent;
-
+ foldCard: { overflow: 'hidden', borderRadius: cssVar.borderRadius },
+ foldChevron: {
+ flex: 'none',
+ color: cssVar.colorTextTertiary,
+ transition: 'transform 160ms ease',
+ },
+ foldChevronOpen: { transform: 'rotate(90deg)' },
+ foldHeader: {
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ width: '100%',
+ minHeight: {
+ 'default': null,
+ '@media (width <= 767px), (pointer: coarse)': '44px',
+ },
+ paddingBlock: '4px',
+ paddingInline: 0,
+ borderStyle: 'none',
+ textAlign: 'start',
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ },
+ foldTitle: {
+ overflow: 'hidden',
+ fontSize: '13px',
+ lineHeight: 1.35,
/* No fill and no border by design — the hover feedback lives on the text. */
- &:hover [data-fold-title] {
- color: ${cssVar.colorText};
- }
-
- @media (width <= 767px), (pointer: coarse) {
- min-height: 44px;
- }
- `,
- foldTitle: css`
- overflow: hidden;
-
- font-size: 13px;
- line-height: 1.35;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
-
- transition: color 120ms ease;
-
- @media (width <= 767px) {
- overflow-wrap: anywhere;
- white-space: normal;
- }
- `,
+ color: {
+ default: cssVar.colorTextSecondary,
+ [stylex.when.ancestor(':hover')]: cssVar.colorText,
+ },
+ textOverflow: 'ellipsis',
+ whiteSpace: { 'default': 'nowrap', '@media (width <= 767px)': 'normal' },
+ overflowWrap: { 'default': null, '@media (width <= 767px)': 'anywhere' },
+ transition: 'color 120ms ease',
+ },
/* A plain block, deliberately not a Flexbox: `Markdown`'s root is
`overflow: hidden`, so as a flex item its automatic minimum size collapses
to 0 and a long document gets squeezed to the viewer's height and clipped
instead of overflowing it — leaving this box scrollable in name only. */
- docViewer: css`
- overflow: auto;
- flex: 1;
-
- height: 100%;
- min-height: 0;
- padding-block: 12px;
- padding-inline: 16px;
-
- > * {
- flex-shrink: 0;
- }
- `,
- fileCard: css`
- cursor: pointer;
-
- display: grid;
- grid-template-columns: 18px minmax(0, 1fr);
- gap: 8px;
- align-items: center;
-
- width: min(100%, 520px);
- padding-block: 7px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- text-align: start;
-
- background: ${cssVar.colorFillQuaternary};
-
- &:hover {
- border-color: ${cssVar.colorLink};
- color: ${cssVar.colorLink};
- }
- `,
- fileCardBody: css`
- display: flex;
- flex-direction: column;
- min-width: 0;
- `,
- fileCardDesc: css`
- overflow: hidden;
-
- margin-block-start: 2px;
-
- font-size: 12px;
- line-height: 1.35;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- fileCardIcon: css`
- display: flex;
- color: ${cssVar.colorTextTertiary};
- `,
- fileCardName: css`
- overflow: hidden;
-
- font-size: 13px;
- line-height: 1.35;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
+ docViewer: {
+ overflow: 'auto',
+ flex: '1',
+ height: '100%',
+ minHeight: '0',
+ paddingBlock: '12px',
+ paddingInline: '16px',
+ },
+ fileCard: {
+ cursor: 'pointer',
+ display: 'grid',
+ gridTemplateColumns: '18px minmax(0, 1fr)',
+ gap: '8px',
+ alignItems: 'center',
+ width: 'min(100%, 520px)',
+ paddingBlock: '7px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: { 'default': cssVar.colorBorderSecondary, ':hover': cssVar.colorLink },
+ borderRadius: cssVar.borderRadius,
+ color: { 'default': null, ':hover': cssVar.colorLink },
+ textAlign: 'start',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ fileCardBody: { display: 'flex', flexDirection: 'column', minWidth: '0' },
+ fileCardDesc: {
+ overflow: 'hidden',
+ marginBlockStart: '2px',
+ fontSize: '12px',
+ lineHeight: 1.35,
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ fileCardIcon: { display: 'flex', color: cssVar.colorTextTertiary },
+ fileCardName: {
+ overflow: 'hidden',
+ fontSize: '13px',
+ lineHeight: 1.35,
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+});
/** Content small enough that folding it would cost more than it saves. */
const INLINE_RENDER_MAX_CHARS = 160;
@@ -299,27 +254,25 @@ export const CollapsibleMarkdownEvidence = memo<{
}
return (
- <Flexbox className={styles.foldCard}>
+ <Flexbox className={stylex.props(styles.foldCard).className}>
<button
aria-expanded={expanded}
- className={styles.foldHeader}
+ {...stylex.props(styles.foldHeader, stylex.defaultMarker())}
title={t(expanded ? 'report.evidence.collapse' : 'report.evidence.expand')}
type={'button'}
onClick={() => setExpanded(!expanded)}
>
<Icon
- className={cx(styles.foldChevron, expanded && styles.foldChevronOpen)}
+ className={stylex.props(styles.foldChevron, expanded && styles.foldChevronOpen).className}
icon={ChevronRight}
size={14}
/>
- <span className={styles.fileCardIcon}>
+ <span {...stylex.props(styles.fileCardIcon)}>
<Icon icon={FileText} size={13} />
</span>
- <span data-fold-title className={styles.foldTitle}>
- {foldTitle}
- </span>
+ <span {...stylex.props(styles.foldTitle)}>{foldTitle}</span>
</button>
- {expanded && <div className={styles.foldBody}>{body}</div>}
+ {expanded && <div {...stylex.props(styles.foldBody)}>{body}</div>}
</Flexbox>
);
});
@@ -350,7 +303,7 @@ export const DocumentViewer = memo<{ fileName?: string | null; markdown?: boolea
);
return (
- <div className={styles.docViewer}>
+ <div {...stylex.props(styles.docViewer)}>
{markdown ? (
<Markdown fontSize={13} variant={'chat'}>
{fileData}
@@ -391,17 +344,17 @@ export const EvidenceFileCard = memo<{
return (
<>
<button
- className={styles.fileCard}
+ {...stylex.props(styles.fileCard)}
title={t('report.evidence.openDetail', { name })}
type={'button'}
onClick={() => setOpen(true)}
>
- <span className={styles.fileCardIcon}>
+ <span {...stylex.props(styles.fileCardIcon)}>
<Icon icon={FileText} size={13} />
</span>
- <span className={styles.fileCardBody}>
- <span className={styles.fileCardName}>{name}</span>
- {desc && <span className={styles.fileCardDesc}>{desc}</span>}
+ <span {...stylex.props(styles.fileCardBody)}>
+ <span {...stylex.props(styles.fileCardName)}>{name}</span>
+ {desc && <span {...stylex.props(styles.fileCardDesc)}>{desc}</span>}
</span>
</button>
{open && (
diff --git a/src/features/Acceptance/Report/ReportViewer.tsx b/src/features/Acceptance/Report/ReportViewer.tsx
index aa795f2b449..d8d038f5dd9 100644
--- a/src/features/Acceptance/Report/ReportViewer.tsx
+++ b/src/features/Acceptance/Report/ReportViewer.tsx
@@ -8,20 +8,9 @@ import type {
VerifySurface,
VerifyVerdict,
} from '@lobechat/types';
-import {
- Block,
- Button,
- Center,
- createStaticStyles,
- cssVar,
- cx,
- Empty,
- Flexbox,
- Icon,
- Image,
- Markdown,
- Text,
-} from '@lobehub/ui';
+import { Block, Button, Center, Empty, Flexbox, Icon, Image, Markdown, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { TFunction } from 'i18next';
import {
AlertTriangle,
@@ -55,6 +44,7 @@ import { useParams } from 'react-router';
import Loading from '@/components/Loading/BrandTextLoading';
import AudioPlayer from '@/features/AudioPlayer';
import type { VerifyEvidenceWithUrl } from '@/services/verify';
+import { sx } from '@/styles/sx';
import { AcceptanceDrawer } from '../AcceptanceDrawer';
import { useVerifyReportBundle } from '../hooks';
@@ -66,6 +56,7 @@ import {
renderableSurfaces,
} from '../utils';
import {
+ comparisonMedia,
EvidenceComparisonCard,
isFilenameLike,
meaningfulEvidenceCaption,
@@ -77,6 +68,7 @@ import {
markdownTextEvidenceTypes,
rendersAsMarkdown,
} from './MarkdownEvidence';
+import { narrativeMarker } from './markers.stylex';
import { originTopicHref } from './originLink';
import {
type EvidenceCategory,
@@ -92,595 +84,452 @@ import { TerminalEvidenceCard } from './TerminalEvidence';
import { readVisualizationManifest } from './visualization';
import { VisualizationRenderer } from './VisualizationRenderer';
-const styles = createStaticStyles(({ css }) => ({
- scroll: css`
- overflow: auto;
- width: 100%;
- height: 100%;
- `,
- page: css`
- width: 100%;
- max-width: 880px;
- margin-inline: auto;
- padding-block: 32px 64px;
-
+const styles = stylex.create({
+ scroll: { overflow: 'auto', width: '100%', height: '100%' },
+ page: {
+ width: '100%',
+ maxWidth: '880px',
+ marginInline: 'auto',
+ paddingBlockStart: { 'default': '32px', '@media (width <= 767px)': '16px' },
+ paddingBlockEnd: {
+ 'default': '64px',
+ '@media (width <= 767px)': 'calc(24px + env(safe-area-inset-bottom))',
+ },
/* Start-aligned with the 46px gutter a check row's body sits at, so the hero
prose and the expanded check prose share one text edge. */
- padding-inline: 46px 32px;
-
- @media (width <= 767px) {
- padding-block: 16px calc(24px + env(safe-area-inset-bottom));
- padding-inline: 16px;
- overflow-wrap: anywhere;
- }
- `,
+ paddingInlineStart: { 'default': '46px', '@media (width <= 767px)': '16px' },
+ paddingInlineEnd: { 'default': '32px', '@media (width <= 767px)': '16px' },
+ overflowWrap: { 'default': null, '@media (width <= 767px)': 'anywhere' },
+ },
/* hero */
- heroLine: css`
- display: flex;
- flex-wrap: wrap;
- gap: 12px;
- align-items: center;
- `,
- pill: css`
- display: inline-flex;
- gap: 6px;
- align-items: center;
-
- padding-block: 5px;
- padding-inline: 13px;
- border-radius: 999px;
-
- font-size: 13px;
- font-weight: 600;
- line-height: 1;
- `,
- summary: css`
- max-width: 100%;
- line-height: 1.6;
- color: ${cssVar.colorText};
- `,
- meta: css`
- display: flex;
- flex-wrap: wrap;
- gap: 8px 16px;
- margin-block-start: 4px;
- `,
- metaItem: css`
- display: inline-flex;
- gap: 6px;
- align-items: baseline;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
-
- code {
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- word-break: break-word;
- }
- `,
- liveBanner: css`
- display: inline-flex;
- gap: 8px;
- align-items: center;
-
- width: fit-content;
- margin-block-start: 4px;
- padding-block: 6px;
- padding-inline: 12px;
- border: 1px solid ${cssVar.colorInfoBorder};
- border-radius: 999px;
-
- font-size: 12px;
- color: ${cssVar.colorInfoText};
-
- background: ${cssVar.colorInfoBg};
- `,
+ heroLine: {
+ display: 'flex',
+ flexWrap: 'wrap',
+ gap: '12px',
+ alignItems: 'center',
+ },
+ pill: {
+ display: 'inline-flex',
+ gap: '6px',
+ alignItems: 'center',
+ paddingBlock: '5px',
+ paddingInline: '13px',
+ borderRadius: '999px',
+ fontSize: '13px',
+ fontWeight: 600,
+ lineHeight: 1,
+ },
+ summary: { maxWidth: '100%', lineHeight: 1.6, color: cssVar.colorText },
+ liveBanner: {
+ display: 'inline-flex',
+ gap: '8px',
+ alignItems: 'center',
+ width: 'fit-content',
+ marginBlockStart: '4px',
+ paddingBlock: '6px',
+ paddingInline: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorInfoBorder,
+ borderRadius: '999px',
+ fontSize: '12px',
+ color: cssVar.colorInfoText,
+ backgroundColor: cssVar.colorInfoBg,
+ backgroundImage: 'none',
+ },
/* Provenance: where the code came from. Reference material the reader scans,
so it stays visually subordinate to the verdict + summary above it. */
- codingScope: css`
- display: flex;
- flex-direction: column;
- gap: 6px;
-
- min-width: 0;
- max-width: 100%;
- margin-block-start: 4px;
- `,
+ codingScope: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '6px',
+ minWidth: '0',
+ maxWidth: '100%',
+ marginBlockStart: '4px',
+ },
/* The PR gets its own line. It is the one outbound link a reader actually
follows, and its title is long enough that sharing a row with branch/commit
would either push them onto a second line anyway or truncate the title to
nothing. */
- scopePullRequestLine: css`
- display: flex;
- min-width: 0;
- max-width: 100%;
- `,
- scopeMetaLine: css`
- display: flex;
- flex-wrap: wrap;
- gap: 6px 14px;
- align-items: center;
-
- min-width: 0;
- max-width: 100%;
- `,
- branchChip: css`
- display: inline-flex;
- flex: 0 1 auto;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- max-width: min(360px, 100%);
-
- color: ${cssVar.colorTextTertiary};
-
- code {
- overflow: hidden;
-
- min-width: 0;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- svg {
- flex: 0 0 auto;
- color: ${cssVar.colorTextQuaternary};
- }
- `,
- commitChip: css`
- display: inline-flex;
- flex: 0 0 auto;
- gap: 6px;
- align-items: center;
-
- color: ${cssVar.colorTextTertiary};
-
- code {
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- }
-
- svg {
- flex: 0 0 auto;
- color: ${cssVar.colorTextQuaternary};
- }
- `,
- prChip: css`
- /* Resting: number secondary, title tertiary, icon quaternary — a quiet chip.
- Hover lifts the WHOLE thing to the primary text color at once (a clearly
- perceptible emphasis, not a one-gray-step nudge), and never the global
- link-blue. Vars so number/title/icon rise together. */
- --pr-number-color: ${cssVar.colorTextSecondary};
- --pr-title-color: ${cssVar.colorTextTertiary};
- --pr-icon-color: ${cssVar.colorTextQuaternary};
-
- cursor: default;
-
- display: inline-flex;
- flex: 0 1 auto;
- gap: 6px;
- align-items: center;
-
+ scopePullRequestLine: { display: 'flex', minWidth: '0', maxWidth: '100%' },
+ scopeMetaLine: {
+ display: 'flex',
+ flexWrap: 'wrap',
+ rowGap: '6px',
+ columnGap: '14px',
+ alignItems: 'center',
+ minWidth: '0',
+ maxWidth: '100%',
+ },
+ /* Icons and <code> inside the provenance chips: StyleX has no descendant
+ selectors, so each element carries its own rule. */
+ chipIcon: {
+ flexGrow: '0',
+ flexShrink: '0',
+ flexBasis: 'auto',
+ color: cssVar.colorTextQuaternary,
+ },
+ chipCode: {
+ overflow: 'hidden',
+ minWidth: '0',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ commitCode: {
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ branchChip: {
+ display: 'inline-flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: '0',
+ maxWidth: 'min(360px, 100%)',
+ color: cssVar.colorTextTertiary,
+ },
+ commitChip: {
+ display: 'inline-flex',
+ flexGrow: '0',
+ flexShrink: '0',
+ flexBasis: 'auto',
+ gap: '6px',
+ alignItems: 'center',
+ color: cssVar.colorTextTertiary,
+ },
+ /* Resting: number secondary, title tertiary, icon quaternary — a quiet chip.
+ Hover lifts the WHOLE thing to the primary text color at once (a clearly
+ perceptible emphasis, not a one-gray-step nudge), and never the global
+ link-blue. Vars so number/title/icon rise together. */
+ prChip: {
+ '--pr-number-color': cssVar.colorTextSecondary,
+ '--pr-title-color': cssVar.colorTextTertiary,
+ '--pr-icon-color': cssVar.colorTextQuaternary,
+ 'cursor': 'default',
+ 'display': 'inline-flex',
+ 'flexGrow': '0',
+ 'flexShrink': '1',
+ 'flexBasis': 'auto',
+ 'gap': '6px',
+ 'alignItems': 'center',
/* Owns its own line, so the title gets the full column before ellipsizing. */
- min-width: 0;
- max-width: 100%;
-
- font-size: 12px;
- color: var(--pr-number-color);
- text-decoration: none;
-
- transition: color 0.15s;
-
- &[data-link='true'] {
- cursor: pointer;
- }
-
- &[data-link='true']:hover {
- --pr-number-color: ${cssVar.colorText};
- --pr-title-color: ${cssVar.colorText};
- --pr-icon-color: ${cssVar.colorTextSecondary};
-
- /* Re-assert over the global \`a:hover\` link-blue — the chip's hover is a
- text-emphasis step, never a recolor. */
- color: var(--pr-number-color);
- }
-
- > svg:first-child {
- flex: 0 0 auto;
- color: var(--pr-icon-color);
- transition: color 0.15s;
- }
- `,
- prNumber: css`
- flex: 0 0 auto;
- color: var(--pr-number-color);
- transition: color 0.15s;
- `,
- prTitle: css`
- overflow: hidden;
- flex: 1 1 auto;
-
- min-width: 0;
-
- color: var(--pr-title-color);
- text-overflow: ellipsis;
- white-space: nowrap;
-
- transition: color 0.15s;
- `,
- scopeMetaItem: css`
- display: inline-flex;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- max-width: 100%;
-
- font-size: 12px;
- line-height: 1.45;
- color: ${cssVar.colorTextTertiary};
-
- code {
- overflow: hidden;
-
- min-width: 0;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- svg {
- flex: 0 0 auto;
- color: ${cssVar.colorTextQuaternary};
- }
- `,
+ 'minWidth': '0',
+ 'maxWidth': '100%',
+ 'fontSize': '12px',
+ 'color': 'var(--pr-number-color)',
+ 'textDecoration': 'none',
+ 'transition': 'color 0.15s',
+ },
+ /* `data-link` chips: the hover step re-asserts the color over the global
+ `a:hover` link-blue — the chip's hover is a text-emphasis step, never a recolor. */
+ prChipLink: {
+ '--pr-number-color': {
+ 'default': cssVar.colorTextSecondary,
+ ':hover': cssVar.colorText,
+ },
+ '--pr-title-color': {
+ 'default': cssVar.colorTextTertiary,
+ ':hover': cssVar.colorText,
+ },
+ '--pr-icon-color': {
+ 'default': cssVar.colorTextQuaternary,
+ ':hover': cssVar.colorTextSecondary,
+ },
+ 'cursor': 'pointer',
+ 'color': { 'default': 'var(--pr-number-color)', ':hover': 'var(--pr-number-color)' },
+ },
+ prIcon: {
+ flexGrow: '0',
+ flexShrink: '0',
+ flexBasis: 'auto',
+ color: 'var(--pr-icon-color)',
+ transition: 'color 0.15s',
+ },
+ prNumber: {
+ flexGrow: '0',
+ flexShrink: '0',
+ flexBasis: 'auto',
+ color: 'var(--pr-number-color)',
+ transition: 'color 0.15s',
+ },
+ prTitle: {
+ overflow: 'hidden',
+ flexGrow: '1',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: '0',
+ color: 'var(--pr-title-color)',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ transition: 'color 0.15s',
+ },
+ scopeMetaItem: {
+ display: 'inline-flex',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: '0',
+ maxWidth: '100%',
+ fontSize: '12px',
+ lineHeight: 1.45,
+ color: cssVar.colorTextTertiary,
+ },
/* The command / URL under test. Can be long; it must never push the rest of
the provenance line onto a second row. */
- scopeEntry: css`
- max-width: 260px;
- `,
- originLink: css`
- cursor: pointer;
- color: ${cssVar.colorTextTertiary};
- text-decoration: none;
-
- &:hover {
- color: ${cssVar.colorLink};
- }
-
- &:hover svg {
- color: ${cssVar.colorLink};
- }
- `,
- surfaceList: css`
- display: flex;
- flex-wrap: wrap;
- gap: 4px;
- `,
- surfaceChip: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: ${cssVar.borderRadiusSM};
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillTertiary};
-
- svg {
- color: ${cssVar.colorTextTertiary};
- }
- `,
+ scopeEntry: { maxWidth: '260px' },
+ originLink: {
+ cursor: 'pointer',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorLink },
+ textDecoration: 'none',
+ },
+ originLinkIcon: {
+ flexGrow: '0',
+ flexShrink: '0',
+ flexBasis: 'auto',
+ color: {
+ default: cssVar.colorTextQuaternary,
+ [stylex.when.ancestor(':hover')]: cssVar.colorLink,
+ },
+ },
+ surfaceList: { display: 'flex', flexWrap: 'wrap', gap: '4px' },
+ surfaceChip: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: cssVar.borderRadiusSM,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ surfaceIcon: { color: cssVar.colorTextTertiary },
/* checks */
- checks: css`
- /* The filter bar used to carry this gap in its own margin; without it the
- hero and the first row collided. */
- overflow: hidden;
-
- margin-block-start: 24px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgContainer};
- `,
- row: css`
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- &:last-child {
- border-block-end: none;
- }
- `,
- rowHead: css`
- cursor: pointer;
-
- display: grid;
- grid-template-columns: 20px minmax(0, 1fr) auto;
- gap: 10px;
- align-items: center;
-
- width: 100%;
- padding-block: 11px;
- padding-inline: 16px;
- border: none;
-
- text-align: start;
-
- background: none;
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
-
- @media (width <= 767px) {
- grid-template-columns: 20px minmax(0, 1fr);
- gap: 6px 8px;
- padding: 12px;
- }
- `,
- rowTitle: css`
- overflow: hidden;
-
- font-size: 14px;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
-
- &[data-failed='true'] {
- font-weight: 600;
- }
-
- @media (width <= 767px) {
- overflow-wrap: anywhere;
- white-space: normal;
- }
- `,
- rowSide: css`
- display: flex;
- gap: 8px;
- align-items: center;
-
- @media (width <= 767px) {
- grid-column: 2;
- flex-wrap: wrap;
- }
- `,
- softTag: css`
- padding-block: 1px;
- padding-inline: 7px;
- border-radius: 4px;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
-
- background: ${cssVar.colorFillTertiary};
- `,
- chev: css`
- color: ${cssVar.colorTextQuaternary};
- transition: transform 0.15s ease;
-
- &[data-open='true'] {
- transform: rotate(90deg);
- }
- `,
- rowBody: css`
- display: flex;
- flex-direction: column;
- gap: 12px;
-
- padding-block: 2px 16px;
- padding-inline: 46px 16px;
-
- @media (width <= 767px) {
- padding-inline: 12px;
- }
- `,
- reasoning: css`
- font-size: 13px;
- line-height: 1.6;
- color: ${cssVar.colorTextSecondary};
- `,
- suggestion: css`
- padding-inline-start: 10px;
- border-inline-start: 2px solid ${cssVar.colorBorder};
-
- font-size: 13px;
- line-height: 1.6;
- color: ${cssVar.colorTextSecondary};
- `,
+ /* The filter bar used to carry this gap in its own margin; without it the
+ hero and the first row collided. */
+ checks: {
+ overflow: 'hidden',
+ marginBlockStart: '24px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ row: {
+ borderBlockEndWidth: { 'default': null, ':not(:last-child)': '1px' },
+ borderBlockEndStyle: { 'default': null, ':not(:last-child)': 'solid' },
+ borderBlockEndColor: { 'default': null, ':not(:last-child)': cssVar.colorBorderSecondary },
+ },
+ rowHead: {
+ cursor: 'pointer',
+ display: 'grid',
+ gridTemplateColumns: {
+ 'default': '20px minmax(0, 1fr) auto',
+ '@media (width <= 767px)': '20px minmax(0, 1fr)',
+ },
+ rowGap: { 'default': '10px', '@media (width <= 767px)': '6px' },
+ columnGap: { 'default': '10px', '@media (width <= 767px)': '8px' },
+ alignItems: 'center',
+ width: '100%',
+ paddingBlock: { 'default': '11px', '@media (width <= 767px)': '12px' },
+ paddingInline: { 'default': '16px', '@media (width <= 767px)': '12px' },
+ borderStyle: 'none',
+ textAlign: 'start',
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: 'none',
+ },
+ rowTitle: {
+ overflow: 'hidden',
+ fontSize: '14px',
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: { 'default': 'nowrap', '@media (width <= 767px)': 'normal' },
+ overflowWrap: { 'default': null, '@media (width <= 767px)': 'anywhere' },
+ },
+ rowTitleFailed: { fontWeight: 600 },
+ rowSide: {
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ gridColumn: { 'default': null, '@media (width <= 767px)': 2 },
+ flexWrap: { 'default': null, '@media (width <= 767px)': 'wrap' },
+ },
+ softTag: {
+ paddingBlock: '1px',
+ paddingInline: '7px',
+ borderRadius: '4px',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ chev: { color: cssVar.colorTextQuaternary, transition: 'transform 0.15s ease' },
+ chevOpen: { transform: 'rotate(90deg)' },
+ rowBody: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '12px',
+ paddingBlockStart: '2px',
+ paddingBlockEnd: '16px',
+ paddingInlineStart: { 'default': '46px', '@media (width <= 767px)': '12px' },
+ paddingInlineEnd: { 'default': '16px', '@media (width <= 767px)': '12px' },
+ },
+ reasoning: { fontSize: '13px', lineHeight: 1.6, color: cssVar.colorTextSecondary },
+ suggestion: {
+ paddingInlineStart: '10px',
+ borderInlineStartWidth: '2px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: cssVar.colorBorder,
+ fontSize: '13px',
+ lineHeight: 1.6,
+ color: cssVar.colorTextSecondary,
+ },
/* What the run said it would do, before it did it — read above the outcome so
intent and result sit together and a gap between them is visible. */
- planDetail: css`
- display: grid;
- grid-template-columns: auto minmax(0, 1fr);
- gap: 4px 8px;
-
- font-size: 13px;
- line-height: 1.6;
- color: ${cssVar.colorTextTertiary};
-
- @media (width <= 767px) {
- grid-template-columns: minmax(0, 1fr);
- gap: 4px;
- color: ${cssVar.colorTextSecondary};
- }
- `,
- planDetailLabel: css`
- color: ${cssVar.colorTextQuaternary};
- white-space: nowrap;
- `,
- notExecutedHint: css`
- font-size: 13px;
- line-height: 1.6;
- color: ${cssVar.colorTextTertiary};
- `,
+ planDetail: {
+ display: 'grid',
+ gridTemplateColumns: {
+ 'default': 'auto minmax(0, 1fr)',
+ '@media (width <= 767px)': 'minmax(0, 1fr)',
+ },
+ rowGap: '4px',
+ columnGap: { 'default': '8px', '@media (width <= 767px)': '4px' },
+ fontSize: '13px',
+ lineHeight: 1.6,
+ color: {
+ 'default': cssVar.colorTextTertiary,
+ '@media (width <= 767px)': cssVar.colorTextSecondary,
+ },
+ },
+ planDetailLabel: { color: cssVar.colorTextQuaternary, whiteSpace: 'nowrap' },
+ notExecutedHint: { fontSize: '13px', lineHeight: 1.6, color: cssVar.colorTextTertiary },
/* narrative */
- narrative: css`
- margin-block-start: 24px;
-
- &:not([open]) > :not(summary) {
- display: none;
- }
- `,
- narrativeSummary: css`
- cursor: pointer;
- user-select: none;
-
- display: inline-flex;
- gap: 6px;
- align-items: center;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- list-style: none;
-
- &::-webkit-details-marker {
- display: none;
- }
-
- &:hover {
- color: ${cssVar.colorText};
- }
- `,
- narrativeBody: css`
- margin-block-start: 12px;
- padding: 16px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgContainer};
- `,
- interactionCostBody: css`
- margin-block-start: 12px;
- `,
+ narrative: { marginBlockStart: '24px' },
+ narrativeContent: {
+ display: { default: null, [stylex.when.ancestor(':not([open])', narrativeMarker)]: 'none' },
+ },
+ narrativeSummary: {
+ cursor: 'pointer',
+ userSelect: 'none',
+ display: { 'default': 'inline-flex', '::-webkit-details-marker': 'none' },
+ gap: '6px',
+ alignItems: 'center',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
+ listStyle: 'none',
+ },
+ narrativeBody: {
+ marginBlockStart: '12px',
+ padding: '16px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ interactionCostBody: { marginBlockStart: '12px' },
/* evidence */
- evidenceList: css`
- display: flex;
- flex-direction: column;
- gap: 6px;
- align-items: flex-start;
-
- width: 100%;
- `,
- evidenceFile: css`
- cursor: pointer;
-
- display: grid;
- grid-template-columns: 18px minmax(0, 1fr);
- gap: 8px;
- align-items: center;
-
- width: min(100%, 520px);
- padding-block: 7px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- text-align: start;
-
- background: ${cssVar.colorFillQuaternary};
-
- &:hover {
- border-color: ${cssVar.colorLink};
- color: ${cssVar.colorLink};
- }
- `,
- evidenceFileIcon: css`
- display: flex;
- color: ${cssVar.colorTextTertiary};
- `,
- evidenceFileBody: css`
- display: flex;
- flex-direction: column;
- min-width: 0;
- `,
- evidenceFileName: css`
- overflow: hidden;
-
- font-size: 13px;
- line-height: 1.35;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- evidenceFileDesc: css`
- overflow: hidden;
-
- margin-block-start: 2px;
-
- font-size: 12px;
- line-height: 1.35;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- evidenceText: css`
- overflow: auto;
-
- max-height: 200px;
- padding-block: 8px;
- padding-inline: 12px;
- border-radius: ${cssVar.borderRadius};
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- white-space: pre-wrap;
-
- background: ${cssVar.colorFillQuaternary};
- `,
- evidenceVideo: css`
- align-self: flex-start;
-
- width: auto;
- max-width: 100%;
- max-height: 360px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusLG};
-
- object-fit: contain;
- `,
- evChip: css`
- display: inline-flex;
- gap: 4px;
- align-items: center;
-
- padding-block: 1px;
- padding-inline: 6px;
- border-radius: 999px;
-
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorTextTertiary};
-
- background: ${cssVar.colorFillTertiary};
- `,
- evidenceDoc: css`
- overflow: hidden;
- display: flex;
- flex: 1;
-
- width: 100%;
- min-height: 0;
- `,
-}));
+ evidenceList: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '6px',
+ alignItems: 'flex-start',
+ width: '100%',
+ },
+ evidenceFile: {
+ cursor: 'pointer',
+ display: 'grid',
+ gridTemplateColumns: '18px minmax(0, 1fr)',
+ gap: '8px',
+ alignItems: 'center',
+ width: 'min(100%, 520px)',
+ paddingBlock: '7px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: { 'default': cssVar.colorBorderSecondary, ':hover': cssVar.colorLink },
+ borderRadius: cssVar.borderRadius,
+ color: { 'default': null, ':hover': cssVar.colorLink },
+ textAlign: 'start',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ evidenceFileIcon: { display: 'flex', color: cssVar.colorTextTertiary },
+ evidenceFileBody: { display: 'flex', flexDirection: 'column', minWidth: '0' },
+ evidenceFileName: {
+ overflow: 'hidden',
+ fontSize: '13px',
+ lineHeight: 1.35,
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ evidenceFileDesc: {
+ overflow: 'hidden',
+ marginBlockStart: '2px',
+ fontSize: '12px',
+ lineHeight: 1.35,
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ evidenceText: {
+ overflow: 'auto',
+ maxHeight: '200px',
+ paddingBlock: '8px',
+ paddingInline: '12px',
+ borderRadius: cssVar.borderRadius,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ whiteSpace: 'pre-wrap',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ evidenceVideo: {
+ alignSelf: 'flex-start',
+ width: 'auto',
+ maxWidth: '100%',
+ maxHeight: '360px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadiusLG,
+ objectFit: 'contain',
+ },
+ evChip: {
+ display: 'inline-flex',
+ gap: '4px',
+ alignItems: 'center',
+ paddingBlock: '1px',
+ paddingInline: '6px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorTextTertiary,
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ evidenceDoc: {
+ overflow: 'hidden',
+ display: 'flex',
+ flex: '1',
+ width: '100%',
+ minHeight: '0',
+ },
+});
const VERDICT_META: Record<
CheckState,
@@ -758,6 +607,7 @@ const EvidenceItem = memo<{
const isTerminal = isTerminalEvidence(e);
const isDocument = Boolean(e.fileUrl) && !isMedia && e.type !== 'audio' && !isTerminal;
const isInlineProse = Boolean(e.content) && markdownTextEvidenceTypes.has(e.type);
+ const videoProps = stylex.props(styles.evidenceVideo, flat && comparisonMedia.video);
const hideLabel =
isTerminal ||
isDocument ||
@@ -788,14 +638,12 @@ const EvidenceItem = memo<{
preview
alt={e.description ?? label}
src={e.fileUrl}
- variant={flat ? 'borderless' : 'outlined'}
- style={
- flat ? { borderRadius: 0, maxWidth: '100%', width: '100%' } : { maxWidth: '100%' }
- }
+ style={{ maxWidth: '100%', ...(flat && { borderRadius: 0, width: '100%' }) }}
+ {...(flat ? comparisonMedia.image : { variant: 'outlined' as const })}
/>
</Flexbox>
) : e.fileUrl && e.type === 'video' ? (
- <video controls className={styles.evidenceVideo} src={e.fileUrl} />
+ <video controls {...videoProps} src={e.fileUrl} />
) : e.fileUrl && e.type === 'audio' ? (
// The same waveform player the conversation renders — one audio dialect
// across the product, plus the download the reviewer needs to keep the
@@ -807,7 +655,7 @@ const EvidenceItem = memo<{
url={e.fileUrl}
/>
) : e.fileUrl ? (
- <div className={styles.evidenceDoc}>
+ <div {...stylex.props(styles.evidenceDoc)}>
<DocumentViewer fileName={e.fileName} markdown={rendersAsMarkdown(e)} url={e.fileUrl} />
</div>
) : e.content && markdownTextEvidenceTypes.has(e.type) ? (
@@ -823,9 +671,9 @@ const EvidenceItem = memo<{
{e.content}
</CollapsibleMarkdownEvidence>
) : e.content ? (
- <div className={styles.evidenceText}>{e.content}</div>
+ <div {...stylex.props(styles.evidenceText)}>{e.content}</div>
) : (
- <span className={styles.softTag}>{e.type}</span>
+ <span {...stylex.props(styles.softTag)}>{e.type}</span>
)}
</Flexbox>
);
@@ -843,17 +691,17 @@ const EvidenceFileButton = memo<{
return (
<button
- className={styles.evidenceFile}
+ {...stylex.props(styles.evidenceFile)}
title={t('report.evidence.openDetail', { name })}
type={'button'}
onClick={onClick}
>
- <span className={styles.evidenceFileIcon}>
+ <span {...stylex.props(styles.evidenceFileIcon)}>
<Icon icon={CATEGORY_ICON[evidenceCategory(evidence.type)]} size={13} />
</span>
- <span className={styles.evidenceFileBody}>
- <span className={styles.evidenceFileName}>{name}</span>
- {description && <span className={styles.evidenceFileDesc}>{description}</span>}
+ <span {...stylex.props(styles.evidenceFileBody)}>
+ <span {...stylex.props(styles.evidenceFileName)}>{name}</span>
+ {description && <span {...stylex.props(styles.evidenceFileDesc)}>{description}</span>}
</span>
</button>
);
@@ -981,24 +829,27 @@ const CheckRow = memo<{ defaultOpen: boolean; row: CheckRowData }>(({ defaultOpe
);
return (
- <div className={styles.row}>
+ <div {...stylex.props(styles.row)}>
<button
aria-expanded={hasBody ? open : undefined}
- className={styles.rowHead}
+ {...stylex.props(styles.rowHead)}
type={'button'}
onClick={() => hasBody && setOpen((o) => !o)}
>
<span style={{ color: meta.dot, display: 'flex' }}>
<Icon icon={meta.icon} size={16} />
</span>
- <span className={styles.rowTitle} data-failed={state === 'failed'}>
+ <span
+ {...stylex.props(styles.rowTitle, state === 'failed' && styles.rowTitleFailed)}
+ data-failed={state === 'failed'}
+ >
{result?.checkItemTitle || planItem?.title || row.id}
</span>
- <span className={styles.rowSide}>
+ <span {...stylex.props(styles.rowSide)}>
{CATEGORY_ORDER.map((cat) =>
categoryCounts[cat] > 0 ? (
<span
- className={styles.evChip}
+ {...stylex.props(styles.evChip)}
key={cat}
title={`${t(`report.evidence.category.${cat}`)} × ${categoryCounts[cat]}`}
>
@@ -1008,27 +859,32 @@ const CheckRow = memo<{ defaultOpen: boolean; row: CheckRowData }>(({ defaultOpe
) : null,
)}
{state === 'not_executed' && (
- <span className={styles.softTag}>{t('report.verdict.notExecuted')}</span>
+ <span {...stylex.props(styles.softTag)}>{t('report.verdict.notExecuted')}</span>
)}
- {!required && <span className={styles.softTag}>{t('report.check.optional')}</span>}
+ {!required && <span {...stylex.props(styles.softTag)}>{t('report.check.optional')}</span>}
{hasBody && (
- <Icon className={styles.chev} data-open={open} icon={ChevronRight} size={14} />
+ <Icon
+ className={stylex.props(styles.chev, open && styles.chevOpen).className}
+ data-open={open}
+ icon={ChevronRight}
+ size={14}
+ />
)}
</span>
</button>
{open && hasBody && (
- <div className={styles.rowBody}>
+ <div {...stylex.props(styles.rowBody)}>
{(planConfig.method || planConfig.expected || requiredEvidence.length > 0) && (
- <div className={styles.planDetail}>
+ <div {...stylex.props(styles.planDetail)}>
{planConfig.method && (
<>
- <span className={styles.planDetailLabel}>{t('report.plan.method')}</span>
+ <span {...stylex.props(styles.planDetailLabel)}>{t('report.plan.method')}</span>
<span>{planConfig.method}</span>
</>
)}
{planConfig.expected && (
<>
- <span className={styles.planDetailLabel}>{t('report.plan.expected')}</span>
+ <span {...stylex.props(styles.planDetailLabel)}>{t('report.plan.expected')}</span>
<span>{planConfig.expected}</span>
</>
)}
@@ -1037,13 +893,17 @@ const CheckRow = memo<{ defaultOpen: boolean; row: CheckRowData }>(({ defaultOpe
so a reader can see what the check was contractually owed. */}
{requiredEvidence.length > 0 && (
<>
- <span className={styles.planDetailLabel}>
+ <span {...stylex.props(styles.planDetailLabel)}>
{t('report.plan.requiredEvidence')}
</span>
- <span className={styles.surfaceList}>
+ <span {...stylex.props(styles.surfaceList)}>
{requiredEvidence.map((spec) => (
- <span className={styles.surfaceChip} key={spec.type} title={spec.hint}>
- <Icon icon={CATEGORY_ICON[evidenceCategory(spec.type)]} size={12} />
+ <span {...stylex.props(styles.surfaceChip)} key={spec.type} title={spec.hint}>
+ <Icon
+ className={stylex.props(styles.surfaceIcon).className}
+ icon={CATEGORY_ICON[evidenceCategory(spec.type)]}
+ size={12}
+ />
{t(`report.evidence.medium.${spec.type}`)}
{/* Says why an authored example or a bare log leaves it uncovered. */}
{spec.provenance === 'execution' &&
@@ -1056,16 +916,16 @@ const CheckRow = memo<{ defaultOpen: boolean; row: CheckRowData }>(({ defaultOpe
</div>
)}
{state === 'not_executed' && (
- <p className={styles.notExecutedHint}>{t('report.plan.notExecutedHint')}</p>
+ <p {...stylex.props(styles.notExecutedHint)}>{t('report.plan.notExecutedHint')}</p>
)}
{result?.toulmin?.evidence && (
- <p className={styles.reasoning}>{result.toulmin.evidence}</p>
+ <p {...stylex.props(styles.reasoning)}>{result.toulmin.evidence}</p>
)}
- {result?.suggestion && <p className={styles.suggestion}>{result.suggestion}</p>}
+ {result?.suggestion && <p {...stylex.props(styles.suggestion)}>{result.suggestion}</p>}
{visualization && <VisualizationRenderer manifest={visualization} />}
{evidenceCount > 0 && (
<>
- <div className={styles.evidenceList}>
+ <div {...stylex.props(styles.evidenceList)}>
{[...comparisonGroups.entries()].map(([id, group]) =>
group.before && group.after ? (
<EvidenceComparisonView after={group.after} before={group.before} key={id} />
@@ -1178,21 +1038,21 @@ const CodingScopeCard = memo<{
const pullRequestContent =
hasPullRequest && pullRequest ? (
<>
- <Icon icon={GitPullRequest} size={15} />
- <span className={styles.prNumber}>{pullRequestLabel(pullRequest, t)}</span>
- {pullRequest.title && <span className={styles.prTitle}>{pullRequest.title}</span>}
+ <Icon className={stylex.props(styles.prIcon).className} icon={GitPullRequest} size={15} />
+ <span {...stylex.props(styles.prNumber)}>{pullRequestLabel(pullRequest, t)}</span>
+ {pullRequest.title && <span {...stylex.props(styles.prTitle)}>{pullRequest.title}</span>}
{pullRequestUrl && <Icon icon={ExternalLink} size={13} />}
</>
) : null;
const shortCommit = commit && commit.length > 12 ? commit.slice(0, 10) : commit;
return (
- <div className={styles.codingScope}>
+ <div {...stylex.props(styles.codingScope)}>
{pullRequestContent && (
- <div className={styles.scopePullRequestLine}>
+ <div {...stylex.props(styles.scopePullRequestLine)}>
{pullRequestUrl ? (
<a
- className={styles.prChip}
+ {...stylex.props(styles.prChip, styles.prChipLink)}
data-link={true}
href={pullRequestUrl}
rel="noreferrer"
@@ -1202,60 +1062,76 @@ const CodingScopeCard = memo<{
{pullRequestContent}
</a>
) : (
- <span className={styles.prChip} title={pullRequest?.title}>
+ <span {...stylex.props(styles.prChip)} title={pullRequest?.title}>
{pullRequestContent}
</span>
)}
</div>
)}
- <div className={styles.scopeMetaLine}>
+ <div {...stylex.props(styles.scopeMetaLine)}>
{branch && (
- <span className={styles.branchChip} title={branch}>
- <Icon icon={GitBranch} size={15} />
- <code>{branch}</code>
+ <span {...stylex.props(styles.branchChip)} title={branch}>
+ <Icon className={stylex.props(styles.chipIcon).className} icon={GitBranch} size={15} />
+ <code {...stylex.props(styles.chipCode)}>{branch}</code>
</span>
)}
{commit && (
- <span className={styles.commitChip} title={commit}>
- <Icon icon={GitCommit} size={14} />
- <code>{shortCommit}</code>
+ <span {...stylex.props(styles.commitChip)} title={commit}>
+ <Icon className={stylex.props(styles.chipIcon).className} icon={GitCommit} size={14} />
+ <code {...stylex.props(styles.commitCode)}>{shortCommit}</code>
</span>
)}
{date && (
- <span className={styles.scopeMetaItem}>
- <Icon icon={CalendarClock} size={13} />
+ <span {...stylex.props(styles.scopeMetaItem)}>
+ <Icon
+ className={stylex.props(styles.chipIcon).className}
+ icon={CalendarClock}
+ size={13}
+ />
<span>{date}</span>
</span>
)}
{surfaces.length > 0 && (
- <span className={styles.surfaceList}>
+ <span {...stylex.props(styles.surfaceList)}>
{surfaces.map((surface) => (
- <span className={styles.surfaceChip} key={surface}>
- <Icon icon={SURFACE_ICON[surface]} size={12} />
+ <span {...stylex.props(styles.surfaceChip)} key={surface}>
+ <Icon
+ className={stylex.props(styles.surfaceIcon).className}
+ icon={SURFACE_ICON[surface]}
+ size={12}
+ />
{t(`report.surface.${surface}`)}
</span>
))}
</span>
)}
{entry && (
- <span className={cx(styles.scopeMetaItem, styles.scopeEntry)} title={entry}>
- <Icon icon={Terminal} size={13} />
- <code>{entry}</code>
+ <span {...stylex.props(styles.scopeMetaItem, styles.scopeEntry)} title={entry}>
+ <Icon className={stylex.props(styles.chipIcon).className} icon={Terminal} size={13} />
+ <code {...stylex.props(styles.chipCode)}>{entry}</code>
</span>
)}
{/* Only ever rendered for the report's author — the server redacts `origin`
from a bundle fetched by anyone else holding the shared link. */}
{originHref && (
<a
- className={cx(styles.scopeMetaItem, styles.originLink)}
+ {...stylex.props(styles.scopeMetaItem, styles.originLink, stylex.defaultMarker())}
href={originHref}
rel="noreferrer"
target="_blank"
title={t('report.scope.origin')}
>
- <Icon icon={MessagesSquare} size={13} />
- <Icon icon={ExternalLink} size={11} />
+ <Icon
+ className={stylex.props(styles.originLinkIcon).className}
+ icon={MessagesSquare}
+ size={13}
+ />
+ <Icon
+ className={stylex.props(styles.originLinkIcon).className}
+ icon={ExternalLink}
+ size={11}
+ />
</a>
)}
</div>
@@ -1347,8 +1223,8 @@ const ReportViewer = memo<ReportViewerProps>(({ runId: explicitRunId }) => {
const origin = data.isOwner ? run.metadata?.origin : undefined;
return (
- <div className={styles.scroll}>
- <div className={styles.page}>
+ <div {...stylex.props(styles.scroll)}>
+ <div {...stylex.props(styles.page)}>
<main>
<Flexbox gap={12}>
{/* Verdict above the title, not trailing it — the same order the
@@ -1356,13 +1232,12 @@ const ReportViewer = memo<ReportViewerProps>(({ runId: explicitRunId }) => {
to its own line anyway, and then reads as an afterthought
rather than as the report's headline state. */}
{verdict && (
- <div className={styles.heroLine} style={{ marginBlockEnd: 2 }}>
+ <div {...sx(styles.heroLine, { marginBlockEnd: 2 })}>
<span
- className={styles.pill}
- style={{
+ {...sx(styles.pill, {
background: VERDICT_META[verdict].bg,
color: VERDICT_META[verdict].color,
- }}
+ })}
>
<Icon icon={VERDICT_META[verdict].icon} size={15} />
{t(`report.verdict.${verdict}`)}
@@ -1373,8 +1248,12 @@ const ReportViewer = memo<ReportViewerProps>(({ runId: explicitRunId }) => {
{run.title || t('report.titleFallback')}
</Text>
- {!isCodingReport && run.goal && <Text className={styles.summary}>{run.goal}</Text>}
- {report?.summary && <Text className={styles.summary}>{report.summary}</Text>}
+ {!isCodingReport && run.goal && (
+ <Text className={stylex.props(styles.summary).className}>{run.goal}</Text>
+ )}
+ {report?.summary && (
+ <Text className={stylex.props(styles.summary).className}>{report.summary}</Text>
+ )}
{isCodingReport && (
<CodingScopeCard
@@ -1384,7 +1263,7 @@ const ReportViewer = memo<ReportViewerProps>(({ runId: explicitRunId }) => {
)}
{liveStatus && (
- <div className={styles.liveBanner}>
+ <div {...stylex.props(styles.liveBanner)}>
<Icon icon={Clock3} size={14} />
{t(liveStatusLabelKey[liveStatus])}
</div>
@@ -1392,7 +1271,7 @@ const ReportViewer = memo<ReportViewerProps>(({ runId: explicitRunId }) => {
</Flexbox>
{visible.length > 0 ? (
- <div className={styles.checks}>
+ <div {...stylex.props(styles.checks)}>
{visible.map((row) => (
/* Every row opens. A report is read to see what was actually
observed, and a page of collapsed titles makes the reader
@@ -1407,24 +1286,24 @@ const ReportViewer = memo<ReportViewerProps>(({ runId: explicitRunId }) => {
)}
{report?.content && (
- <details className={styles.narrative}>
- <summary className={styles.narrativeSummary}>
+ <details {...stylex.props(styles.narrative, narrativeMarker)}>
+ <summary {...stylex.props(styles.narrativeSummary)}>
<Icon icon={ChevronRight} size={13} />
{t('report.sections.details')}
</summary>
- <div className={styles.narrativeBody}>
+ <div {...stylex.props(styles.narrativeBody, styles.narrativeContent)}>
<Markdown>{report.content}</Markdown>
</div>
</details>
)}
{interactionCost && (
- <details className={styles.narrative}>
- <summary className={styles.narrativeSummary}>
+ <details {...stylex.props(styles.narrative, narrativeMarker)}>
+ <summary {...stylex.props(styles.narrativeSummary)}>
<Icon icon={ChevronRight} size={13} />
{t('report.interaction.title')}
</summary>
- <div className={styles.interactionCostBody}>
+ <div {...stylex.props(styles.interactionCostBody, styles.narrativeContent)}>
<InteractionCostPanel cost={interactionCost} />
</div>
</details>
diff --git a/src/features/Acceptance/Report/VisualizationRenderer.tsx b/src/features/Acceptance/Report/VisualizationRenderer.tsx
index 129c3dc3d0c..4e8a8b7e071 100644
--- a/src/features/Acceptance/Report/VisualizationRenderer.tsx
+++ b/src/features/Acceptance/Report/VisualizationRenderer.tsx
@@ -10,12 +10,16 @@ import type {
VerifyVisualizationDataset,
VerifyVisualizationManifest,
} from '@lobechat/types';
-import { createStaticStyles, cssVar, cx, Flexbox, Icon, Text } from '@lobehub/ui';
+import { Flexbox, Icon, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ArrowDownRight, ArrowUpRight, ChartNoAxesCombined } from 'lucide-react';
import type { ReactNode } from 'react';
import { Fragment, memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { sx } from '@/styles/sx';
+
import {
datasetForView,
fieldLabel,
@@ -26,200 +30,166 @@ import {
tableHighlightRows,
} from './visualization';
-const styles = createStaticStyles(({ css }) => ({
- axisLabel: css`
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- `,
- badge: css`
- display: inline-flex;
- gap: 3px;
- align-items: center;
-
- padding-block: 1px;
- padding-inline: 5px;
- border-radius: 999px;
-
- font-size: 11px;
- font-weight: 600;
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorSuccess};
-
- background: ${cssVar.colorSuccessBg};
- `,
- badgeWorse: css`
- color: ${cssVar.colorError};
- background: ${cssVar.colorErrorBg};
- `,
- bar: css`
- overflow: hidden;
- height: 6px;
- border-radius: 999px;
- background: ${cssVar.colorFillSecondary};
- `,
- barChartLabel: css`
- font-size: 11px;
- color: ${cssVar.colorTextSecondary};
- `,
- barAfter: css`
- height: 100%;
- border-radius: inherit;
- background: ${cssVar.colorInfo};
- `,
- barBefore: css`
- height: 100%;
- border-radius: inherit;
- background: ${cssVar.colorTextQuaternary};
- `,
- body: css`
- min-width: 0;
- padding: 14px;
- `,
- card: css`
- overflow: hidden;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusLG};
- background: ${cssVar.colorBgContainer};
- `,
- chart: css`
- display: block;
- width: 100%;
- min-height: 180px;
- `,
- context: css`
- padding-block: 8px 10px;
- padding-inline: 14px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- delta: css`
- display: inline-flex;
- gap: 3px;
- align-items: center;
-
- font-weight: 600;
- font-variant-numeric: tabular-nums;
- color: ${cssVar.colorSuccess};
- `,
- deltaWorse: css`
- color: ${cssVar.colorError};
- `,
- header: css`
- padding-block: 10px;
- padding-inline: 14px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- heatmap: css`
- display: grid;
- gap: 3px;
- align-items: center;
- `,
- heatmapCell: css`
- display: flex;
- align-items: center;
- justify-content: center;
-
- min-height: 34px;
- border-radius: ${cssVar.borderRadiusSM};
-
- font-size: 11px;
- font-weight: 600;
- font-variant-numeric: tabular-nums;
- `,
- metric: css`
- display: grid;
- grid-template-columns: minmax(120px, 1fr) minmax(240px, 2.4fr) auto;
- gap: 16px;
- align-items: center;
-
- padding-block: 12px;
- padding-inline: 14px;
-
- & + & {
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- }
-
- @media (width <= 640px) {
- grid-template-columns: 1fr auto;
- }
- `,
- metricName: css`
- min-width: 0;
- font-weight: 500;
- `,
- sample: css`
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- `,
- table: css`
- border-collapse: collapse;
- width: 100%;
-
- th,
- td {
- padding-block: 8px;
- padding-inline: 10px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- text-align: start;
- white-space: nowrap;
- }
-
- th {
- font-size: 11px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- background: ${cssVar.colorFillQuaternary};
- }
-
- td {
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- }
- `,
- tableBest: css`
- font-weight: 700;
- color: ${cssVar.colorInfo};
- background: ${cssVar.colorInfoBg};
- `,
- tableBestBadge: css`
- margin-inline-start: 5px;
- padding-block: 1px;
- padding-inline: 4px;
- border-radius: 4px;
-
- font-size: 9px;
- font-weight: 700;
- color: ${cssVar.colorInfo};
-
- background: ${cssVar.colorInfoBgHover};
- `,
- tableScroll: css`
- overflow-x: auto;
- `,
- target: css`
- font-size: 11px;
- color: ${cssVar.colorTextSecondary};
- `,
- values: css`
- display: flex;
- flex-direction: column;
- gap: 9px;
-
- @media (width <= 640px) {
- grid-column: 1 / -1;
- grid-row: 2;
- }
- `,
- valueText: css`
- display: flex;
- justify-content: space-between;
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- `,
-}));
+const styles = stylex.create({
+ axisLabel: { fontSize: '11px', color: cssVar.colorTextTertiary },
+ badge: {
+ display: 'inline-flex',
+ gap: '3px',
+ alignItems: 'center',
+ paddingBlock: '1px',
+ paddingInline: '5px',
+ borderRadius: '999px',
+ fontSize: '11px',
+ fontWeight: 600,
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorSuccess,
+ backgroundColor: cssVar.colorSuccessBg,
+ backgroundImage: 'none',
+ },
+ badgeWorse: {
+ color: cssVar.colorError,
+ backgroundColor: cssVar.colorErrorBg,
+ backgroundImage: 'none',
+ },
+ bar: {
+ overflow: 'hidden',
+ height: '6px',
+ borderRadius: '999px',
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ barChartLabel: { fontSize: '11px', color: cssVar.colorTextSecondary },
+ barAfter: {
+ height: '100%',
+ borderRadius: 'inherit',
+ backgroundColor: cssVar.colorInfo,
+ backgroundImage: 'none',
+ },
+ barBefore: {
+ height: '100%',
+ borderRadius: 'inherit',
+ backgroundColor: cssVar.colorTextQuaternary,
+ backgroundImage: 'none',
+ },
+ body: { minWidth: '0', padding: '14px' },
+ card: {
+ overflow: 'hidden',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ chart: { display: 'block', width: '100%', minHeight: '180px' },
+ context: {
+ paddingBlockStart: '8px',
+ paddingBlockEnd: '10px',
+ paddingInline: '14px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ },
+ delta: {
+ display: 'inline-flex',
+ gap: '3px',
+ alignItems: 'center',
+ fontWeight: 600,
+ fontVariantNumeric: 'tabular-nums',
+ color: cssVar.colorSuccess,
+ },
+ deltaWorse: { color: cssVar.colorError },
+ header: {
+ paddingBlock: '10px',
+ paddingInline: '14px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ },
+ heatmap: { display: 'grid', gap: '3px', alignItems: 'center' },
+ heatmapCell: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ minHeight: '34px',
+ borderRadius: cssVar.borderRadiusSM,
+ fontSize: '11px',
+ fontWeight: 600,
+ fontVariantNumeric: 'tabular-nums',
+ },
+ metric: {
+ display: 'grid',
+ gridTemplateColumns: {
+ 'default': 'minmax(120px, 1fr) minmax(240px, 2.4fr) auto',
+ '@media (width <= 640px)': '1fr auto',
+ },
+ gap: '16px',
+ alignItems: 'center',
+ paddingBlock: '12px',
+ paddingInline: '14px',
+ borderBlockStartWidth: { default: null, [stylex.when.siblingBefore(':is(*)')]: '1px' },
+ borderBlockStartStyle: { default: null, [stylex.when.siblingBefore(':is(*)')]: 'solid' },
+ borderBlockStartColor: {
+ default: null,
+ [stylex.when.siblingBefore(':is(*)')]: cssVar.colorBorderSecondary,
+ },
+ },
+ metricName: { minWidth: '0', fontWeight: 500 },
+ sample: { fontSize: '11px', color: cssVar.colorTextTertiary },
+ table: { borderCollapse: 'collapse', width: '100%' },
+ /* The table cells are styled per element: StyleX has no descendant selectors. */
+ cell: {
+ paddingBlock: '8px',
+ paddingInline: '10px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ textAlign: 'start',
+ whiteSpace: 'nowrap',
+ },
+ th: {
+ fontSize: '11px',
+ fontWeight: 500,
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ td: { fontSize: '12px', fontVariantNumeric: 'tabular-nums' },
+ tableBest: {
+ fontWeight: 700,
+ color: cssVar.colorInfo,
+ backgroundColor: cssVar.colorInfoBg,
+ backgroundImage: 'none',
+ },
+ tableBestBadge: {
+ marginInlineStart: '5px',
+ paddingBlock: '1px',
+ paddingInline: '4px',
+ borderRadius: '4px',
+ fontSize: '9px',
+ fontWeight: 700,
+ color: cssVar.colorInfo,
+ backgroundColor: cssVar.colorInfoBgHover,
+ backgroundImage: 'none',
+ },
+ tableScroll: { overflowX: 'auto' },
+ target: { fontSize: '11px', color: cssVar.colorTextSecondary },
+ values: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '9px',
+ gridColumn: { 'default': null, '@media (width <= 640px)': '1 / -1' },
+ gridRow: { 'default': null, '@media (width <= 640px)': 2 },
+ },
+ valueText: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ fontSize: '12px',
+ fontVariantNumeric: 'tabular-nums',
+ },
+});
const SERIES_COLORS = [
cssVar.colorInfo,
@@ -257,13 +227,18 @@ const ViewCard = memo<{
}>(({ children, context, title }) => {
const { t } = useTranslation('verify');
return (
- <div className={styles.card}>
- <Flexbox horizontal align={'center'} className={styles.header} gap={8}>
+ <div {...stylex.props(styles.card)}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.header).className}
+ gap={8}
+ >
<Icon icon={ChartNoAxesCombined} size={15} />
<Text strong>{title ?? t('report.visualization.title')}</Text>
</Flexbox>
{children}
- {context && <div className={styles.context}>{context}</div>}
+ {context && <div {...stylex.props(styles.context)}>{context}</div>}
</div>
);
});
@@ -297,17 +272,22 @@ const MetricComparisonRenderer = memo<{
const DeltaIcon = after <= before ? ArrowDownRight : ArrowUpRight;
return (
- <div className={styles.metric} key={`${stringCell(row, view.encoding.label)}-${index}`}>
+ <div
+ {...stylex.props(styles.metric, stylex.defaultMarker())}
+ key={`${stringCell(row, view.encoding.label)}-${index}`}
+ >
<Flexbox gap={2}>
- <span className={styles.metricName}>
+ <span {...stylex.props(styles.metricName)}>
{stringCell(row, view.encoding.label) ?? t('report.visualization.unnamed')}
</span>
<Flexbox horizontal gap={8}>
{view.encoding.statistic && (
- <span className={styles.sample}>{stringCell(row, view.encoding.statistic)}</span>
+ <span {...stylex.props(styles.sample)}>
+ {stringCell(row, view.encoding.statistic)}
+ </span>
)}
{(view.encoding.beforeSamples || view.encoding.afterSamples) && (
- <span className={styles.sample}>
+ <span {...stylex.props(styles.sample)}>
n=
{view.encoding.beforeSamples
? (numberCell(row, view.encoding.beforeSamples) ?? '–')
@@ -320,22 +300,23 @@ const MetricComparisonRenderer = memo<{
)}
</Flexbox>
</Flexbox>
- <div className={styles.values}>
+ <div {...stylex.props(styles.values)}>
{(
[
['before', before, styles.barBefore],
['after', after, styles.barAfter],
] as const
- ).map(([role, value, barClass]) => (
+ ).map(([role, value, barStyle]) => (
<Flexbox gap={5} key={role}>
- <span className={styles.valueText}>
+ <span {...stylex.props(styles.valueText)}>
<span>{t(`report.visualization.${role}`)}</span>
<strong>{formatValue(value, unit)}</strong>
</span>
- <div className={styles.bar}>
+ <div {...stylex.props(styles.bar)}>
<div
- className={barClass}
- style={{ width: `${Math.max(3, (Math.abs(value) / maximum) * 100)}%` }}
+ {...sx(barStyle, {
+ width: `${Math.max(3, (Math.abs(value) / maximum) * 100)}%`,
+ })}
/>
</div>
</Flexbox>
@@ -343,13 +324,13 @@ const MetricComparisonRenderer = memo<{
</div>
<Flexbox align={'flex-end'} gap={2}>
{improvement !== null && (
- <span className={cx(styles.delta, !improved && styles.deltaWorse)}>
+ <span {...stylex.props(styles.delta, !improved && styles.deltaWorse)}>
<Icon icon={DeltaIcon} size={13} />
{Math.abs(improvement).toFixed(1)}%
</span>
)}
{target !== null && (
- <span className={styles.target}>
+ <span {...stylex.props(styles.target)}>
{t(
targetMet
? 'report.visualization.targetMet'
@@ -388,10 +369,10 @@ const LineChartRenderer = memo<{
return (
<ViewCard context={view.context} title={view.title}>
- <div className={styles.body}>
+ <div {...stylex.props(styles.body)}>
<svg
aria-label={view.title ?? 'Line chart'}
- className={styles.chart}
+ {...stylex.props(styles.chart)}
role={'img'}
viewBox={'0 0 640 230'}
>
@@ -467,10 +448,10 @@ const ScatterPlotRenderer = memo<{
return (
<ViewCard context={view.context} title={view.title}>
- <div className={styles.body}>
+ <div {...stylex.props(styles.body)}>
<svg
aria-label={view.title ?? 'Scatter plot'}
- className={styles.chart}
+ {...stylex.props(styles.chart)}
role={'img'}
viewBox={'0 0 640 230'}
>
@@ -531,32 +512,32 @@ const HeatmapRenderer = memo<{
return (
<ViewCard context={view.context} title={view.title}>
- <div className={styles.body}>
+ <div {...stylex.props(styles.body)}>
<div
- className={styles.heatmap}
- style={{ gridTemplateColumns: `minmax(64px, auto) repeat(${xValues.length}, 1fr)` }}
+ {...sx(styles.heatmap, {
+ gridTemplateColumns: `minmax(64px, auto) repeat(${xValues.length}, 1fr)`,
+ })}
>
<span />
{xValues.map((value) => (
- <span className={styles.axisLabel} key={value} style={{ textAlign: 'center' }}>
+ <span {...sx(styles.axisLabel, { textAlign: 'center' })} key={value}>
{value}
</span>
))}
{yValues.map((y) => (
<Fragment key={y}>
- <span className={styles.axisLabel}>{y}</span>
+ <span {...stylex.props(styles.axisLabel)}>{y}</span>
{xValues.map((x) => {
const value = byCoordinate.get(`${x}\0${y}`);
const intensity =
typeof value === 'number' ? 0.14 + ((value - minimum) / span) * 0.76 : 0;
return (
<span
- className={styles.heatmapCell}
key={`${x}-${y}`}
- style={{
+ {...sx(styles.heatmapCell, {
background: `color-mix(in srgb, ${cssVar.colorInfo} ${intensity * 100}%, ${cssVar.colorBgContainer})`,
color: intensity > 0.58 ? cssVar.colorTextLightSolid : cssVar.colorText,
- }}
+ })}
>
{typeof value === 'number' ? formatValue(value) : '–'}
</span>
@@ -592,10 +573,10 @@ const BarChartRenderer = memo<{
return (
<ViewCard context={view.context} title={view.title}>
- <div className={styles.body}>
+ <div {...stylex.props(styles.body)}>
<svg
aria-label={view.title ?? 'Bar chart'}
- className={styles.chart}
+ {...stylex.props(styles.chart)}
role={'img'}
viewBox={'0 0 640 250'}
>
@@ -623,7 +604,7 @@ const BarChartRenderer = memo<{
);
})}
<text
- className={styles.barChartLabel}
+ {...stylex.props(styles.barChartLabel)}
fill={cssVar.colorTextSecondary}
textAnchor={'middle'}
x={groupStart + groupWidth / 2}
@@ -674,12 +655,14 @@ const TableRenderer = memo<{
);
return (
<ViewCard context={view.context} title={view.title}>
- <div className={styles.tableScroll}>
- <table className={styles.table}>
+ <div {...stylex.props(styles.tableScroll)}>
+ <table {...stylex.props(styles.table)}>
<thead>
<tr>
{fields.map((field) => (
- <th key={field.key}>{field.label ?? field.key}</th>
+ <th {...stylex.props(styles.cell, styles.th)} key={field.key}>
+ {field.label ?? field.key}
+ </th>
))}
</tr>
</thead>
@@ -689,9 +672,12 @@ const TableRenderer = memo<{
{fields.map((field) => {
const isBest = highlightedRows.get(field.key)?.has(index) ?? false;
return (
- <td className={isBest ? styles.tableBest : undefined} key={field.key}>
+ <td
+ {...stylex.props(styles.cell, styles.td, isBest && styles.tableBest)}
+ key={field.key}
+ >
{String(row[field.key] ?? '–')}
- {isBest && <span className={styles.tableBestBadge}>SOTA</span>}
+ {isBest && <span {...stylex.props(styles.tableBestBadge)}>SOTA</span>}
</td>
);
})}
@@ -718,7 +704,7 @@ export const VisualizationDeltaBadge = memo<{
const improved = delta.improvement >= 0;
const DeltaIcon = delta.after <= delta.before ? ArrowDownRight : ArrowUpRight;
return (
- <span className={cx(styles.badge, !improved && styles.badgeWorse)}>
+ <span {...stylex.props(styles.badge, !improved && styles.badgeWorse)}>
<Icon icon={DeltaIcon} size={11} />
{Math.abs(delta.improvement).toFixed(1)}%
</span>
diff --git a/src/features/Acceptance/Report/markers.stylex.ts b/src/features/Acceptance/Report/markers.stylex.ts
new file mode 100644
index 00000000000..e903854c211
--- /dev/null
+++ b/src/features/Acceptance/Report/markers.stylex.ts
@@ -0,0 +1,3 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const narrativeMarker = stylex.defineMarker();
diff --git a/src/features/Acceptance/Run/CheckerDock.tsx b/src/features/Acceptance/Run/CheckerDock.tsx
index 63784e1b887..09d9aaed3a0 100644
--- a/src/features/Acceptance/Run/CheckerDock.tsx
+++ b/src/features/Acceptance/Run/CheckerDock.tsx
@@ -1,15 +1,7 @@
import type { VerifyCheckItem } from '@lobechat/types';
-import {
- ActionIcon,
- Button,
- createStaticStyles,
- cssVar,
- cx,
- Flexbox,
- Icon,
- Input,
- useThemeMode,
-} from '@lobehub/ui';
+import { ActionIcon, Button, Flexbox, Icon, Input, useThemeMode } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
Check,
CheckCircle2,
@@ -36,90 +28,82 @@ import { useChatStore } from '@/store/chat';
import { useVerifyResults, useVerifyState } from '../hooks';
import { countResults, phaseFromStatus } from '../utils';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- actions: css`
- margin-block-start: 12px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- `,
- body: css`
- padding-block: 0 12px;
- padding-inline: 12px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
- `,
- /* In the merged verify card the RunResult header already draws the divider —
- drop our own top border so they don't stack into a 2px line. */
- bodyEmbedded: css`
- border-block-start: none;
- `,
- checkRow: css`
- display: grid;
- grid-template-columns: 20px minmax(0, 1fr) auto;
- gap: 8px;
- align-items: start;
-
- padding-block: 12px;
-
- &:not(:last-child) {
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- }
- `,
- chevron: css`
- flex: none;
- color: ${cssVar.colorTextQuaternary};
- `,
- clickable: css`
- cursor: pointer;
- transition: background 150ms ${cssVar.motionEaseOut};
-
- &:hover {
- background: ${cssVar.colorFillQuaternary};
- }
- `,
- desc: css`
- margin-block-start: 3px;
- font-size: 12px;
- line-height: 1.45;
- color: ${cssVar.colorTextTertiary};
- `,
- dock: css`
- overflow: hidden;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 16px;
- background: ${cssVar.colorBgElevated};
- `,
- head: css`
- cursor: pointer;
-
- display: flex;
- gap: 12px;
- align-items: center;
- justify-content: space-between;
-
- padding-block: 11px;
- padding-inline: 12px;
- `,
- inputPanel: css`
- margin-block-start: 10px;
- padding: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 12px;
-
- background: ${cssVar.colorFillQuaternary};
- `,
- sub: css`
- overflow: hidden;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- title: css`
- font-size: 13px;
- font-weight: 700;
- color: ${cssVar.colorText};
- `,
-}));
+const styles = stylex.create({
+ actions: {
+ marginBlockStart: '12px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ },
+ body: {
+ paddingBlockStart: '0',
+ paddingBlockEnd: '12px',
+ paddingInline: '12px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ },
+ bodyEmbedded: { borderBlockStartStyle: 'none' },
+ checkRow: {
+ display: 'grid',
+ gridTemplateColumns: '20px minmax(0, 1fr) auto',
+ gap: '8px',
+ alignItems: 'start',
+ paddingBlock: '12px',
+ borderBlockEndWidth: { 'default': null, ':not(:last-child)': '1px' },
+ borderBlockEndStyle: { 'default': null, ':not(:last-child)': 'solid' },
+ borderBlockEndColor: { 'default': null, ':not(:last-child)': cssVar.colorBorderSecondary },
+ },
+ chevron: { flex: 'none', color: cssVar.colorTextQuaternary },
+ clickable: {
+ cursor: 'pointer',
+ transition: `background 150ms ${cssVar.motionEaseOut}`,
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ desc: {
+ marginBlockStart: '3px',
+ fontSize: '12px',
+ lineHeight: 1.45,
+ color: cssVar.colorTextTertiary,
+ },
+ dock: {
+ overflow: 'hidden',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: '16px',
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ },
+ head: {
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '12px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingBlock: '11px',
+ paddingInline: '12px',
+ },
+ inputPanel: {
+ marginBlockStart: '10px',
+ padding: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '12px',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ sub: {
+ overflow: 'hidden',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ title: { fontSize: '13px', fontWeight: 700, color: cssVar.colorText },
+});
const statusIcon = (
status: VerifyCheckResultItem['status'] | undefined,
@@ -218,7 +202,7 @@ const CheckerDock = memo<CheckerDockProps>(({ operationId, embedded }) => {
// buried the checklist under paragraphs. The row opens the full result.
return (
<div
- className={cx(styles.checkRow, styles.clickable)}
+ {...stylex.props(styles.checkRow, styles.clickable)}
key={item.id}
onClick={() => openVerifyResult(operationId, item.id)}
>
@@ -235,11 +219,14 @@ const CheckerDock = memo<CheckerDockProps>(({ operationId, embedded }) => {
) : (
<Icon color={cssVar[sIcon.color]} icon={sIcon.icon} size={16} spin={sIcon.spin} />
)}
- <span className={styles.title} style={{ fontWeight: 600, minWidth: 0 }}>
+ <span
+ className={stylex.props(styles.title).className}
+ style={{ fontWeight: 600, minWidth: 0 }}
+ >
{item.title}
</span>
<Icon
- className={styles.chevron}
+ className={stylex.props(styles.chevron).className}
icon={ChevronRight}
size={16}
style={{ marginBlockStart: 2 }}
@@ -320,15 +307,15 @@ const CheckerDock = memo<CheckerDockProps>(({ operationId, embedded }) => {
);
if (phase === 'repairing')
return (
- <div className={styles.inputPanel} style={{ marginTop: 10 }}>
- <div className={styles.desc}>{t('dock.repairHint')}</div>
+ <div className={stylex.props(styles.inputPanel).className} style={{ marginTop: 10 }}>
+ <div {...stylex.props(styles.desc)}>{t('dock.repairHint')}</div>
</div>
);
return null;
};
const body = (
- <div className={cx(styles.body, embedded && styles.bodyEmbedded)}>
+ <div {...stylex.props(styles.body, embedded && styles.bodyEmbedded)}>
{editing ? (
renderEditor()
) : (
@@ -336,7 +323,7 @@ const CheckerDock = memo<CheckerDockProps>(({ operationId, embedded }) => {
<Flexbox gap={0}>{plan.map((item) => renderCheckRow(item))}</Flexbox>
{(() => {
const actions = renderActions();
- return actions ? <div className={styles.actions}>{actions}</div> : null;
+ return actions ? <div {...stylex.props(styles.actions)}>{actions}</div> : null;
})()}
</>
)}
@@ -354,15 +341,15 @@ const CheckerDock = memo<CheckerDockProps>(({ operationId, embedded }) => {
: ShieldCheck;
return (
- <div className={styles.dock}>
- <div className={styles.head} onClick={() => setExpanded((v) => !v)}>
+ <div {...stylex.props(styles.dock)}>
+ <div {...stylex.props(styles.head)} onClick={() => setExpanded((v) => !v)}>
<Flexbox horizontal align="center" gap={10} style={{ minWidth: 0 }}>
<Icon icon={headIcon} size={18} />
<Flexbox style={{ minWidth: 0 }}>
<Flexbox horizontal align="center" gap={8}>
- <span className={styles.title}>{t('dock.title')}</span>
+ <span {...stylex.props(styles.title)}>{t('dock.title')}</span>
</Flexbox>
- <span className={styles.sub}>{subText}</span>
+ <span {...stylex.props(styles.sub)}>{subText}</span>
</Flexbox>
</Flexbox>
<Icon
diff --git a/src/features/Acceptance/Run/RunResult.tsx b/src/features/Acceptance/Run/RunResult.tsx
index e4cfda4d02a..926c88bf0c3 100644
--- a/src/features/Acceptance/Run/RunResult.tsx
+++ b/src/features/Acceptance/Run/RunResult.tsx
@@ -1,4 +1,6 @@
-import { createStaticStyles, cssVar, cx, Flexbox, Icon } from '@lobehub/ui';
+import { Flexbox, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { Info, Shield, ShieldAlert, ShieldCheck, ShieldX } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -6,61 +8,55 @@ import { useTranslation } from 'react-i18next';
import { useVerifyResults, useVerifyState } from '../hooks';
import { countResults, type DockPhase, phaseFromStatus } from '../utils';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- body: css`
- padding-block: 12px;
- padding-inline: 16px;
-
- font-size: 13px;
- line-height: 1.7;
- color: ${cssVar.colorTextSecondary};
- `,
- card: css`
- overflow: hidden;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 16px;
- background: ${cssVar.colorBgContainer};
- `,
- cardFailed: css`
- border-color: ${cssVar.colorErrorBorder};
- `,
- foot: css`
- display: flex;
- gap: 8px;
- align-items: center;
-
- padding-block: 10px;
- padding-inline: 16px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- head: css`
- display: flex;
- gap: 14px;
- align-items: flex-start;
-
- padding-block: 14px;
- padding-inline: 16px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
- status: css`
- font-size: 13px;
- font-weight: 600;
- `,
- sub: css`
- margin-block-start: 4px;
- font-size: 12px;
- line-height: 1.5;
- color: ${cssVar.colorTextTertiary};
- `,
- title: css`
- font-size: 15px;
- font-weight: 700;
- color: ${cssVar.colorText};
- `,
-}));
+const styles = stylex.create({
+ body: {
+ paddingBlock: '12px',
+ paddingInline: '16px',
+ fontSize: '13px',
+ lineHeight: 1.7,
+ color: cssVar.colorTextSecondary,
+ },
+ card: {
+ overflow: 'hidden',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '16px',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ cardFailed: { borderColor: cssVar.colorErrorBorder },
+ foot: {
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ paddingBlock: '10px',
+ paddingInline: '16px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ head: {
+ display: 'flex',
+ gap: '14px',
+ alignItems: 'flex-start',
+ paddingBlock: '14px',
+ paddingInline: '16px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ },
+ status: { fontSize: '13px', fontWeight: 600 },
+ sub: {
+ marginBlockStart: '4px',
+ fontSize: '12px',
+ lineHeight: 1.5,
+ color: cssVar.colorTextTertiary,
+ },
+ title: { fontSize: '15px', fontWeight: 700, color: cssVar.colorText },
+});
interface BadgeMeta {
color: 'default' | 'success' | 'error' | 'warning';
@@ -144,7 +140,7 @@ const RunResult = memo<RunResultProps>(({ operationId, round = 1, embedded }) =>
// never has to travel to the far edge of the card — a pill there read as a
// separate control and left the title looking neutral on a failed round.
const header = (
- <div className={styles.head}>
+ <div {...stylex.props(styles.head)}>
<Flexbox>
<Flexbox horizontal align="center" gap={7}>
<Icon
@@ -152,12 +148,15 @@ const RunResult = memo<RunResultProps>(({ operationId, round = 1, embedded }) =>
icon={meta.badge.icon}
size={16}
/>
- <span className={styles.title}>{t('result.title', { round })}</span>
- <span className={styles.status} style={{ color: badgeTextMap[meta.badge.color] }}>
+ <span {...stylex.props(styles.title)}>{t('result.title', { round })}</span>
+ <span
+ className={stylex.props(styles.status).className}
+ style={{ color: badgeTextMap[meta.badge.color] }}
+ >
{t(`badge.${meta.badge.key}` as any)}
</span>
</Flexbox>
- <div className={styles.sub}>
+ <div {...stylex.props(styles.sub)}>
{t(meta.subKey as any, { passed: counts.passed, total: counts.total } as any)}
</div>
</Flexbox>
@@ -168,9 +167,9 @@ const RunResult = memo<RunResultProps>(({ operationId, round = 1, embedded }) =>
if (embedded) return header;
return (
- <div className={cx(styles.card, phase === 'failed' && styles.cardFailed)}>
+ <div {...stylex.props(styles.card, phase === 'failed' && styles.cardFailed)}>
{header}
- <div className={styles.body}>
+ <div {...stylex.props(styles.body)}>
<Flexbox gap={4}>
{(state.verifyPlan ?? []).map((item) => {
const result = (results ?? []).find((r) => r.checkItemId === item.id);
@@ -191,7 +190,7 @@ const RunResult = memo<RunResultProps>(({ operationId, round = 1, embedded }) =>
})}
</Flexbox>
</div>
- <div className={styles.foot}>
+ <div {...stylex.props(styles.foot)}>
<Icon icon={Info} size={14} />
<span>{t('result.foot')}</span>
</div>
diff --git a/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx b/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx
index 40649d421db..ab3d3a587ef 100644
--- a/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx
@@ -8,6 +8,7 @@ import { memo, type ReactNode } from 'react';
import AudioPlayer from '@/features/AudioPlayer';
import {
+ comparisonMedia,
EvidenceComparisonCard,
meaningfulEvidenceCaption,
readEvidenceComparison,
@@ -59,7 +60,7 @@ const comparisonContent = (item: AcceptanceEvidence, action?: ReactNode, video?:
loading={'lazy'}
src={item.fileUrl!}
style={{ aspectRatio: imageRatio(item), borderRadius: 0, width: '100%' }}
- variant={'borderless'}
+ {...comparisonMedia.image}
/>
);
if (!action) return image;
diff --git a/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx b/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx
index 63aa99ab1f4..de9ba98eeaa 100644
--- a/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx
@@ -5,6 +5,7 @@ import { Check, MessageSquare, X } from 'lucide-react';
import { memo, type ReactNode, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { comparisonMedia } from '../../Report/EvidenceComparisonCard';
import { useOptionalAcceptanceScope } from '../AcceptanceScope';
import { commentAnchorId } from '../Comments/anchor';
import { FLOATING_ACTION_HOST } from './FloatingCommentAction';
@@ -448,6 +449,7 @@ export const ScreenshotTiles = memo<ScreenshotTilesProps>(
>
<Image
alt={alt}
+ {...(flat ? comparisonMedia.image : undefined)}
loading={'lazy'}
src={src}
style={flat ? { borderRadius: 0 } : undefined}
@@ -483,6 +485,7 @@ export const ScreenshotTiles = memo<ScreenshotTilesProps>(
>
<Image
alt={alt}
+ {...(flat ? comparisonMedia.image : undefined)}
height={'100%'}
loading={'lazy'}
maxHeight={'none'}
@@ -533,6 +536,7 @@ export const ScreenshotTiles = memo<ScreenshotTilesProps>(
>
<Image
alt={alt}
+ {...(flat ? comparisonMedia.image : undefined)}
loading={'lazy'}
maxHeight={'none'}
maxWidth={'none'}
diff --git a/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx b/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx
index b8b57bd4431..3d722c90f51 100644
--- a/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx
+++ b/src/features/Acceptance/Workspace/AcceptanceBatchBar.tsx
@@ -1,23 +1,26 @@
'use client';
-import { ActionIcon, Button, createStaticStyles, cssVar, DropdownMenu, Flexbox } from '@lobehub/ui';
+import { ActionIcon, Button, DropdownMenu, Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { CircleCheck, FolderInput, Trash2, X } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useAcceptanceProjectMenu } from './useAcceptanceProjectMenuItem';
-const styles = createStaticStyles(({ css }) => ({
- bar: css`
- flex: none;
-
- padding-block: 8px;
- padding-inline: 12px;
- border-block-start: 1px solid ${cssVar.colorBorderSecondary};
-
- background: ${cssVar.colorBgContainer};
- `,
-}));
+const styles = stylex.create({
+ bar: {
+ flex: 'none',
+ paddingBlock: '8px',
+ paddingInline: '12px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorBorderSecondary,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+});
interface AcceptanceBatchBarProps {
/** Selected rows the accept sweep can actually move. */
@@ -63,7 +66,7 @@ const AcceptanceBatchBar = memo<AcceptanceBatchBarProps>(
});
return (
- <Flexbox horizontal align={'center'} className={styles.bar} gap={6}>
+ <Flexbox horizontal align={'center'} className={stylex.props(styles.bar).className} gap={6}>
<Button
disabled={pending || acceptCount === 0}
icon={CircleCheck}
diff --git a/src/features/Acceptance/Workspace/AcceptanceDeleteConfirm.tsx b/src/features/Acceptance/Workspace/AcceptanceDeleteConfirm.tsx
index c1dc1c64070..a25190af8ab 100644
--- a/src/features/Acceptance/Workspace/AcceptanceDeleteConfirm.tsx
+++ b/src/features/Acceptance/Workspace/AcceptanceDeleteConfirm.tsx
@@ -4,14 +4,14 @@ import {
Button,
Checkbox,
createModal,
- createStaticStyles,
- cssVar,
Flexbox,
type ModalInstance,
Text,
toast,
useModalContext,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { t } from 'i18next';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -25,33 +25,24 @@ import { frostedModalStyles } from '../Viewer/Review/modals';
const PREVIEW_BATCH_LIMIT = 20;
-const styles = createStaticStyles(({ css }) => ({
- facts: css`
- display: grid;
- grid-template-columns: auto 1fr;
- gap: 4px 14px;
-
- margin: 0;
- padding-block: 10px;
- padding-inline: 12px;
- border-radius: ${cssVar.borderRadiusLG};
-
- font-size: 13px;
- font-variant-numeric: tabular-nums;
-
- background: ${cssVar.colorFillQuaternary};
-
- dt {
- margin: 0;
- color: ${cssVar.colorTextTertiary};
- }
-
- dd {
- margin: 0;
- color: ${cssVar.colorText};
- }
- `,
-}));
+const styles = stylex.create({
+ facts: {
+ display: 'grid',
+ gridTemplateColumns: 'auto 1fr',
+ rowGap: '4px',
+ columnGap: '14px',
+ margin: 0,
+ paddingBlock: '10px',
+ paddingInline: '12px',
+ borderRadius: cssVar.borderRadiusLG,
+ fontSize: '13px',
+ fontVariantNumeric: 'tabular-nums',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ term: { margin: 0, color: cssVar.colorTextTertiary },
+ detail: { margin: 0, color: cssVar.colorText },
+});
interface DeleteConfirmProps {
description?: string;
@@ -119,20 +110,26 @@ const DeleteConfirmContent = memo<DeleteConfirmProps>(({ description, ids, onDel
: translate('acceptance.workspace.deleteConfirm.purgeOptionPlain')}
</Checkbox>
{purge && preview && (
- <dl className={styles.facts}>
- <dt>{translate('acceptance.workspace.deleteConfirm.rounds')}</dt>
- <dd>
+ <dl {...stylex.props(styles.facts)}>
+ <dt {...stylex.props(styles.term)}>
+ {translate('acceptance.workspace.deleteConfirm.rounds')}
+ </dt>
+ <dd {...stylex.props(styles.detail)}>
{translate('acceptance.workspace.deleteConfirm.roundsValue', { count: preview.rounds })}
</dd>
- <dt>{translate('acceptance.workspace.deleteConfirm.files')}</dt>
- <dd>
+ <dt {...stylex.props(styles.term)}>
+ {translate('acceptance.workspace.deleteConfirm.files')}
+ </dt>
+ <dd {...stylex.props(styles.detail)}>
{translate('acceptance.workspace.deleteConfirm.filesValue', {
count: preview.fileCount,
...preview.files,
})}
</dd>
- <dt>{translate('acceptance.workspace.deleteConfirm.space')}</dt>
- <dd>{formatSize(preview.bytes)}</dd>
+ <dt {...stylex.props(styles.term)}>
+ {translate('acceptance.workspace.deleteConfirm.space')}
+ </dt>
+ <dd {...stylex.props(styles.detail)}>{formatSize(preview.bytes)}</dd>
</dl>
)}
<Flexbox horizontal gap={8} justify={'flex-end'}>
diff --git a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx
index aadeb83f7e4..e4deae9cf1d 100644
--- a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx
+++ b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx
@@ -7,8 +7,6 @@ import {
Button,
Center,
Checkbox,
- createStaticStyles,
- cssVar,
DraggablePanel,
DraggablePanelContainer,
DropdownMenu,
@@ -18,6 +16,8 @@ import {
Text,
toast,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { useDebounce } from 'ahooks';
import isEqual from 'fast-deep-equal';
import {
@@ -45,6 +45,7 @@ import { verifyService } from '@/services/verify';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
import { useVerifyStore } from '@/store/verify';
+import { sx } from '@/styles/sx';
import { useAcceptanceList, useAcceptanceListInfinite } from '../hooks';
import { acceptanceHomePath, useAcceptanceRouteBase } from '../Viewer/routes';
@@ -106,176 +107,146 @@ const EMPTY_FILTER_KEYS = {
completed: 'acceptance.workspace.filters.empty.completed',
} as const satisfies Record<Exclude<AcceptanceListFilter, 'all'>, string>;
-const styles = createStaticStyles(({ css }) => ({
- panel: css`
- height: 100%;
- background: ${cssVar.colorBgLayout};
- `,
- head: css`
- flex: none;
- padding-block: 14px 6px;
- padding-inline: 12px;
- `,
- headWithBrand: css`
- flex: none;
- padding-block: 0 6px;
- padding-inline: 12px;
- `,
- titleRow: css`
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-inline: 4px;
- `,
- titleRowWithBrand: css`
- display: flex;
- align-items: center;
- justify-content: space-between;
-
- min-height: 48px;
- padding-inline: 4px;
- `,
- collapseBtn: css`
- cursor: pointer;
-
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- width: 26px;
- height: 26px;
- border: none;
- border-radius: 4px;
-
- color: ${cssVar.colorTextTertiary};
-
- background: none;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillTertiary};
- }
- `,
- search: css`
- display: flex;
- gap: 7px;
- align-items: center;
-
- height: 32px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgContainer};
-
- svg {
- flex: none;
- color: ${cssVar.colorTextQuaternary};
- }
-
- input {
- width: 100%;
- min-width: 0;
- border: none;
-
- font-size: 13px;
- color: ${cssVar.colorText};
-
- background: none;
- outline: none;
-
- &::placeholder {
- color: ${cssVar.colorTextQuaternary};
- }
- }
- `,
- searchRow: css`
- display: flex;
- gap: 4px;
- align-items: center;
-
- margin-block: 8px 4px;
- margin-inline: 4px;
-
- > label {
- flex: 1;
- min-width: 0;
- }
- `,
- filterButton: css`
- flex: none;
- `,
- selectionRow: css`
- display: flex;
- gap: 6px;
- align-items: center;
-
- margin-block: 2px 4px;
- margin-inline: 4px;
-
- font-size: 12px;
- `,
- searchEmpty: css`
- display: flex;
- flex-direction: column;
- gap: 10px;
- align-items: flex-start;
-
- padding-block: 24px;
- padding-inline: 12px;
- `,
- searchEmptyMsg: css`
- font-size: 12px;
- line-height: 1.6;
- color: ${cssVar.colorTextTertiary};
- word-break: break-word;
- `,
- list: css`
- display: flex;
- flex-direction: column;
- gap: 2px;
-
- padding-block: 6px 16px;
- padding-inline: 8px;
- `,
- groupList: css`
- display: flex;
- flex-direction: column;
- gap: 2px;
- `,
- groupTitle: css`
- display: inline-flex;
- gap: 8px;
- align-items: center;
-
- font-size: 14px;
- color: ${cssVar.colorTextSecondary};
- `,
- emptyState: css`
- height: 100%;
- min-height: 240px;
- padding-block: 24px;
- padding-inline: 16px;
- `,
- retryBtn: css`
- cursor: pointer;
-
- padding-block: 4px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 4px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorBgContainer};
-
- &:hover {
- border-color: ${cssVar.colorTextTertiary};
- color: ${cssVar.colorText};
- }
- `,
-}));
+const styles = stylex.create({
+ panel: {
+ height: '100%',
+ backgroundColor: cssVar.colorBgLayout,
+ backgroundImage: 'none',
+ },
+ head: {
+ flex: 'none',
+ paddingBlockStart: '14px',
+ paddingBlockEnd: '6px',
+ paddingInline: '12px',
+ },
+ headWithBrand: {
+ flex: 'none',
+ paddingBlockStart: 0,
+ paddingBlockEnd: '6px',
+ paddingInline: '12px',
+ },
+ titleRow: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingInline: '4px',
+ },
+ titleRowWithBrand: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ minHeight: '48px',
+ paddingInline: '4px',
+ },
+ collapseBtn: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '26px',
+ height: '26px',
+ borderStyle: 'none',
+ borderRadius: '4px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
+ backgroundImage: 'none',
+ },
+ search: {
+ display: 'flex',
+ gap: '7px',
+ alignItems: 'center',
+ /* The only child label of the search row: it takes the row's free width. */
+ flex: '1',
+ minWidth: '0',
+ height: '32px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ searchIcon: { flex: 'none', color: cssVar.colorTextQuaternary },
+ searchInput: {
+ 'width': '100%',
+ 'minWidth': '0',
+ 'borderStyle': 'none',
+ 'fontSize': '13px',
+ 'color': cssVar.colorText,
+ 'backgroundColor': 'transparent',
+ 'backgroundImage': 'none',
+ 'outline': 'none',
+ '::placeholder': { color: cssVar.colorTextQuaternary },
+ },
+ searchRow: {
+ display: 'flex',
+ gap: '4px',
+ alignItems: 'center',
+ marginBlockStart: '8px',
+ marginBlockEnd: '4px',
+ marginInline: '4px',
+ },
+ filterButton: { flex: 'none' },
+ selectionRow: {
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ marginBlockStart: '2px',
+ marginBlockEnd: '4px',
+ marginInline: '4px',
+ fontSize: '12px',
+ },
+ searchEmpty: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '10px',
+ alignItems: 'flex-start',
+ paddingBlock: '24px',
+ paddingInline: '12px',
+ },
+ searchEmptyMsg: {
+ fontSize: '12px',
+ lineHeight: 1.6,
+ color: cssVar.colorTextTertiary,
+ wordBreak: 'break-word',
+ },
+ list: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '2px',
+ paddingBlockStart: '6px',
+ paddingBlockEnd: '16px',
+ paddingInline: '8px',
+ },
+ groupList: { display: 'flex', flexDirection: 'column', gap: '2px' },
+ groupTitle: {
+ display: 'inline-flex',
+ gap: '8px',
+ alignItems: 'center',
+ fontSize: '14px',
+ color: cssVar.colorTextSecondary,
+ },
+ emptyState: {
+ height: '100%',
+ minHeight: '240px',
+ paddingBlock: '24px',
+ paddingInline: '16px',
+ },
+ retryBtn: {
+ cursor: 'pointer',
+ paddingBlock: '4px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: { 'default': cssVar.colorBorder, ':hover': cssVar.colorTextTertiary },
+ borderRadius: '4px',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+});
interface AcceptanceListPanelProps extends ReportPanelExpand {
headerLeading?: ReactNode;
@@ -705,9 +676,9 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
const body = (
<>
- <div className={headerLeading ? styles.headWithBrand : styles.head}>
+ <div {...stylex.props(headerLeading ? styles.headWithBrand : styles.head)}>
{!hosted && (
- <div className={headerLeading ? styles.titleRowWithBrand : styles.titleRow}>
+ <div {...stylex.props(headerLeading ? styles.titleRowWithBrand : styles.titleRow)}>
<Flexbox
horizontal
align={'center'}
@@ -730,7 +701,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</Flexbox>
<button
aria-label={t('workspace.collapse')}
- className={styles.collapseBtn}
+ {...stylex.props(styles.collapseBtn)}
title={t('workspace.collapse')}
type={'button'}
onClick={() => setExpand(false)}
@@ -739,10 +710,11 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</button>
</div>
)}
- <div className={styles.searchRow}>
- <label className={styles.search}>
- <Icon icon={Search} size={13} />
+ <div {...stylex.props(styles.searchRow)}>
+ <label {...stylex.props(styles.search)}>
+ <Icon className={stylex.props(styles.searchIcon).className} icon={Search} size={13} />
<input
+ {...stylex.props(styles.searchInput)}
placeholder={t('workspace.search')}
type={'search'}
value={query}
@@ -752,7 +724,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
<DropdownMenu items={filterItems} placement={'bottomRight'}>
<ActionIcon
active={filter !== 'all' || facetsNarrowed}
- className={styles.filterButton}
+ className={stylex.props(styles.filterButton).className}
icon={ListFilter}
size={'small'}
title={t('acceptance.workspace.filters.title')}
@@ -761,7 +733,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
<DropdownMenu items={overflowItems} placement={'bottomRight'}>
<ActionIcon
active={selecting}
- className={styles.filterButton}
+ className={stylex.props(styles.filterButton).className}
icon={MoreHorizontal}
size={'small'}
title={t('acceptance.workspace.actions.more')}
@@ -769,7 +741,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</DropdownMenu>
</div>
{selecting && (
- <div className={styles.selectionRow}>
+ <div {...stylex.props(styles.selectionRow)}>
<Checkbox
checked={selectAllState === 'all'}
disabled={selectableItems.length === 0}
@@ -795,13 +767,17 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
{error ? (
// A failed fetch must read as an error with a retry — never as an
// empty "no acceptances" page.
- <Center className={styles.emptyState} gap={12}>
+ <Center className={stylex.props(styles.emptyState).className} gap={12}>
<Empty
description={t('workspace.loadError')}
icon={TriangleAlert}
title={t('workspace.loadErrorTitle')}
/>
- <button className={styles.retryBtn} type={'button'} onClick={() => void mutate()}>
+ <button
+ {...stylex.props(styles.retryBtn)}
+ type={'button'}
+ onClick={() => void mutate()}
+ >
{t('workspace.retry')}
</button>
</Center>
@@ -811,8 +787,8 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
emptyVariant === 'filtered' ? (
// A zero-result FILTER must read as "no match for this query",
// never as the first-run empty state.
- <div className={styles.searchEmpty}>
- <span className={styles.searchEmptyMsg}>
+ <div {...stylex.props(styles.searchEmpty)}>
+ <span {...stylex.props(styles.searchEmptyMsg)}>
{trimmedQuery
? t('acceptance.workspace.filters.noSearchResults', { query: trimmedQuery })
: facetsNarrowed
@@ -822,7 +798,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
: t(EMPTY_FILTER_KEYS[filter])}
</span>
<button
- className={styles.retryBtn}
+ {...stylex.props(styles.retryBtn)}
type={'button'}
onClick={() => {
setQuery('');
@@ -834,7 +810,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</button>
</div>
) : (
- <Center className={styles.emptyState}>
+ <Center className={stylex.props(styles.emptyState).className}>
{/* The dashed circle is the acceptance "awaiting" glyph
(AcceptanceStatusPill) — the domain's own mark, not the
generic inbox. */}
@@ -846,7 +822,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</Center>
)
) : (
- <div className={styles.list} style={selecting ? { userSelect: 'none' } : undefined}>
+ <div {...sx(styles.list, selecting ? { userSelect: 'none' } : undefined)}>
{showGroups ? (
<Accordion
gap={4}
@@ -869,7 +845,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</DropdownMenu>
) : undefined,
title: (
- <span className={styles.groupTitle}>
+ <span {...stylex.props(styles.groupTitle)}>
{/* The folder reads as "project"; a status or age
bucket is not a folder and must not wear one. */}
{groupMode === 'project' && <Icon icon={FolderClosed} size={14} />}
@@ -880,7 +856,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</span>
),
children: (
- <div className={styles.groupList}>
+ <div {...stylex.props(styles.groupList)}>
{group.items.map((item) => (
<AcceptanceRow
active={item.id === acceptanceId}
@@ -949,7 +925,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
return (
<DraggablePanel
- className={styles.panel}
+ className={stylex.props(styles.panel).className}
defaultSize={{ width: panelWidth }}
expand={expand}
maxWidth={PANEL_MAX}
diff --git a/src/features/Acceptance/Workspace/AcceptanceOnboarding.tsx b/src/features/Acceptance/Workspace/AcceptanceOnboarding.tsx
index 2d6cddf9899..5a4f3e5906c 100644
--- a/src/features/Acceptance/Workspace/AcceptanceOnboarding.tsx
+++ b/src/features/Acceptance/Workspace/AcceptanceOnboarding.tsx
@@ -3,8 +3,6 @@
import {
Button,
CopyButton,
- createStaticStyles,
- cssVar,
Flexbox,
Icon,
TabsIndicator,
@@ -12,6 +10,8 @@ import {
TabsRoot,
TabsTab,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ArrowLeft, Bot, ClipboardCheck, Terminal } from 'lucide-react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -22,155 +22,131 @@ import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwar
import { acceptanceHomePath } from '../Viewer/routes';
-const styles = createStaticStyles(({ css }) => ({
- description: css`
- max-width: 520px;
-
- font-size: 14px;
- line-height: 1.6;
- color: ${cssVar.colorTextSecondary};
- text-align: center;
- `,
- container: css`
- overflow: auto;
- flex: 1;
-
- width: 100%;
- min-height: 0;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgContainer};
- `,
- content: css`
- width: 100%;
- max-width: 720px;
- margin-inline: auto;
- padding-block: clamp(32px, 8vh, 96px) 48px;
- padding-inline: 24px;
-
- @media (width <= 680px) {
- padding-block: 8px 16px;
- padding-inline: 16px;
- }
- `,
- icon: css`
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- width: 56px;
- height: 56px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- method: css`
- min-width: 0;
- padding: 24px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
- `,
- methodDescription: css`
- font-size: ${cssVar.fontSize};
- line-height: 1.55;
- color: ${cssVar.colorTextTertiary};
- `,
- methodIcon: css`
- color: ${cssVar.colorTextTertiary};
- `,
- methodTitle: css`
- font-size: ${cssVar.fontSize};
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
- step: css`
- display: grid;
- grid-template-columns: 24px minmax(0, 1fr);
- gap: 12px;
-
- min-width: 0;
- padding: 12px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
- `,
- stepIndex: css`
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- width: 24px;
- height: 24px;
- border-radius: 50%;
-
- font-size: 12px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillSecondary};
- `,
- steps: css`
- display: grid;
- grid-template-columns: minmax(0, 1fr);
- gap: 12px;
-
- @media (width <= 680px) {
- grid-template-columns: 1fr;
- }
- `,
- tab: css`
- flex: 1;
- justify-content: center;
- `,
- tabList: css`
- width: 100%;
- `,
- tabs: css`
- width: 100%;
- `,
- page: css`
- flex: 1;
-
- width: 100%;
- min-width: 0;
- height: 100%;
- min-height: 0;
- padding: 8px;
-
- background: ${cssVar.colorBgLayout};
- `,
- prompt: css`
- flex: 1;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: ${cssVar.fontSize};
- line-height: 1.65;
- color: ${cssVar.colorText};
- overflow-wrap: anywhere;
- `,
- promptBox: css`
- padding: 12px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
- background: ${cssVar.colorFillQuaternary};
- `,
- sectionTitle: css`
- font-size: 14px;
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
- title: css`
- font-size: ${cssVar.fontSizeHeading2};
- font-weight: 600;
- line-height: 1.25;
- color: ${cssVar.colorText};
- text-align: center;
- letter-spacing: -0.02em;
- `,
-}));
+const styles = stylex.create({
+ description: {
+ maxWidth: '520px',
+ fontSize: '14px',
+ lineHeight: 1.6,
+ color: cssVar.colorTextSecondary,
+ textAlign: 'center',
+ },
+ container: {
+ overflow: 'auto',
+ flex: '1',
+ width: '100%',
+ minHeight: '0',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ content: {
+ width: '100%',
+ maxWidth: '720px',
+ marginInline: 'auto',
+ paddingBlockStart: { 'default': 'clamp(32px, 8vh, 96px)', '@media (width <= 680px)': '8px' },
+ paddingBlockEnd: { 'default': '48px', '@media (width <= 680px)': '16px' },
+ paddingInline: { 'default': '24px', '@media (width <= 680px)': '16px' },
+ },
+ icon: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '56px',
+ height: '56px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ method: {
+ minWidth: '0',
+ padding: '24px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ },
+ methodDescription: {
+ fontSize: cssVar.fontSize,
+ lineHeight: 1.55,
+ color: cssVar.colorTextTertiary,
+ },
+ methodTitle: { fontSize: cssVar.fontSize, fontWeight: 600, color: cssVar.colorText },
+ step: {
+ display: 'grid',
+ gridTemplateColumns: '24px minmax(0, 1fr)',
+ gap: '12px',
+ minWidth: '0',
+ padding: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ },
+ stepIndex: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '24px',
+ height: '24px',
+ borderRadius: '50%',
+ fontSize: '12px',
+ fontWeight: 500,
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ steps: {
+ display: 'grid',
+ gridTemplateColumns: { 'default': 'minmax(0, 1fr)', '@media (width <= 680px)': '1fr' },
+ gap: '12px',
+ },
+ tab: { flex: '1', justifyContent: 'center' },
+ tabList: { width: '100%' },
+ tabs: { width: '100%' },
+ page: {
+ flex: '1',
+ width: '100%',
+ minWidth: '0',
+ height: '100%',
+ minHeight: '0',
+ padding: '8px',
+ backgroundColor: cssVar.colorBgLayout,
+ backgroundImage: 'none',
+ },
+ prompt: {
+ flex: '1',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: cssVar.fontSize,
+ lineHeight: 1.65,
+ color: cssVar.colorText,
+ overflowWrap: 'anywhere',
+ },
+ promptBox: {
+ padding: '12px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ sectionTitle: { fontSize: '14px', fontWeight: 600, color: cssVar.colorText },
+ title: {
+ fontSize: cssVar.fontSizeHeading2,
+ fontWeight: 600,
+ lineHeight: 1.25,
+ color: cssVar.colorText,
+ textAlign: 'center',
+ letterSpacing: '-0.02em',
+ },
+});
const AcceptanceOnboarding = () => {
const { t } = useTranslation('verify');
@@ -178,42 +154,44 @@ const AcceptanceOnboarding = () => {
const [mode, setMode] = useState<'agent' | 'manual'>('agent');
return (
- <Flexbox className={styles.page}>
- <Flexbox className={styles.container}>
+ <Flexbox className={stylex.props(styles.page).className}>
+ <Flexbox className={stylex.props(styles.container).className}>
<Flexbox horizontal align={'center'} padding={16}>
<Button icon={ArrowLeft} type={'text'} onClick={() => navigate(acceptanceHomePath())}>
{t('back', { ns: 'common' })}
</Button>
</Flexbox>
- <Flexbox className={styles.content} gap={32}>
+ <Flexbox className={stylex.props(styles.content).className} gap={32}>
<Flexbox align={'center'} gap={16}>
- <span className={styles.icon}>
+ <span {...stylex.props(styles.icon)}>
<Icon icon={ClipboardCheck} size={28} />
</span>
<Flexbox align={'center'} gap={12}>
- <span className={styles.title}>{t('acceptance.workspace.onboarding.title')}</span>
- <span className={styles.description}>
+ <span {...stylex.props(styles.title)}>
+ {t('acceptance.workspace.onboarding.title')}
+ </span>
+ <span {...stylex.props(styles.description)}>
{t('acceptance.workspace.onboarding.description')}
</span>
</Flexbox>
</Flexbox>
<Flexbox gap={12}>
- <span className={styles.sectionTitle}>
+ <span {...stylex.props(styles.sectionTitle)}>
{t('acceptance.workspace.onboarding.installSection')}
</span>
<TabsRoot
- className={styles.tabs}
+ className={stylex.props(styles.tabs).className}
value={mode}
onValueChange={(key) => setMode(key as 'agent' | 'manual')}
>
- <TabsList className={styles.tabList}>
+ <TabsList className={stylex.props(styles.tabList).className}>
<TabsIndicator />
- <TabsTab className={styles.tab} value={'agent'}>
+ <TabsTab className={stylex.props(styles.tab).className} value={'agent'}>
<Icon icon={Bot} size={16} />
{t('acceptance.workspace.onboarding.agent.title')}
</TabsTab>
- <TabsTab className={styles.tab} value={'manual'}>
+ <TabsTab className={stylex.props(styles.tab).className} value={'manual'}>
<Icon icon={Terminal} size={16} />
{t('acceptance.workspace.onboarding.manual.title')}
</TabsTab>
@@ -221,12 +199,17 @@ const AcceptanceOnboarding = () => {
</TabsRoot>
{mode === 'agent' ? (
- <Flexbox className={styles.method} gap={12}>
- <span className={styles.methodDescription}>
+ <Flexbox className={stylex.props(styles.method).className} gap={12}>
+ <span {...stylex.props(styles.methodDescription)}>
{t('acceptance.workspace.onboarding.agent.description')}
</span>
- <Flexbox horizontal align={'flex-start'} className={styles.promptBox} gap={8}>
- <span className={styles.prompt}>
+ <Flexbox
+ horizontal
+ align={'flex-start'}
+ className={stylex.props(styles.promptBox).className}
+ gap={8}
+ >
+ <span {...stylex.props(styles.prompt)}>
{t('acceptance.workspace.onboarding.agent.prompt')}
</span>
<CopyButton
@@ -236,7 +219,7 @@ const AcceptanceOnboarding = () => {
</Flexbox>
</Flexbox>
) : (
- <div className={styles.steps}>
+ <div {...stylex.props(styles.steps)}>
{[
{
command: CLI_INSTALL_COMMAND,
@@ -254,11 +237,11 @@ const AcceptanceOnboarding = () => {
title: t('acceptance.workspace.onboarding.run.title'),
},
].map((step, index) => (
- <div className={styles.step} key={step.title}>
- <span className={styles.stepIndex}>{index + 1}</span>
+ <div {...stylex.props(styles.step)} key={step.title}>
+ <span {...stylex.props(styles.stepIndex)}>{index + 1}</span>
<Flexbox gap={8}>
- <span className={styles.methodTitle}>{step.title}</span>
- <span className={styles.methodDescription}>{step.description}</span>
+ <span {...stylex.props(styles.methodTitle)}>{step.title}</span>
+ <span {...stylex.props(styles.methodDescription)}>{step.description}</span>
<CommandLine command={step.command} />
</Flexbox>
</div>
diff --git a/src/features/Acceptance/Workspace/AcceptanceRow.tsx b/src/features/Acceptance/Workspace/AcceptanceRow.tsx
index 4604f334bed..d28c379ed3a 100644
--- a/src/features/Acceptance/Workspace/AcceptanceRow.tsx
+++ b/src/features/Acceptance/Workspace/AcceptanceRow.tsx
@@ -2,17 +2,9 @@
import type { AcceptanceStatus } from '@lobechat/types';
import type { DropdownItem } from '@lobehub/ui';
-import {
- ActionIcon,
- Center,
- Checkbox,
- createStaticStyles,
- cssVar,
- DropdownMenu,
- Flexbox,
- Icon,
- toast,
-} from '@lobehub/ui';
+import { ActionIcon, Center, Checkbox, DropdownMenu, Flexbox, Icon, toast } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import dayjs from 'dayjs';
import {
BadgeCheck,
@@ -51,31 +43,31 @@ import { openMergeAcceptanceModal } from './MergeAcceptanceModal';
import { useAcceptanceProjectMenuItem } from './useAcceptanceProjectMenuItem';
import { useAcceptanceRowCreator } from './useAcceptanceRowCreator';
-const styles = createStaticStyles(({ css }) => ({
- itemProject: css`
- overflow: hidden;
-
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- itemTime: css`
- flex: none;
- padding-inline-start: 8px;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- spin: css`
- animation: acceptance-spin 1.1s linear infinite;
+const spin = stylex.keyframes({
+ to: { transform: 'rotate(360deg)' },
+});
- @keyframes acceptance-spin {
- to {
- transform: rotate(360deg);
- }
- }
- `,
-}));
+const styles = stylex.create({
+ itemProject: {
+ overflow: 'hidden',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ itemTime: {
+ flex: 'none',
+ paddingInlineStart: '8px',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ },
+ spin: {
+ animationName: spin,
+ animationDuration: '1.1s',
+ animationTimingFunction: 'linear',
+ animationIterationCount: 'infinite',
+ },
+});
type Glyph = 'accepted' | 'awaiting' | 'bad' | 'closed' | 'repairing' | 'running' | 'unsure';
@@ -337,7 +329,7 @@ const AcceptanceRow = memo<{
const statusGlyph = (
<Icon
- className={SPINNING_GLYPHS.has(glyph) ? styles.spin : undefined}
+ className={SPINNING_GLYPHS.has(glyph) ? stylex.props(styles.spin).className : undefined}
icon={meta.icon}
size={16}
style={{ color: meta.color }}
@@ -391,13 +383,13 @@ const AcceptanceRow = memo<{
}
description={
showProject && item.project ? (
- <span className={styles.itemProject}>{item.project.name}</span>
+ <span {...stylex.props(styles.itemProject)}>{item.project.name}</span>
) : undefined
}
extra={
<Flexbox horizontal align={'center'} gap={6}>
{selectable && statusGlyph}
- <span className={styles.itemTime}>
+ <span {...stylex.props(styles.itemTime)}>
{relativeTime(item.updatedAt ?? item.createdAt)}
</span>
</Flexbox>
diff --git a/src/features/Acceptance/Workspace/MergeAcceptanceModal.tsx b/src/features/Acceptance/Workspace/MergeAcceptanceModal.tsx
index c814c73a325..f65a03879bc 100644
--- a/src/features/Acceptance/Workspace/MergeAcceptanceModal.tsx
+++ b/src/features/Acceptance/Workspace/MergeAcceptanceModal.tsx
@@ -3,8 +3,6 @@
import {
Button,
createModal,
- createStaticStyles,
- cssVar,
Empty,
Flexbox,
Icon,
@@ -12,6 +10,8 @@ import {
Text,
useModalContext,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { t } from 'i18next';
import { Search, TriangleAlert } from 'lucide-react';
import { memo, useState } from 'react';
@@ -36,131 +36,108 @@ const SETTLED_STATUSES = new Set(['accepted', 'closed']);
*/
const TARGET_WINDOW = 200;
-const styles = createStaticStyles(({ css }) => ({
- search: css`
- display: flex;
- gap: 7px;
- align-items: center;
-
- height: 32px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgContainer};
-
- svg {
- flex: none;
- color: ${cssVar.colorTextQuaternary};
- }
-
- input {
- width: 100%;
- min-width: 0;
- border: none;
-
- font-size: 13px;
- color: ${cssVar.colorText};
-
- background: none;
- outline: none;
- }
- `,
- list: css`
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: 2px;
-
- min-height: 120px;
- max-height: 320px;
- padding-block: 4px;
- `,
- option: css`
- cursor: pointer;
-
- display: flex;
- flex-direction: column;
- gap: 2px;
- align-items: flex-start;
-
- padding-block: 7px;
- padding-inline: 10px;
- border: 1px solid transparent;
- border-radius: ${cssVar.borderRadius};
-
- text-align: start;
-
- background: none;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- optionActive: css`
- border-color: ${cssVar.colorPrimary};
- background: ${cssVar.colorPrimaryBg};
-
- &:hover {
- background: ${cssVar.colorPrimaryBg};
- }
- `,
- optionDisabled: css`
- cursor: not-allowed;
- opacity: 0.45;
-
- &:hover {
- background: none;
- }
- `,
- optionTitle: css`
- overflow: hidden;
- display: block;
-
- width: 100%;
-
- font-size: 13px;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- optionSub: css`
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- `,
- empty: css`
- padding-block: 28px;
- font-size: 12px;
- color: ${cssVar.colorTextTertiary};
- text-align: center;
- `,
- errorState: css`
- display: flex;
- flex-direction: column;
- gap: 10px;
- align-items: center;
-
- padding-block: 20px;
- `,
- retryBtn: css`
- cursor: pointer;
-
- padding-block: 4px;
- padding-inline: 10px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 4px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorBgContainer};
-
- &:hover {
- border-color: ${cssVar.colorTextTertiary};
- color: ${cssVar.colorText};
- }
- `,
-}));
+const styles = stylex.create({
+ search: {
+ display: 'flex',
+ gap: '7px',
+ alignItems: 'center',
+ height: '32px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ searchIcon: { flex: 'none', color: cssVar.colorTextQuaternary },
+ searchInput: {
+ width: '100%',
+ minWidth: '0',
+ borderStyle: 'none',
+ fontSize: '13px',
+ color: cssVar.colorText,
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ outline: 'none',
+ },
+ list: {
+ overflowY: 'auto',
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '2px',
+ minHeight: '120px',
+ maxHeight: '320px',
+ paddingBlock: '4px',
+ },
+ option: {
+ cursor: 'pointer',
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '2px',
+ alignItems: 'flex-start',
+ paddingBlock: '7px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'transparent',
+ borderRadius: cssVar.borderRadius,
+ textAlign: 'start',
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
+ backgroundImage: 'none',
+ },
+ optionActive: {
+ borderColor: cssVar.colorPrimary,
+ backgroundColor: { 'default': cssVar.colorPrimaryBg, ':hover': cssVar.colorPrimaryBg },
+ },
+ optionDisabled: {
+ cursor: 'not-allowed',
+ opacity: 0.45,
+ backgroundColor: { 'default': 'transparent', ':hover': 'transparent' },
+ },
+ /* Disabled wins on hover, but an active row keeps its tint at rest. */
+ optionActiveDisabled: {
+ cursor: 'not-allowed',
+ opacity: 0.45,
+ backgroundColor: { 'default': cssVar.colorPrimaryBg, ':hover': 'transparent' },
+ },
+ optionTitle: {
+ overflow: 'hidden',
+ display: 'block',
+ width: '100%',
+ fontSize: '13px',
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ optionSub: { fontSize: '12px', color: cssVar.colorTextTertiary },
+ empty: {
+ paddingBlock: '28px',
+ fontSize: '12px',
+ color: cssVar.colorTextTertiary,
+ textAlign: 'center',
+ },
+ errorState: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '10px',
+ alignItems: 'center',
+ paddingBlock: '20px',
+ },
+ retryBtn: {
+ cursor: 'pointer',
+ paddingBlock: '4px',
+ paddingInline: '10px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: { 'default': cssVar.colorBorder, ':hover': cssVar.colorTextTertiary },
+ borderRadius: '4px',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+});
const titleOf = (item: AcceptanceListItem) => item.subject.title || item.subjectId;
@@ -212,9 +189,10 @@ const MergeContent = memo<MergeContentProps>(({ onConfirm, source }) => {
})}
</Text>
- <label className={styles.search}>
- <Icon icon={Search} size={13} />
+ <label {...stylex.props(styles.search)}>
+ <Icon className={stylex.props(styles.searchIcon).className} icon={Search} size={13} />
<input
+ {...stylex.props(styles.searchInput)}
autoFocus
placeholder={translate('acceptance.workspace.merge.searchPlaceholder')}
type={'search'}
@@ -226,20 +204,20 @@ const MergeContent = memo<MergeContentProps>(({ onConfirm, source }) => {
{error ? (
// A failed list read must not read as "there is nothing to merge into":
// the two states lead to opposite conclusions about the delivery.
- <div className={styles.errorState}>
+ <div {...stylex.props(styles.errorState)}>
<Empty
description={translate('workspace.loadError')}
icon={TriangleAlert}
title={translate('workspace.loadErrorTitle')}
/>
- <button className={styles.retryBtn} type={'button'} onClick={() => void mutate()}>
+ <button {...stylex.props(styles.retryBtn)} type={'button'} onClick={() => void mutate()}>
{translate('workspace.retry')}
</button>
</div>
) : isLoading ? (
<SkeletonList rows={4} />
) : candidates.length === 0 ? (
- <div className={styles.empty}>
+ <div {...stylex.props(styles.empty)}>
{translate(
others.length === 0
? 'acceptance.workspace.merge.noCandidates'
@@ -248,7 +226,7 @@ const MergeContent = memo<MergeContentProps>(({ onConfirm, source }) => {
)}
</div>
) : (
- <div className={styles.list}>
+ <div {...stylex.props(styles.list)}>
{candidates.map((item) => {
const settled = SETTLED_STATUSES.has(item.status);
return (
@@ -256,17 +234,16 @@ const MergeContent = memo<MergeContentProps>(({ onConfirm, source }) => {
disabled={settled}
key={item.id}
type={'button'}
- className={[
+ {...stylex.props(
styles.option,
- item.id === targetId ? styles.optionActive : '',
- settled ? styles.optionDisabled : '',
- ]
- .filter(Boolean)
- .join(' ')}
+ item.id === targetId && styles.optionActive,
+ settled &&
+ (item.id === targetId ? styles.optionActiveDisabled : styles.optionDisabled),
+ )}
onClick={() => setTargetId(item.id)}
>
- <span className={styles.optionTitle}>{titleOf(item)}</span>
- <span className={styles.optionSub}>
+ <span {...stylex.props(styles.optionTitle)}>{titleOf(item)}</span>
+ <span {...stylex.props(styles.optionSub)}>
{item.checkCount == null
? translate(`acceptance.status.${item.status}` as any)
: translate('acceptance.workspace.checkCount', { count: item.checkCount })}
diff --git a/src/features/Acceptance/Workspace/index.tsx b/src/features/Acceptance/Workspace/index.tsx
index 2ff69292d8e..084e7297c61 100644
--- a/src/features/Acceptance/Workspace/index.tsx
+++ b/src/features/Acceptance/Workspace/index.tsx
@@ -1,6 +1,8 @@
'use client';
-import { ActionIcon, createStaticStyles, cssVar, Drawer, Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Drawer, Flexbox, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { Menu, PanelLeftOpen, Pin } from 'lucide-react';
import { memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -20,44 +22,35 @@ import { useAcceptanceProjectActionItems } from './AcceptanceProjectActions';
import AcceptanceScopeSwitcher from './AcceptanceScopeSwitcher';
import { useReportPanelExpand } from './useReportPanelExpand';
-const styles = createStaticStyles(({ css }) => ({
- expandBtn: css`
- cursor: pointer;
-
- position: absolute;
- z-index: 20;
- inset-block-start: 12px;
- inset-inline-start: 12px;
-
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- width: 28px;
- height: 28px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 6px;
-
- color: ${cssVar.colorTextTertiary};
-
- background: ${cssVar.colorBgContainer};
-
- &:hover {
- border-color: ${cssVar.colorBorder};
- color: ${cssVar.colorText};
- }
- `,
- main: css`
- position: relative;
-
- flex: 1;
-
- min-width: 0;
- height: 100%;
-
- background: ${cssVar.colorBgContainer};
- `,
-}));
+const styles = stylex.create({
+ expandBtn: {
+ cursor: 'pointer',
+ position: 'absolute',
+ zIndex: 20,
+ insetBlockStart: '12px',
+ insetInlineStart: '12px',
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '28px',
+ height: '28px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: { 'default': cssVar.colorBorderSecondary, ':hover': cssVar.colorBorder },
+ borderRadius: '6px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ main: {
+ position: 'relative',
+ flex: '1',
+ minWidth: '0',
+ height: '100%',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+});
interface AcceptanceOnboardingState {
data?: unknown[];
@@ -181,11 +174,11 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {
projectId={projectId}
/>
)}
- <div className={styles.main}>
+ <div {...stylex.props(styles.main)}>
{showList && !panel.expand && (
<button
aria-label={t('workspace.expand')}
- className={styles.expandBtn}
+ {...stylex.props(styles.expandBtn)}
title={t('workspace.expand')}
type={'button'}
onClick={() => panel.setExpand(true)}
@@ -217,7 +210,7 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {
</Drawer>
)}
<Flexbox horizontal flex={1} style={{ minHeight: 0 }} width={'100%'}>
- <div className={styles.main}>
+ <div {...stylex.props(styles.main)}>
<Outlet />
</div>
</Flexbox>
diff --git a/src/features/AttachmentInput/AttachmentMenu.tsx b/src/features/AttachmentInput/AttachmentMenu.tsx
index 166eec1169f..981e725a567 100644
--- a/src/features/AttachmentInput/AttachmentMenu.tsx
+++ b/src/features/AttachmentInput/AttachmentMenu.tsx
@@ -1,7 +1,7 @@
'use client';
import { ActionIcon, css, cx, Icon, Upload } from '@lobehub/ui';
-import { ChevronRight, FileUp, LibraryBig, PlusIcon, TypeIcon } from 'lucide-react';
+import { FileUp, LibraryBig, PlusIcon, TypeIcon } from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -11,6 +11,7 @@ import { openLibraryFilePicker } from '@/features/LibraryModal';
import ActionDropdown, {
type ActionDropdownMenuItems,
} from '../ChatInput/ActionBar/components/ActionDropdown';
+import SubmenuChevron from '../ChatInput/ActionBar/components/SubmenuChevron';
const hotArea = css`
&::before {
@@ -66,7 +67,7 @@ const AttachmentMenu = memo<AttachmentMenuProps>(
},
},
],
- extra: <Icon className={'lobe-submenu-chevron'} icon={ChevronRight} size={16} />,
+ extra: <SubmenuChevron />,
icon: LibraryBig,
key: 'attachments',
label: t('plus.addAttachments', { ns: 'chat' }),
diff --git a/src/features/ChatInput/ActionBar/AgentMode/index.tsx b/src/features/ChatInput/ActionBar/AgentMode/index.tsx
index a3fc3e4d44f..27debc25156 100644
--- a/src/features/ChatInput/ActionBar/AgentMode/index.tsx
+++ b/src/features/ChatInput/ActionBar/AgentMode/index.tsx
@@ -1,4 +1,6 @@
-import { createStaticStyles, cssVar, cx, Flexbox, Icon, Popover, Tooltip } from '@lobehub/ui';
+import { Flexbox, Icon, Popover, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
ChevronDownIcon,
FolderIcon,
@@ -19,111 +21,89 @@ import { useEffectiveAgentMode } from '@/features/ChatInput/hooks/useEffectiveAg
import { useToggleAgentMode } from '@/features/ChatInput/hooks/useToggleAgentMode';
import { usePermission } from '@/hooks/usePermission';
-const styles = createStaticStyles(({ css }) => ({
- activeOption: css`
- background: ${cssVar.colorFillSecondary};
- `,
- agentTooltip: css`
- display: flex;
- flex-direction: column;
- gap: 4px;
- min-width: 160px;
- `,
- agentTooltipCap: css`
- display: flex;
- gap: 6px;
- align-items: center;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- agentTooltipTitle: css`
- margin-block-end: 2px;
- font-size: 12px;
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
- button: css`
- cursor: pointer;
-
- display: flex;
- gap: 6px;
- align-items: center;
-
- height: 28px;
- padding-inline: 8px;
- border-radius: 999px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillTertiary};
-
- transition: all 0.2s;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
- }
- `,
- buttonDisabled: css`
- cursor: not-allowed;
- opacity: 0.5;
-
- &:hover {
- color: ${cssVar.colorTextSecondary};
- background: ${cssVar.colorFillTertiary};
- }
- `,
- option: css`
- cursor: pointer;
-
- width: 100%;
- padding-block: 10px;
- padding-inline: 8px;
- border-radius: ${cssVar.borderRadius};
-
- transition: background-color 0.2s;
-
- &:hover {
- background: ${cssVar.colorFillSecondary};
- }
- `,
- optionDisabled: css`
- cursor: not-allowed;
- opacity: 0.55;
-
- &:hover {
- background: transparent;
- }
- `,
- optionDesc: css`
- font-size: 12px;
- line-height: 1.4;
- color: ${cssVar.colorTextDescription};
- `,
- optionIcon: css`
- flex-shrink: 0;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
- background: ${cssVar.colorBgElevated};
- `,
- optionTitle: css`
- font-size: 14px;
- font-weight: 500;
- line-height: 1.4;
- color: ${cssVar.colorText};
- `,
- popoverPopup: css`
- /* The popup pads its option rows by 4px, so its corner must be one step larger
- than the rows' radius (borderRadius 8 → borderRadiusLG 12 = 8 + 4) to wrap them
- concentrically instead of looking tighter than them. &&& outranks the base
- popup style's border-radius. */
- &&& {
- border-radius: ${cssVar.borderRadiusLG};
- }
- `,
-}));
+const styles = stylex.create({
+ activeOption: { backgroundColor: cssVar.colorFillSecondary, backgroundImage: 'none' },
+ // Keeps the selected row's resting fill while cancelling the hover highlight.
+ activeOptionDisabled: {
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': 'transparent' },
+ backgroundImage: 'none',
+ },
+ agentTooltip: { display: 'flex', flexDirection: 'column', gap: '4px', minWidth: '160px' },
+ agentTooltipCap: {
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ },
+ agentTooltipTitle: {
+ marginBlockEnd: '2px',
+ fontSize: '12px',
+ fontWeight: 600,
+ color: cssVar.colorText,
+ },
+ button: {
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ height: '28px',
+ paddingInline: '8px',
+ borderRadius: '999px',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': cssVar.colorFillTertiary, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: 'none',
+ transition: 'all 0.2s',
+ },
+ buttonDisabled: {
+ cursor: 'not-allowed',
+ opacity: 0.5,
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorTextSecondary },
+ backgroundColor: { 'default': cssVar.colorFillTertiary, ':hover': cssVar.colorFillTertiary },
+ },
+ option: {
+ cursor: 'pointer',
+ width: '100%',
+ paddingBlock: '10px',
+ paddingInline: '8px',
+ borderRadius: cssVar.borderRadius,
+ transition: 'background-color 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ optionDisabled: {
+ cursor: 'not-allowed',
+ opacity: 0.55,
+ backgroundColor: { 'default': null, ':hover': 'transparent' },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ optionDesc: {
+ fontSize: '12px',
+ lineHeight: 1.4,
+ color: cssVar.colorTextDescription,
+ },
+ optionIcon: {
+ flexShrink: 0,
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ },
+ optionTitle: {
+ fontSize: '14px',
+ fontWeight: 500,
+ lineHeight: 1.4,
+ color: cssVar.colorText,
+ },
+ // The popup pads its option rows by 4px, so its corner must be one step larger
+ // than the rows' radius (borderRadius 8 → borderRadiusLG 12 = 8 + 4) to wrap them
+ // concentrically instead of looking tighter than them. StyleX is unlayered, so it
+ // outranks the base popup style's border-radius without the `&&&` hack.
+ popoverPopup: { borderRadius: cssVar.borderRadiusLG },
+});
const AGENT_CAPS = [
{ icon: WrenchIcon, key: 'tools' },
@@ -170,10 +150,10 @@ const AgentMode = memo(() => {
);
const agentTooltip = (
- <div className={styles.agentTooltip}>
- <div className={styles.agentTooltipTitle}>{t('chatMode.agent')}</div>
+ <div {...stylex.props(styles.agentTooltip)}>
+ <div {...stylex.props(styles.agentTooltipTitle)}>{t('chatMode.agent')}</div>
{AGENT_CAPS.map(({ key, icon }) => (
- <div className={styles.agentTooltipCap} key={key}>
+ <div {...stylex.props(styles.agentTooltipCap)} key={key}>
<Icon icon={icon} size={12} />
{t(`chatMode.agentCap.${key}`)}
</div>
@@ -195,16 +175,19 @@ const AgentMode = memo(() => {
horizontal
align="center"
gap={12}
- className={cx(
- styles.option,
- currentMode === 'agent' && styles.activeOption,
- !canSelectAgentMode && styles.optionDisabled,
- )}
+ className={
+ stylex.props(
+ styles.option,
+ currentMode === 'agent' && styles.activeOption,
+ !canSelectAgentMode && styles.optionDisabled,
+ currentMode === 'agent' && !canSelectAgentMode && styles.activeOptionDisabled,
+ ).className
+ }
onClick={() => handleSelect('agent')}
>
<Flexbox
align="center"
- className={styles.optionIcon}
+ className={stylex.props(styles.optionIcon).className}
height={32}
justify="center"
width={32}
@@ -212,21 +195,23 @@ const AgentMode = memo(() => {
<Icon icon={InfinityIcon} size={16} />
</Flexbox>
<Flexbox flex={1}>
- <div className={styles.optionTitle}>{t('chatMode.agent')}</div>
- <div className={styles.optionDesc}>{agentDesc}</div>
+ <div {...stylex.props(styles.optionTitle)}>{t('chatMode.agent')}</div>
+ <div {...stylex.props(styles.optionDesc)}>{agentDesc}</div>
</Flexbox>
</Flexbox>
<Flexbox
horizontal
align="center"
- className={cx(styles.option, currentMode === 'chat' && styles.activeOption)}
gap={12}
+ className={
+ stylex.props(styles.option, currentMode === 'chat' && styles.activeOption).className
+ }
onClick={() => handleSelect('chat')}
>
<Flexbox
align="center"
- className={styles.optionIcon}
+ className={stylex.props(styles.optionIcon).className}
height={32}
justify="center"
width={32}
@@ -234,15 +219,15 @@ const AgentMode = memo(() => {
<Icon icon={MessageCircleIcon} size={16} />
</Flexbox>
<Flexbox flex={1}>
- <div className={styles.optionTitle}>{t('chatMode.chat')}</div>
- <div className={styles.optionDesc}>{t('chatMode.chatDesc')}</div>
+ <div {...stylex.props(styles.optionTitle)}>{t('chatMode.chat')}</div>
+ <div {...stylex.props(styles.optionDesc)}>{t('chatMode.chatDesc')}</div>
</Flexbox>
</Flexbox>
</Flexbox>
);
const button = (
- <div className={cx(styles.button, disabled && styles.buttonDisabled)}>
+ <div {...stylex.props(styles.button, disabled && styles.buttonDisabled)}>
<Icon icon={CurrentIcon} size={14} />
<span>{t(`chatMode.${currentMode}`)}</span>
<Icon icon={ChevronDownIcon} size={12} />
@@ -262,7 +247,7 @@ const AgentMode = memo(() => {
return (
<Popover
- className={styles.popoverPopup}
+ className={stylex.props(styles.popoverPopup).className}
content={popoverContent}
open={!disabled && open}
placement="bottomLeft"
diff --git a/src/features/ChatInput/ActionBar/Knowledge/useControls.tsx b/src/features/ChatInput/ActionBar/Knowledge/useControls.tsx
index f5bd607ba9c..7069f65607c 100644
--- a/src/features/ChatInput/ActionBar/Knowledge/useControls.tsx
+++ b/src/features/ChatInput/ActionBar/Knowledge/useControls.tsx
@@ -1,5 +1,7 @@
import { type ItemType } from '@lobehub/ui';
-import { createStaticStyles, cssVar, cx, Icon } from '@lobehub/ui';
+import { Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { LibraryBig } from 'lucide-react';
import type { ReactNode } from 'react';
@@ -18,44 +20,32 @@ import CheckboxItem from '../components/CheckboxWithLoading';
// growing past it.
const labelMaxWidth = 'min(210px, 45vw)';
-const styles = createStaticStyles(({ css }) => ({
- viewMore: css`
- cursor: pointer;
-
- display: flex;
- gap: 12px;
- align-items: center;
-
- /* width 320 + margin-inline -12 anchors the submenu to 320px (matching the skill
- submenu) and lets the row span full width; padding-inline 12 lines its icon/text
- up with the menu items above. */
- width: 320px;
- min-height: 32px;
-
- /* The footer wrapper adds padding-block: 8px top & bottom; the top keeps it separated
- from the list, but the bottom leaves a dead gap against the popup edge — cancel it. */
- margin-block-end: -8px;
- margin-inline: -12px;
- padding-inline: 12px;
- border: 0;
- border-radius: 6px;
-
- font-size: 14px;
- color: ${cssVar.colorText};
-
- background: transparent;
-
- transition: background 150ms ${cssVar.motionEaseOut};
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- viewMoreLabel: css`
- flex: 1;
- text-align: start;
- `,
-}));
+const styles = stylex.create({
+ viewMore: {
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '12px',
+ alignItems: 'center',
+ // width 320 + margin-inline -12 anchors the submenu to 320px (matching the skill
+ // submenu) and lets the row span full width; padding-inline 12 lines its icon/text
+ // up with the menu items above.
+ width: '320px',
+ minHeight: '32px',
+ // The footer wrapper adds padding-block: 8px top & bottom; the top keeps it separated
+ // from the list, but the bottom leaves a dead gap against the popup edge — cancel it.
+ marginBlockEnd: '-8px',
+ marginInline: '-12px',
+ paddingInline: '12px',
+ borderStyle: 'none',
+ borderRadius: '6px',
+ fontSize: '14px',
+ color: cssVar.colorText,
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: `background 150ms ${cssVar.motionEaseOut}`,
+ },
+ viewMoreLabel: { flex: '1', textAlign: 'start' },
+});
export interface KnowledgeControls {
enabledCount: number;
@@ -131,7 +121,7 @@ export const useControls = ({
// files or libraries" with no way to attach the first one.
const footer = (
<button
- className={cx(styles.viewMore)}
+ {...stylex.props(styles.viewMore)}
type="button"
onClick={(event) => {
event.stopPropagation();
@@ -139,7 +129,7 @@ export const useControls = ({
}}
>
<Icon color={cssVar.colorTextSecondary} icon={LibraryBig} size={14} />
- <span className={cx(styles.viewMoreLabel)}>
+ <span {...stylex.props(styles.viewMoreLabel)}>
{relatedGroups.length > 0 ? t('knowledgeBase.viewMore') : t('knowledgeBase.related.browse')}
</span>
</button>
diff --git a/src/features/ChatInput/ActionBar/Memory/Controls.tsx b/src/features/ChatInput/ActionBar/Memory/Controls.tsx
index a38c988e8ea..20e8db1e0a5 100644
--- a/src/features/ChatInput/ActionBar/Memory/Controls.tsx
+++ b/src/features/ChatInput/ActionBar/Memory/Controls.tsx
@@ -1,6 +1,8 @@
import { type UserMemoryEffort } from '@lobechat/types';
-import { Center, createStaticStyles, cssVar, cx, Divider, Flexbox, Icon } from '@lobehub/ui';
+import { Center, Divider, Flexbox, Icon } from '@lobehub/ui';
import { BrainOffIcon } from '@lobehub/ui/icons';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { type LucideIcon } from 'lucide-react';
import { Brain } from 'lucide-react';
import { memo } from 'react';
@@ -17,39 +19,29 @@ import { useMemoryEnabled } from './useMemoryEnabled';
const MEMORY_EFFORT_LEVELS: readonly UserMemoryEffort[] = ['low', 'medium', 'high'];
-const styles = createStaticStyles(({ css }) => ({
- active: css`
- background: ${cssVar.colorFillTertiary};
- `,
- description: css`
- font-size: 12px;
- color: ${cssVar.colorTextDescription};
- `,
- icon: css`
- border: 1px solid ${cssVar.colorFillTertiary};
- border-radius: ${cssVar.borderRadius};
- background: ${cssVar.colorBgElevated};
- `,
- option: css`
- cursor: pointer;
-
- width: 100%;
- padding-block: 8px;
- padding-inline: 8px;
- border-radius: ${cssVar.borderRadius};
-
- transition: background-color 0.2s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- title: css`
- font-size: 14px;
- font-weight: 500;
- color: ${cssVar.colorText};
- `,
-}));
+const styles = stylex.create({
+ active: { backgroundColor: cssVar.colorFillTertiary, backgroundImage: 'none' },
+ description: { fontSize: '12px', color: cssVar.colorTextDescription },
+ icon: {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillTertiary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ },
+ option: {
+ cursor: 'pointer',
+ width: '100%',
+ paddingBlock: '8px',
+ paddingInline: '8px',
+ borderRadius: cssVar.borderRadius,
+ transition: 'background-color 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ title: { fontSize: '14px', fontWeight: 500, color: cssVar.colorText },
+});
interface ToggleOption {
description: string;
@@ -70,7 +62,7 @@ const ToggleItem = memo<ToggleOption>(({ value, description, icon, label }) => {
<Flexbox
horizontal
align={'flex-start'}
- className={cx(styles.option, isActive && styles.active)}
+ className={stylex.props(styles.option, isActive && styles.active).className}
gap={12}
style={{
cursor: canCreate ? undefined : 'not-allowed',
@@ -81,12 +73,12 @@ const ToggleItem = memo<ToggleOption>(({ value, description, icon, label }) => {
await updateAgentChatConfig({ memory: { enabled: value === 'on' } });
}}
>
- <Center className={styles.icon} flex={'none'} height={32} width={32}>
+ <Center className={stylex.props(styles.icon).className} flex={'none'} height={32} width={32}>
<Icon icon={icon} />
</Center>
<Flexbox flex={1}>
- <div className={styles.title}>{label}</div>
- <div className={styles.description}>{description}</div>
+ <div {...stylex.props(styles.title)}>{label}</div>
+ <div {...stylex.props(styles.description)}>{description}</div>
</Flexbox>
</Flexbox>
);
@@ -114,8 +106,8 @@ export const MemoryEffortControl = memo(() => {
<Divider style={{ margin: 0 }} />
<Flexbox horizontal align={'center'} gap={16} padding={8}>
<Flexbox flex={1} gap={4} style={{ minWidth: 100 }}>
- <div className={styles.title}>{t('memory.effort.title')}</div>
- <div className={styles.description}>{t('memory.effort.desc')}</div>
+ <div {...stylex.props(styles.title)}>{t('memory.effort.title')}</div>
+ <div {...stylex.props(styles.description)}>{t('memory.effort.desc')}</div>
</Flexbox>
<Flexbox
flex={1}
diff --git a/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx b/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx
index 1bd37e3ff14..253d561ad8c 100644
--- a/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx
+++ b/src/features/ChatInput/ActionBar/Model/SelectorMenu.tsx
@@ -1,6 +1,4 @@
import {
- createStaticStyles,
- cssVar,
DropdownMenuItem,
DropdownMenuItemContent,
DropdownMenuItemExtra,
@@ -15,6 +13,8 @@ import {
DropdownMenuTrigger,
renderDropdownMenuItems,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { ReactNode } from 'react';
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -28,30 +28,22 @@ import { buildSelectorSubmenu } from '../../components/buildSelectorSubmenu';
import type { ReasoningEffortControl } from '../../hooks/useReasoningEffortControl';
import { type DropdownPlacement } from '../context';
-const styles = createStaticStyles(({ css }) => ({
- meta: css`
- overflow: hidden;
- display: flex;
- gap: 6px;
- align-items: center;
-
- max-width: 150px;
-
- /* The packaged extra slot defaults to the code font (it is styled for
- keyboard hints); a model name belongs in the UI font. */
- font-family: ${cssVar.fontFamily};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- name: css`
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- popup: css`
- width: 240px;
- `,
-}));
+const styles = stylex.create({
+ meta: {
+ overflow: 'hidden',
+ display: 'flex',
+ gap: '6px',
+ alignItems: 'center',
+ maxWidth: '150px',
+ // The packaged extra slot defaults to the code font (it is styled for
+ // keyboard hints); a model name belongs in the UI font.
+ fontFamily: cssVar.fontFamily,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ name: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
+ popup: { width: '240px' },
+});
/**
* The effort rows go through `renderDropdownMenuItems`, which draws base-ui's own
@@ -159,9 +151,9 @@ const SelectorMenu = memo<SelectorMenuProps>(
}, [effortKey, effortLevels, effortValue, hasReasoningMode, modeLevels, modeValue, select, t]);
const modelMeta = (
- <DropdownMenuItemExtra className={styles.meta}>
+ <DropdownMenuItemExtra className={stylex.props(styles.meta).className}>
<ModelIcon model={model} size={16} />
- <span className={styles.name}>{displayName}</span>
+ <span {...stylex.props(styles.name)}>{displayName}</span>
</DropdownMenuItemExtra>
);
@@ -170,7 +162,7 @@ const SelectorMenu = memo<SelectorMenuProps>(
<DropdownMenuTrigger openOnHover={openOnHover}>{children}</DropdownMenuTrigger>
<DropdownMenuPortal>
<DropdownMenuPositioner hoverTrigger={openOnHover} placement={placement} sideOffset={8}>
- <DropdownMenuPopup className={styles.popup}>
+ <DropdownMenuPopup className={stylex.props(styles.popup).className}>
{canSelectModel ? (
<DropdownMenuSubmenuRoot>
<DropdownMenuSubmenuTrigger label={t('modelSelector.model')}>
diff --git a/src/features/ChatInput/ActionBar/Params/Controls.tsx b/src/features/ChatInput/ActionBar/Params/Controls.tsx
index f6177728600..bf6bf943a9c 100644
--- a/src/features/ChatInput/ActionBar/Params/Controls.tsx
+++ b/src/features/ChatInput/ActionBar/Params/Controls.tsx
@@ -5,9 +5,6 @@ import {
} from '@lobechat/const';
import { resolveEffectiveReasoningChatConfig } from '@lobechat/model-runtime/utils/modelExtendParams';
import {
- createStaticStyles,
- cssVar,
- cx,
Flexbox,
Icon,
Segmented,
@@ -18,6 +15,8 @@ import {
TextArea,
} from '@lobehub/ui';
import { useForm } from '@lobehub/ui/form';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { debounce } from 'es-toolkit/compat';
import isEqual from 'fast-deep-equal';
import { ChevronDown, ChevronUp } from 'lucide-react';
@@ -70,199 +69,152 @@ interface SliderConfig {
unlimitedInput?: boolean;
}
-const styles = createStaticStyles(({ css }) => ({
- advancedContent: css`
- display: flex;
- flex-direction: column;
-
- .control-row {
- border-block-start: 1px solid ${cssVar.colorSplit};
- }
-
- .control-row:first-child {
- border-block-start: none;
- }
- `,
- sectionHeader: css`
- cursor: pointer;
-
- width: calc(100% + 16px);
- margin-inline: -8px;
- padding-block: 12px;
- padding-inline: 8px;
- border: none;
- border-radius: 10px;
-
- font: inherit;
- font-size: 12px;
- font-weight: 500;
- color: ${cssVar.colorTextSecondary};
- text-align: start;
-
- background: transparent;
-
- transition: color 0.2s ease;
-
- &:hover {
- color: ${cssVar.colorText};
- }
-
- &:hover .section-header-label {
- color: ${cssVar.colorText};
- }
-
- &:focus-visible {
- outline: 1px solid ${cssVar.colorBorder};
- outline-offset: 2px;
- }
- `,
- body: css`
- overflow-y: auto;
- overscroll-behavior: contain;
- display: flex;
- flex: 1 1 auto;
- flex-direction: column;
-
- min-height: 0;
- padding-block-end: 4px;
- padding-inline: 12px;
- `,
- commonSection: css`
- display: flex;
- flex-direction: column;
- padding-block: 0;
- `,
- divider: css`
- height: 1px;
- background: ${cssVar.colorSplit};
- `,
- hint: css`
- font-size: 12px;
- line-height: 18px;
- color: ${cssVar.colorTextTertiary};
- `,
- form: css`
- margin: 0;
- `,
- formSidebar: css`
- display: flex;
- flex: 1;
-
- width: 100%;
- height: 100%;
- min-height: 0;
- `,
- header: css`
- display: flex;
- gap: 12px;
- align-items: center;
- justify-content: space-between;
-
- padding-block: 16px;
- padding-inline: 12px;
- border-block-end: 1px solid ${cssVar.colorSplit};
-
- font-size: 14px;
- font-weight: 600;
- line-height: 1.4;
- color: ${cssVar.colorText};
- `,
- headerLoading: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- width: 18px;
- height: 18px;
-
- color: ${cssVar.colorTextTertiary};
- `,
- headerTitle: css`
- overflow: hidden;
- min-width: 0;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- label: css`
- user-select: none;
-
- min-width: 0;
-
- font-size: 13px;
- font-weight: 500;
- line-height: 20px;
- color: ${cssVar.colorTextSecondary};
- `,
- labelMain: css`
- flex-wrap: wrap;
- min-width: 0;
- `,
- muted: css`
- .control-label {
- color: ${cssVar.colorTextTertiary};
- }
- `,
- modelConfigSection: css`
- padding-block: 12px;
- `,
- panel: css`
- overflow: hidden;
- display: flex;
- flex-direction: column;
-
- width: min(384px, 100%);
- max-height: 50vh;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 16px;
-
- background: ${cssVar.colorBgElevated};
- box-shadow: ${cssVar.boxShadowSecondary};
- `,
- sidebarPanel: css`
- width: 100%;
- height: 100%;
- max-height: none;
- border: none;
- border-radius: 0;
-
- background: transparent;
- box-shadow: none;
- `,
- rowControl: css`
- width: 100%;
- `,
- rowRoot: css`
- padding-block: 12px;
- `,
- tag: css`
- user-select: none;
-
- align-self: flex-start;
-
- width: fit-content;
- padding-block: 2px;
- padding-inline: 7px;
- border-radius: 999px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 10px;
- font-weight: 500;
- line-height: 1.2;
- color: ${cssVar.colorTextQuaternary};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- tooltipContent: css`
- display: flex;
- flex-direction: column;
- gap: 6px;
- max-width: 240px;
- `,
- slider: css`
- width: 100%;
- `,
-}));
+const styles = stylex.create({
+ advancedContent: { display: 'flex', flexDirection: 'column' },
+ sectionHeader: {
+ cursor: 'pointer',
+ width: 'calc(100% + 16px)',
+ marginInline: '-8px',
+ paddingBlock: '12px',
+ paddingInline: '8px',
+ borderStyle: 'none',
+ borderRadius: '10px',
+ fontFamily: 'inherit',
+ fontStyle: 'inherit',
+ fontVariant: 'inherit',
+ fontStretch: 'inherit',
+ fontFeatureSettings: 'inherit',
+ fontVariationSettings: 'inherit',
+ fontKerning: 'inherit',
+ fontOpticalSizing: 'inherit',
+ fontSizeAdjust: 'inherit',
+ lineHeight: 'inherit',
+ fontSize: '12px',
+ fontWeight: 500,
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ textAlign: 'start',
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ transition: 'color 0.2s ease',
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineWidth: { 'default': null, ':focus-visible': '1px' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorBorder },
+ outlineOffset: { 'default': null, ':focus-visible': '2px' },
+ },
+ sectionHeaderLabel: {
+ color: {
+ default: cssVar.colorTextSecondary,
+ [stylex.when.ancestor(':hover')]: cssVar.colorText,
+ },
+ },
+ body: {
+ overflowY: 'auto',
+ overscrollBehavior: 'contain',
+ display: 'flex',
+ flexGrow: '1',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ flexDirection: 'column',
+ minHeight: '0',
+ paddingBlockEnd: '4px',
+ paddingInline: '12px',
+ },
+ commonSection: { display: 'flex', flexDirection: 'column', paddingBlock: '0' },
+ divider: { height: '1px', backgroundColor: cssVar.colorSplit, backgroundImage: 'none' },
+ hint: { fontSize: '12px', lineHeight: '18px', color: cssVar.colorTextTertiary },
+ form: { margin: '0' },
+ formSidebar: { display: 'flex', flex: '1', width: '100%', height: '100%', minHeight: '0' },
+ header: {
+ display: 'flex',
+ gap: '12px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ paddingBlock: '16px',
+ paddingInline: '12px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorSplit,
+ fontSize: '14px',
+ fontWeight: 600,
+ lineHeight: 1.4,
+ color: cssVar.colorText,
+ },
+ headerLoading: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '18px',
+ height: '18px',
+ color: cssVar.colorTextTertiary,
+ },
+ headerTitle: {
+ overflow: 'hidden',
+ minWidth: '0',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ label: {
+ userSelect: 'none',
+ minWidth: '0',
+ fontSize: '13px',
+ fontWeight: 500,
+ lineHeight: '20px',
+ color: cssVar.colorTextSecondary,
+ },
+ labelMain: { flexWrap: 'wrap', minWidth: '0' },
+ labelMuted: { color: cssVar.colorTextTertiary },
+ modelConfigSection: { paddingBlock: '12px' },
+ panel: {
+ overflow: 'hidden',
+ display: 'flex',
+ flexDirection: 'column',
+ width: 'min(384px, 100%)',
+ maxHeight: '50vh',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '16px',
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ boxShadow: cssVar.boxShadowSecondary,
+ },
+ sidebarPanel: {
+ width: '100%',
+ height: '100%',
+ maxHeight: 'none',
+ borderStyle: 'none',
+ borderRadius: 0,
+ backgroundColor: 'transparent',
+ backgroundImage: 'none',
+ boxShadow: 'none',
+ },
+ rowControl: { width: '100%' },
+ rowRoot: { paddingBlock: '12px' },
+ // Rows inside the advanced list are divided from the previous row; the first has no rule.
+ rowSeparated: {
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: { 'default': 'solid', ':first-child': 'none' },
+ borderBlockStartColor: cssVar.colorSplit,
+ },
+ tag: {
+ userSelect: 'none',
+ alignSelf: 'flex-start',
+ width: 'fit-content',
+ paddingBlock: '2px',
+ paddingInline: '7px',
+ borderRadius: '999px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '10px',
+ fontWeight: 500,
+ lineHeight: 1.2,
+ color: cssVar.colorTextQuaternary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ tooltipContent: { display: 'flex', flexDirection: 'column', gap: '6px', maxWidth: '240px' },
+ slider: { width: '100%' },
+});
const PARAM_NAME_MAP: Record<ParamKey, string> = {
frequency_penalty: 'params.frequency_penalty',
@@ -333,20 +285,30 @@ const setStoredOpen = (storageKey: string, open: boolean) => {
};
interface ControlLabelProps {
+ muted?: boolean;
tag?: string;
title: string;
tooltip?: string;
}
-const ControlLabel = memo<ControlLabelProps>(({ title, tooltip, tag }) => (
- <Flexbox align={'flex-start'} className={cx(styles.label, 'control-label')} gap={6}>
- <Flexbox horizontal align={'center'} className={styles.labelMain} gap={6}>
+const ControlLabel = memo<ControlLabelProps>(({ muted, title, tooltip, tag }) => (
+ <Flexbox
+ align={'flex-start'}
+ className={stylex.props(styles.label, muted && styles.labelMuted).className}
+ gap={6}
+ >
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.labelMain).className}
+ gap={6}
+ >
{title}
{tooltip && (
<InfoTooltip
title={
- <div className={styles.tooltipContent}>
- {tag && <span className={styles.tag}>{tag}</span>}
+ <div {...stylex.props(styles.tooltipContent)}>
+ {tag && <span {...stylex.props(styles.tag)}>{tag}</span>}
<span>{tooltip}</span>
</div>
}
@@ -360,18 +322,31 @@ interface ControlRowProps {
action?: ReactNode;
children?: ReactNode;
muted?: boolean;
+ /** Draw a rule above the row (none above the first sibling). */
+ separated?: boolean;
tag?: string;
title: string;
tooltip?: string;
}
-const ControlRow = ({ action, children, muted, tag, title, tooltip }: ControlRowProps) => (
- <Flexbox className={cx('control-row', styles.rowRoot, muted && styles.muted)} gap={10}>
+const ControlRow = ({
+ action,
+ children,
+ muted,
+ separated,
+ tag,
+ title,
+ tooltip,
+}: ControlRowProps) => (
+ <Flexbox
+ className={stylex.props(styles.rowRoot, separated && styles.rowSeparated).className}
+ gap={10}
+ >
<Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>
- <ControlLabel tag={tag} title={title} tooltip={tooltip} />
+ <ControlLabel muted={muted} tag={tag} title={title} tooltip={tooltip} />
{action}
</Flexbox>
- {children && <div className={styles.rowControl}>{children}</div>}
+ {children && <div {...stylex.props(styles.rowControl)}>{children}</div>}
</Flexbox>
);
@@ -382,9 +357,14 @@ interface SectionHeaderProps {
}
const SectionHeader = memo<SectionHeaderProps>(({ onToggle, open, title }) => (
- <button aria-expanded={open} className={styles.sectionHeader} type="button" onClick={onToggle}>
+ <button
+ aria-expanded={open}
+ type="button"
+ {...stylex.props(styles.sectionHeader, stylex.defaultMarker())}
+ onClick={onToggle}
+ >
<Flexbox horizontal align={'center'} gap={12} justify={'space-between'}>
- <span className={cx(styles.label, 'section-header-label')}>{title}</span>
+ <span {...stylex.props(styles.label, styles.sectionHeaderLabel)}>{title}</span>
<Icon icon={open ? ChevronUp : ChevronDown} size={18} />
</Flexbox>
</button>
@@ -409,7 +389,7 @@ const SliderField = ({
}: SliderFieldProps) => (
<SliderWithInput
changeOnWheel
- className={styles.slider}
+ className={stylex.props(styles.slider).className}
controls={false}
disabled={disabled}
gap={10}
@@ -733,18 +713,18 @@ const Controls = ({ variant = 'popover' }: ControlsProps) => {
}, []);
return (
- <div className={cx(styles.form, variant === 'sidebar' && styles.formSidebar)}>
- <div className={cx(styles.panel, variant === 'sidebar' && styles.sidebarPanel)}>
- <div className={styles.header}>
- <span className={styles.headerTitle}>{panelTitle}</span>
+ <div {...stylex.props(styles.form, variant === 'sidebar' && styles.formSidebar)}>
+ <div {...stylex.props(styles.panel, variant === 'sidebar' && styles.sidebarPanel)}>
+ <div {...stylex.props(styles.header)}>
+ <span {...stylex.props(styles.headerTitle)}>{panelTitle}</span>
{updating && (
- <div className={styles.headerLoading}>
+ <div {...stylex.props(styles.headerLoading)}>
<Spin size="small" />
</div>
)}
</div>
- <div className={styles.body}>
- <div className={styles.commonSection}>
+ <div {...stylex.props(styles.body)}>
+ <div {...stylex.props(styles.commonSection)}>
<ControlRow
tag="agentMode"
title={t('settingModel.params.panel.chatMode')}
@@ -878,7 +858,7 @@ const Controls = ({ variant = 'popover' }: ControlsProps) => {
}
>
{showFollowUpHint && (
- <div className={styles.hint}>
+ <div {...stylex.props(styles.hint)}>
{t('settingChat.enableFollowUpChips.notConfiguredHint')}
</div>
)}
@@ -930,14 +910,14 @@ const Controls = ({ variant = 'popover' }: ControlsProps) => {
</div>
{hasModelConfig && (
<>
- <div className={styles.divider} />
+ <div {...stylex.props(styles.divider)} />
<SectionHeader
open={modelConfigOpen}
title={t('ModelSwitchPanel.detail.config', { ns: 'components' })}
onToggle={handleModelConfigOpenChange}
/>
{modelConfigOpen && (
- <div className={styles.modelConfigSection}>
+ <div {...stylex.props(styles.modelConfigSection)}>
<ControlsForm
hideReasoningParams
disabled={!canCreate}
@@ -951,20 +931,21 @@ const Controls = ({ variant = 'popover' }: ControlsProps) => {
)}
{!enableAgentMode && (
<>
- <div className={styles.divider} />
+ <div {...stylex.props(styles.divider)} />
<SectionHeader
open={advancedOpen}
title={t('settingModel.params.panel.advanced')}
onToggle={handleAdvancedOpenChange}
/>
{advancedOpen && (
- <div className={styles.advancedContent}>
+ <div {...stylex.props(styles.advancedContent)}>
{PARAM_ORDER.filter((key) => !disabledParams?.includes(key)).map((key) => {
const meta = PARAM_CONFIG[key];
const enabled = enabledMap[key];
return (
<ControlRow
+ separated
key={key}
muted={!enabled}
tag={meta.tag}
@@ -995,6 +976,7 @@ const Controls = ({ variant = 'popover' }: ControlsProps) => {
);
})}
<ControlRow
+ separated
tag="max_tokens"
title={t('settingModel.params.panel.responseLength')}
tooltip={t('settingModel.maxTokens.desc')}
@@ -1029,6 +1011,7 @@ const Controls = ({ variant = 'popover' }: ControlsProps) => {
</ControlRow>
{!hasReasoningExtendParams && (
<ControlRow
+ separated
tag="reasoning_effort"
title={t('settingModel.reasoningEffort.title')}
tooltip={t('settingModel.reasoningEffort.desc')}
diff --git a/src/features/ChatInput/ActionBar/Plus/index.tsx b/src/features/ChatInput/ActionBar/Plus/index.tsx
index 79990269e1f..52452006d5c 100644
--- a/src/features/ChatInput/ActionBar/Plus/index.tsx
+++ b/src/features/ChatInput/ActionBar/Plus/index.tsx
@@ -1,11 +1,12 @@
'use client';
import { validateVideoFileSize } from '@lobechat/utils/client';
-import { css, cssVar, cx, Icon, Popover, toast, Upload } from '@lobehub/ui';
+import { Icon, Popover, toast, Upload } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import {
CheckIcon,
- ChevronRight,
Cloud,
FileUp,
LibraryBig,
@@ -45,93 +46,68 @@ import { insertGoalTag } from '../../InputEditor/ActionTag/goalTag';
import { useChatInputStore } from '../../store';
import { type ActionDropdownMenuItems } from '../components/ActionDropdown';
import { ChatInputAction } from '../components/ChatInputAction';
+import SubmenuChevron from '../components/SubmenuChevron';
import { useDetailPopoverState } from '../components/useDetailPopoverState';
import { useControls as useKnowledgeControls } from '../Knowledge/useControls';
import { useControls as useToolsControls } from '../Tools/useControls';
-const hotArea = css`
- &::before {
- content: '';
- position: absolute;
- inset: 0;
- background-color: transparent;
- }
-`;
-
-const activeLabel = css`
- display: flex;
- gap: 16px;
- align-items: center;
- justify-content: space-between;
-
- width: 100%;
-
- color: inherit;
-
- span {
- overflow: hidden;
- min-width: 0;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-`;
-
-const labelWithChip = css`
- display: inline-flex;
- gap: 8px;
- align-items: center;
-`;
-
-const countChip = css`
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- min-width: 18px;
- height: 18px;
- padding-block: 0;
- padding-inline: 6px;
- border-radius: 9px;
-
- font-size: 11px;
- line-height: 18px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillSecondary};
-`;
-
-const gatewayModeInfoCard = css`
- overflow: hidden;
- width: 280px;
- border-radius: 8px;
-
- .cover {
- display: block;
-
- width: 100%;
- height: 148px;
-
- object-fit: cover;
- background: ${cssVar.colorFillTertiary};
- }
-
- .body {
- padding: 12px;
- }
-
- .title {
- font-size: 14px;
- font-weight: 600;
- line-height: 1.35;
- }
-
- .desc {
- margin-block-start: 6px;
- font-size: 12px;
- line-height: 1.5;
- color: ${cssVar.colorTextSecondary};
- }
-`;
+const styles = stylex.create({
+ activeLabel: {
+ display: 'flex',
+ gap: '16px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ width: '100%',
+ color: 'inherit',
+ },
+ activeLabelText: {
+ overflow: 'hidden',
+ minWidth: '0',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ countChip: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ minWidth: '18px',
+ height: '18px',
+ paddingBlock: '0',
+ paddingInline: '6px',
+ borderRadius: '9px',
+ fontSize: '11px',
+ lineHeight: '18px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ gatewayBody: { padding: '12px' },
+ gatewayCard: { overflow: 'hidden', width: '280px', borderRadius: '8px' },
+ gatewayCover: {
+ display: 'block',
+ width: '100%',
+ height: '148px',
+ objectFit: 'cover',
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ gatewayDesc: {
+ marginBlockStart: '6px',
+ fontSize: '12px',
+ lineHeight: 1.5,
+ color: cssVar.colorTextSecondary,
+ },
+ gatewayTitle: { fontSize: '14px', fontWeight: 600, lineHeight: 1.35 },
+ hotArea: {
+ '::before': {
+ content: '""',
+ position: 'absolute',
+ inset: 0,
+ backgroundColor: 'transparent',
+ },
+ },
+ labelWithChip: { display: 'inline-flex', gap: '8px', alignItems: 'center' },
+});
type DropdownItemWithPopover = NonNullable<ActionDropdownMenuItems>[number] & {
label?: ReactNode;
@@ -311,8 +287,8 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
const items = useMemo<ActionDropdownMenuItems>(() => {
const renderActive = (label: string, active: boolean) =>
active ? (
- <div className={cx(activeLabel)}>
- <span>{label}</span>
+ <div {...stylex.props(styles.activeLabel)}>
+ <span {...stylex.props(styles.activeLabelText)}>{label}</span>
<Icon icon={CheckIcon} size={14} />
</div>
) : (
@@ -321,24 +297,24 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
const renderLabelWithCount = (label: string, count: number, prefix?: string) =>
count > 0 || prefix ? (
- <span className={cx(labelWithChip)}>
+ <span {...stylex.props(styles.labelWithChip)}>
<span>{label}</span>
- <span className={cx(countChip)}>{prefix ? `${prefix} | ${count}` : count}</span>
+ <span {...stylex.props(styles.countChip)}>{prefix ? `${prefix} | ${count}` : count}</span>
</span>
) : (
label
);
const gatewayModeInfo = (
- <div className={cx(gatewayModeInfoCard)}>
+ <div {...stylex.props(styles.gatewayCard)}>
<img
alt=""
- className="cover"
+ {...stylex.props(styles.gatewayCover)}
src={imageUrl(isDark ? 'agent_gateway_dark.webp' : 'agent_gateway_light.webp')}
/>
- <div className="body">
- <div className="title">{t('gatewayMode.cardTitle')}</div>
- <div className="desc">{t('gatewayMode.desc')}</div>
+ <div {...stylex.props(styles.gatewayBody)}>
+ <div {...stylex.props(styles.gatewayTitle)}>{t('gatewayMode.cardTitle')}</div>
+ <div {...stylex.props(styles.gatewayDesc)}>{t('gatewayMode.desc')}</div>
</div>
</div>
);
@@ -383,7 +359,7 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
if (filesToUpload.length > 0) await upload(filesToUpload, agentId);
}}
>
- <div className={cx(hotArea)}>{t('upload.action.fileOrImageUpload')}</div>
+ <div {...stylex.props(styles.hotArea)}>{t('upload.action.fileOrImageUpload')}</div>
</Upload>
),
},
@@ -401,7 +377,7 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
children: skillMenuItems,
// Trailing chevron (replaces base-ui's default triangle submenu arrow,
// which is hidden via the .lobe-submenu-chevron rule in ActionDropdown).
- extra: <Icon className="lobe-submenu-chevron" icon={ChevronRight} size={16} />,
+ extra: <SubmenuChevron />,
footer: skillMarketFooter,
header: skillMarketHeader,
icon: SkillsIcon,
@@ -489,7 +465,7 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI
],
// Trailing chevron (replaces base-ui's default triangle submenu arrow,
// which is hidden via the .lobe-submenu-chevron rule in ActionDropdown).
- extra: <Icon className="lobe-submenu-chevron" icon={ChevronRight} size={16} />,
+ extra: <SubmenuChevron />,
footer: canConfigureResource ? knowledgeFooter : undefined,
icon: LibraryBig,
key: 'attachments',
diff --git a/src/features/ChatInput/ActionBar/Search/Controls.tsx b/src/features/ChatInput/ActionBar/Search/Controls.tsx
index 722dba1c288..6e4dd334fb5 100644
--- a/src/features/ChatInput/ActionBar/Search/Controls.tsx
+++ b/src/features/ChatInput/ActionBar/Search/Controls.tsx
@@ -1,5 +1,7 @@
-import { Center, createStaticStyles, cssVar, cx, Divider, Flexbox, Icon } from '@lobehub/ui';
+import { Center, Divider, Flexbox, Icon } from '@lobehub/ui';
import { GlobeOffIcon } from '@lobehub/ui/icons';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { type LucideIcon } from 'lucide-react';
import { SparkleIcon } from 'lucide-react';
import { memo, useEffect } from 'react';
@@ -17,44 +19,29 @@ import { useUpdateAgentConfig } from '../../hooks/useUpdateAgentConfig';
import FCSearchModel from './FCSearchModel';
import ModelBuiltinSearch from './ModelBuiltinSearch';
-const styles = createStaticStyles(({ css }) => ({
- active: css`
- background: ${cssVar.colorFillTertiary};
- `,
- check: css`
- margin-inline-start: 12px;
- font-size: 16px;
- color: ${cssVar.colorPrimary};
- `,
- description: css`
- font-size: 12px;
- color: ${cssVar.colorTextDescription};
- `,
- icon: css`
- border: 1px solid ${cssVar.colorFillTertiary};
- border-radius: ${cssVar.borderRadius};
- background: ${cssVar.colorBgElevated};
- `,
- option: css`
- cursor: pointer;
-
- width: 100%;
- padding-block: 8px;
- padding-inline: 8px;
- border-radius: ${cssVar.borderRadius};
-
- transition: background-color 0.2s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- title: css`
- font-size: 14px;
- font-weight: 500;
- color: ${cssVar.colorText};
- `,
-}));
+const styles = stylex.create({
+ active: { backgroundColor: cssVar.colorFillTertiary, backgroundImage: 'none' },
+ description: { fontSize: '12px', color: cssVar.colorTextDescription },
+ icon: {
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillTertiary,
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ },
+ option: {
+ cursor: 'pointer',
+ width: '100%',
+ paddingBlock: '8px',
+ paddingInline: '8px',
+ borderRadius: cssVar.borderRadius,
+ transition: 'background-color 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ title: { fontSize: '14px', fontWeight: 500, color: cssVar.colorText },
+});
interface NetworkOption {
description: string;
@@ -74,7 +61,7 @@ const Item = memo<NetworkOption>(({ value, description, icon, label }) => {
<Flexbox
horizontal
align={'flex-start'}
- className={cx(styles.option, mode === value && styles.active)}
+ className={stylex.props(styles.option, mode === value && styles.active).className}
gap={12}
key={value}
style={{
@@ -86,12 +73,12 @@ const Item = memo<NetworkOption>(({ value, description, icon, label }) => {
await updateAgentChatConfig({ searchMode: value });
}}
>
- <Center className={styles.icon} flex={'none'} height={32} width={32}>
+ <Center className={stylex.props(styles.icon).className} flex={'none'} height={32} width={32}>
<Icon icon={icon} />
</Center>
<Flexbox flex={1}>
- <div className={styles.title}>{label}</div>
- <div className={styles.description}>{description}</div>
+ <div {...stylex.props(styles.title)}>{label}</div>
+ <div {...stylex.props(styles.description)}>{description}</div>
</Flexbox>
</Flexbox>
);
diff --git a/src/features/ChatInput/ActionBar/Search/FCSearchModel.tsx b/src/features/ChatInput/ActionBar/Search/FCSearchModel.tsx
index b7ff9b82fee..7831af8238a 100644
--- a/src/features/ChatInput/ActionBar/Search/FCSearchModel.tsx
+++ b/src/features/ChatInput/ActionBar/Search/FCSearchModel.tsx
@@ -1,4 +1,6 @@
-import { createStaticStyles, cssVar, Flexbox } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -10,27 +12,9 @@ import { useAgentId } from '../../hooks/useAgentId';
import { useUpdateAgentConfig } from '../../hooks/useUpdateAgentConfig';
import FunctionCallingModelSelect from './FunctionCallingModelSelect';
-const styles = createStaticStyles(({ css }) => ({
- check: css`
- margin-inline-start: 12px;
- font-size: 16px;
- color: ${cssVar.colorPrimary};
- `,
- content: css`
- flex: 1;
- width: 230px;
- `,
- description: css`
- width: 200px;
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- `,
- title: css`
- font-size: 14px;
- font-weight: 500;
- color: ${cssVar.colorText};
- `,
-}));
+const styles = stylex.create({
+ title: { fontSize: '14px', fontWeight: 500, color: cssVar.colorText },
+});
interface FCSearchModelProps {
disabled?: boolean;
@@ -46,7 +30,9 @@ const FCSearchModel = memo<FCSearchModelProps>(({ disabled }) => {
return (
<Flexbox horizontal distribution={'space-between'} gap={16} padding={8}>
<Flexbox horizontal align={'center'} gap={4}>
- <Flexbox className={styles.title}>{t('search.searchModel.title')}</Flexbox>
+ <Flexbox className={stylex.props(styles.title).className}>
+ {t('search.searchModel.title')}
+ </Flexbox>
<InfoTooltip title={t('search.searchModel.desc')} />
</Flexbox>
<FunctionCallingModelSelect
diff --git a/src/features/ChatInput/ActionBar/Search/FunctionCallingModelSelect/index.tsx b/src/features/ChatInput/ActionBar/Search/FunctionCallingModelSelect/index.tsx
index 9039963fac2..bbad504060f 100644
--- a/src/features/ChatInput/ActionBar/Search/FunctionCallingModelSelect/index.tsx
+++ b/src/features/ChatInput/ActionBar/Search/FunctionCallingModelSelect/index.tsx
@@ -1,4 +1,4 @@
-import { createStaticStyles, Select, type SelectProps, TooltipGroup } from '@lobehub/ui';
+import { Select, type SelectProps, TooltipGroup } from '@lobehub/ui';
import { type ReactNode } from 'react';
import { memo, useMemo } from 'react';
@@ -7,16 +7,6 @@ import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';
import { type WorkingModel } from '@/types/agent';
import { type EnabledProviderWithModels } from '@/types/aiProvider';
-const prefixCls = 'ant';
-
-const styles = createStaticStyles(({ css }) => ({
- select: css`
- &.${prefixCls}-select-dropdown .${prefixCls}-select-item-option-grouped {
- padding-inline-start: 12px;
- }
- `,
-}));
-
interface ModelOption {
label: ReactNode;
provider: string;
@@ -71,7 +61,6 @@ const ModelSelect = memo<ModelSelectProps>(({ value, onChange, ...rest }) => {
<TooltipGroup>
<Select
options={options}
- popupClassName={styles.select}
popupMatchSelectWidth={false}
value={`${value?.provider}/${value?.model}`}
variant={'filled'}
diff --git a/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx b/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx
index 8cadb1c2ca3..c6cf9ca9938 100644
--- a/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx
+++ b/src/features/ChatInput/ActionBar/Tools/PopoverContent.tsx
@@ -1,13 +1,7 @@
import { type ItemType } from '@lobehub/ui';
-import {
- createStaticStyles,
- cssVar,
- Flexbox,
- Icon,
- SearchBar,
- stopPropagation,
- usePopoverContext,
-} from '@lobehub/ui';
+import { Flexbox, Icon, SearchBar, stopPropagation, usePopoverContext } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { Pin, Settings, Store, Zap } from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -18,84 +12,64 @@ import { ScrollSignalProvider } from './ScrollSignalContext';
import SkillActivateMode from './SkillActivateMode';
import ToolsList from './ToolsList';
-const styles = createStaticStyles(({ css }) => ({
- footer: css`
- display: flex;
- gap: 14px;
- align-items: center;
-
- padding-block: 6px;
- padding-inline: 12px;
- border-block-start: 1px solid ${cssVar.colorFill};
- `,
- header: css`
- padding-block: 8px;
- padding-inline: 8px;
- border-block-end: 1px solid ${cssVar.colorFill};
- `,
- iconButton: css`
- cursor: pointer;
-
- display: inline-flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- width: 28px;
- height: 28px;
- border: 0;
- border-radius: 6px;
-
- color: ${cssVar.colorTextTertiary};
-
- background: transparent;
-
- transition:
- color 0.2s,
- background 0.2s;
-
- &:hover {
- color: ${cssVar.colorTextSecondary};
- background: ${cssVar.colorFillTertiary};
- }
- `,
- statsItem: css`
- display: inline-flex;
- gap: 5px;
- align-items: center;
-
- font-size: 12px;
- line-height: 18px;
- color: ${cssVar.colorTextTertiary};
- `,
- storeButton: css`
- cursor: pointer;
-
- display: inline-flex;
- flex: none;
- gap: 4px;
- align-items: center;
-
- height: 28px;
- padding-inline: 8px;
- border: 0;
- border-radius: 6px;
-
- font-size: 13px;
- color: ${cssVar.colorTextSecondary};
-
- background: transparent;
-
- transition:
- color 0.2s,
- background 0.2s;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillTertiary};
- }
- `,
-}));
+const styles = stylex.create({
+ footer: {
+ display: 'flex',
+ gap: '14px',
+ alignItems: 'center',
+ paddingBlock: '6px',
+ paddingInline: '12px',
+ borderBlockStartWidth: '1px',
+ borderBlockStartStyle: 'solid',
+ borderBlockStartColor: cssVar.colorFill,
+ },
+ header: {
+ paddingBlock: '8px',
+ paddingInline: '8px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorFill,
+ },
+ iconButton: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '28px',
+ height: '28px',
+ borderStyle: 'none',
+ borderRadius: '6px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorTextSecondary },
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'color 0.2s, background 0.2s',
+ },
+ statsItem: {
+ display: 'inline-flex',
+ gap: '5px',
+ alignItems: 'center',
+ fontSize: '12px',
+ lineHeight: '18px',
+ color: cssVar.colorTextTertiary,
+ },
+ storeButton: {
+ cursor: 'pointer',
+ display: 'inline-flex',
+ flex: 'none',
+ gap: '4px',
+ alignItems: 'center',
+ height: '28px',
+ paddingInline: '8px',
+ borderStyle: 'none',
+ borderRadius: '6px',
+ fontSize: '13px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'color 0.2s, background 0.2s',
+ },
+});
const filterItems = (items: ItemType[], keyword: string): ItemType[] => {
const lower = keyword.toLowerCase();
@@ -145,7 +119,12 @@ const PopoverContent = memo<PopoverContentProps>(
return (
<Flexbox gap={0}>
- <Flexbox horizontal align="center" className={styles.header} gap={4}>
+ <Flexbox
+ horizontal
+ align="center"
+ className={stylex.props(styles.header).className}
+ gap={4}
+ >
<SearchBar
allowClear
placeholder={t('tools.search')}
@@ -166,18 +145,18 @@ const PopoverContent = memo<PopoverContentProps>(
>
<ToolsList detailPopoverDisabled={detailPopoverDisabled} items={filteredItems} />
</ScrollSignalProvider>
- <div className={styles.footer}>
- <span className={styles.statsItem}>
+ <div {...stylex.props(styles.footer)}>
+ <span {...stylex.props(styles.statsItem)}>
<Icon icon={Pin} size={12} />
{pinnedCount}
</span>
- <span className={styles.statsItem}>
+ <span {...stylex.props(styles.statsItem)}>
<Icon icon={Zap} size={12} />
{autoCount}
</span>
<Flexbox horizontal align="center" gap={2} style={{ marginInlineStart: 'auto' }}>
<button
- className={styles.storeButton}
+ {...stylex.props(styles.storeButton)}
type="button"
onClick={() => {
closePopover();
@@ -189,7 +168,7 @@ const PopoverContent = memo<PopoverContentProps>(
</button>
<button
aria-label={t('tools.plugins.management')}
- className={styles.iconButton}
+ {...stylex.props(styles.iconButton)}
type="button"
onClick={() => {
closePopover();
diff --git a/src/features/ChatInput/ActionBar/Tools/ToolItemDetailPopover.tsx b/src/features/ChatInput/ActionBar/Tools/ToolItemDetailPopover.tsx
index 145f3de589c..8259b2e576d 100644
--- a/src/features/ChatInput/ActionBar/Tools/ToolItemDetailPopover.tsx
+++ b/src/features/ChatInput/ActionBar/Tools/ToolItemDetailPopover.tsx
@@ -1,36 +1,29 @@
-import { createStaticStyles, cssVar, Flexbox, Tag, Text } from '@lobehub/ui';
+import { Flexbox, Tag, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo, type ReactNode } from 'react';
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- width: 320px;
- padding: 12px;
- `,
- description: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 6;
-
- font-size: 12px;
- line-height: 1.5;
- color: ${cssVar.colorTextSecondary};
- `,
- identifier: css`
- overflow: hidden;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 11px;
- color: ${cssVar.colorTextTertiary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- title: css`
- font-size: 14px;
- font-weight: 600;
- color: ${cssVar.colorText};
- `,
-}));
+const styles = stylex.create({
+ container: { width: '320px', padding: '12px' },
+ description: {
+ overflow: 'hidden',
+ display: '-webkit-box',
+ WebkitBoxOrient: 'vertical',
+ WebkitLineClamp: '6',
+ fontSize: '12px',
+ lineHeight: 1.5,
+ color: cssVar.colorTextSecondary,
+ },
+ identifier: {
+ overflow: 'hidden',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '11px',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ title: { fontSize: '14px', fontWeight: 600, color: cssVar.colorText },
+});
interface ToolItemDetailPopoverProps {
description?: ReactNode;
@@ -50,12 +43,12 @@ interface ToolItemDetailPopoverProps {
const ToolItemDetailPopover = memo<ToolItemDetailPopoverProps>(
({ icon, title, description, sourceLabel, identifier, meta }) => {
return (
- <Flexbox className={styles.container} gap={10}>
+ <Flexbox className={stylex.props(styles.container).className} gap={10}>
<Flexbox horizontal align={'center'} gap={10}>
{icon}
<Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
<Flexbox horizontal align={'center'} gap={6}>
- <Text ellipsis className={styles.title}>
+ <Text ellipsis className={stylex.props(styles.title).className}>
{title}
</Text>
{sourceLabel && (
@@ -64,10 +57,10 @@ const ToolItemDetailPopover = memo<ToolItemDetailPopoverProps>(
</Tag>
)}
</Flexbox>
- {identifier && <span className={styles.identifier}>{identifier}</span>}
+ {identifier && <span {...stylex.props(styles.identifier)}>{identifier}</span>}
</Flexbox>
</Flexbox>
- {description && <div className={styles.description}>{description}</div>}
+ {description && <div {...stylex.props(styles.description)}>{description}</div>}
{meta}
</Flexbox>
);
diff --git a/src/features/ChatInput/ActionBar/Tools/ToolsList.tsx b/src/features/ChatInput/ActionBar/Tools/ToolsList.tsx
index 6a683eae364..a9a049d4e5d 100644
--- a/src/features/ChatInput/ActionBar/Tools/ToolsList.tsx
+++ b/src/features/ChatInput/ActionBar/Tools/ToolsList.tsx
@@ -1,47 +1,46 @@
import type { ItemType } from '@lobehub/ui';
-import { createStaticStyles, cssVar, Divider, Flexbox, Icon, Popover, Text } from '@lobehub/ui';
+import { Divider, Flexbox, Icon, Popover, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { ReactNode } from 'react';
import { Fragment, isValidElement, memo } from 'react';
import { useDetailPopoverState } from '../components/useDetailPopoverState';
import { useScrollSignal } from './ScrollSignalContext';
-export const toolsListStyles = createStaticStyles(({ css }) => ({
- groupLabel: css`
- padding-block: 12px 4px;
- padding-inline: 12px;
- `,
- item: css`
- cursor: pointer;
-
- display: flex;
- gap: 12px;
- align-items: center;
-
- padding-block: 8px;
- padding-inline: 12px;
- border-radius: 6px;
-
- transition: background-color 0.2s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- itemContent: css`
- flex: 1;
- min-width: 0;
- `,
- itemIcon: css`
- display: flex;
- flex-shrink: 0;
- align-items: center;
- justify-content: center;
-
- width: 24px;
- height: 24px;
- `,
-}));
+const styles = stylex.create({
+ groupLabel: { paddingBlockStart: '12px', paddingBlockEnd: '4px', paddingInline: '12px' },
+ item: {
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '12px',
+ alignItems: 'center',
+ paddingBlock: '8px',
+ paddingInline: '12px',
+ borderRadius: '6px',
+ transition: 'background-color 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ itemContent: { flex: '1', minWidth: '0' },
+ itemIcon: {
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '24px',
+ height: '24px',
+ },
+});
+
+/**
+ * Class names for callers outside this file (the profile editor popover reuses the row look).
+ */
+export const toolsListStyles = {
+ item: stylex.props(styles.item).className,
+ itemContent: stylex.props(styles.itemContent).className,
+ itemIcon: stylex.props(styles.itemIcon).className,
+};
interface ToolItemData {
children?: ToolItemData[];
@@ -89,14 +88,14 @@ const RegularItem = memo<{
const row = (
<div
- className={toolsListStyles.item}
+ {...stylex.props(styles.item)}
key={item.key || `item-${index}`}
role="button"
tabIndex={0}
onClick={item.onClick}
>
- {iconNode && <div className={toolsListStyles.itemIcon}>{iconNode}</div>}
- <div className={toolsListStyles.itemContent}>{item.label}</div>
+ {iconNode && <div {...stylex.props(styles.itemIcon)}>{iconNode}</div>}
+ <div {...stylex.props(styles.itemContent)}>{item.label}</div>
{item.extra}
</div>
);
@@ -129,7 +128,7 @@ const GroupItem = memo<{
item: ToolItemData;
}>(({ detailPopoverDisabled, item, index }) => (
<Fragment key={item.key || `group-${index}`}>
- <Text className={toolsListStyles.groupLabel} fontSize={12} type="secondary">
+ <Text className={stylex.props(styles.groupLabel).className} fontSize={12} type="secondary">
{item.label}
</Text>
{item.children?.map((child, childIndex) => (
diff --git a/src/features/ChatInput/ActionBar/Tools/useControls.styles.ts b/src/features/ChatInput/ActionBar/Tools/useControls.styles.ts
new file mode 100644
index 00000000000..2ea2c1f1d84
--- /dev/null
+++ b/src/features/ChatInput/ActionBar/Tools/useControls.styles.ts
@@ -0,0 +1,268 @@
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+// StyleX can only fold constants declared in this module (or in a `.stylex.ts` file), so
+// these mirror ./constants — keep the two in sync.
+const SKILL_ICON_SIZE = 18;
+const SKILL_ICON_GAP = 14;
+const SKILL_TRAILING_CONTROL_SIZE = 20;
+
+// Shared by the policy menu rows; kept in one place so hover/disabled stay in sync.
+export const styles = stylex.create({
+ activationGroupActions: { display: 'flex', flex: 'none', gap: '8px', alignItems: 'center' },
+ activationGroupChevron: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: `${SKILL_TRAILING_CONTROL_SIZE}px`,
+ height: `${SKILL_TRAILING_CONTROL_SIZE}px`,
+ color: cssVar.colorTextTertiary,
+ },
+ activationGroupHeader: {
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '12px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ width: '100%',
+ minWidth: '0',
+ paddingBlock: '4px',
+ },
+ activationGroupIcon: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: `${SKILL_ICON_SIZE}px`,
+ },
+ activationGroupTitleBlock: {
+ display: 'flex',
+ gap: `${SKILL_ICON_GAP}px`,
+ alignItems: 'center',
+ minWidth: '0',
+ },
+ activationGroupTitleBody: {
+ display: 'flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: '0',
+ },
+ activationGroupTitleText: {
+ overflow: 'hidden',
+ minWidth: '0',
+ fontSize: '14px',
+ fontWeight: 500,
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ textTransform: 'none',
+ whiteSpace: 'nowrap',
+ },
+ addSkillLabel: { flex: '1', textAlign: 'start' },
+ addSkillRow: {
+ display: 'flex',
+ gap: `${SKILL_ICON_GAP}px`,
+ alignItems: 'center',
+ width: 'calc(100% + 24px)',
+ minHeight: '32px',
+ // The footer adds 8px block padding; cancel it on the last action row so the
+ // bottom row sits flush against the popup edge instead of leaving a gap.
+ marginBlockEnd: { 'default': null, ':last-child': '-8px' },
+ marginInline: '-12px',
+ paddingInline: '12px',
+ borderStyle: 'none',
+ borderRadius: '6px',
+ fontSize: '14px',
+ color: cssVar.colorText,
+ backgroundColor: { 'default': 'transparent', ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: `background 150ms ${cssVar.motionEaseOut}`,
+ },
+ count: { flex: 'none', color: cssVar.colorTextTertiary },
+ deleteButton: {
+ cursor: { 'default': 'pointer', ':disabled': 'not-allowed' },
+ display: 'flex',
+ gap: '10px',
+ alignItems: 'center',
+ width: '100%',
+ minHeight: '36px',
+ paddingBlock: '8px',
+ paddingInline: '10px',
+ borderStyle: 'none',
+ borderRadius: '6px',
+ fontSize: '14px',
+ lineHeight: '20px',
+ color: cssVar.colorError,
+ opacity: { 'default': null, ':disabled': 0.45 },
+ // `:disabled` has to win over `:hover`, so it is nested under it.
+ backgroundColor: {
+ 'default': 'transparent',
+ ':hover': { 'default': cssVar.colorErrorBg, ':disabled': 'transparent' },
+ },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: `background 150ms ${cssVar.motionEaseOut}`,
+ },
+ deleteDivider: {
+ height: '1px',
+ marginBlock: '2px',
+ marginInline: '4px',
+ backgroundColor: cssVar.colorBorderSecondary,
+ backgroundImage: 'none',
+ },
+ deleteIcon: { color: cssVar.colorError },
+ iconAuto: { color: cssVar.colorInfo },
+ iconDefault: { color: cssVar.colorTextTertiary },
+ iconDisabled: { color: cssVar.colorError },
+ iconPinned: { color: cssVar.colorInfo },
+ policyButton: {
+ cursor: { 'default': 'pointer', ':disabled': 'not-allowed' },
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ // Connector rows hand this button to the menu's extra slot, a plain block
+ // wrapper — without vertical-align its strut adds descender space below the
+ // button and pushes those rows taller than the rest.
+ width: `${SKILL_TRAILING_CONTROL_SIZE}px`,
+ height: `${SKILL_TRAILING_CONTROL_SIZE}px`,
+ padding: '0',
+ borderStyle: 'none',
+ borderRadius: '6px',
+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorTextSecondary },
+ opacity: { 'default': null, ':disabled': 0.45 },
+ verticalAlign: 'top',
+ // `:disabled` has to win over `:hover`, so it is nested under it.
+ backgroundColor: {
+ 'default': 'transparent',
+ ':hover': { 'default': cssVar.colorFillTertiary, ':disabled': 'transparent' },
+ },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: 'color 0.2s, background 0.2s',
+ },
+ policyCheck: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '16px',
+ height: '16px',
+ color: cssVar.colorInfo,
+ },
+ policyItem: {
+ cursor: { 'default': 'pointer', ':disabled': 'not-allowed' },
+ display: 'flex',
+ gap: '10px',
+ alignItems: 'center',
+ width: '100%',
+ minHeight: '36px',
+ paddingBlock: '8px',
+ paddingInline: '10px',
+ borderStyle: 'none',
+ borderRadius: '6px',
+ fontSize: '14px',
+ lineHeight: '20px',
+ color: cssVar.colorText,
+ opacity: { 'default': null, ':disabled': 0.45 },
+ // `:disabled` has to win over `:hover`, so it is nested under it.
+ backgroundColor: {
+ 'default': 'transparent',
+ ':hover': { 'default': cssVar.colorFillTertiary, ':disabled': 'transparent' },
+ },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ transition: `background 150ms ${cssVar.motionEaseOut}`,
+ },
+ policyItemIcon: {
+ display: 'flex',
+ flex: 'none',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '16px',
+ height: '16px',
+ },
+ policyPanel: {
+ minWidth: '132px',
+ padding: '4px',
+ borderRadius: cssVar.borderRadius,
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ boxShadow: '0 0 15px 0 #00000008, 0 2px 30px 0 #00000014',
+ },
+ // Capability rows (memory / web search) host their own settings under the
+ // activation policy, so the panel takes the width those settings had as
+ // standalone popovers instead of the compact 132px policy list.
+ policyPanelWide: { width: '320px' },
+ policyText: { flex: '1', textAlign: 'start' },
+ switchWrap: { display: 'inline-flex', flex: 'none', alignItems: 'center' },
+ toolLabel: {
+ display: 'flex',
+ flex: '1',
+ gap: `${SKILL_ICON_GAP}px`,
+ alignItems: 'center',
+ minWidth: '0',
+ },
+ toolLabelBody: {
+ overflow: 'hidden',
+ display: 'flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: '0',
+ },
+ toolLabelText: {
+ overflow: 'hidden',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ minWidth: '0',
+ lineHeight: 1.4,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ // Hover / focus-within on the row (the default marker) reveals the trailing controls.
+ toolRow: {
+ display: 'flex',
+ gap: '16px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ width: '100%',
+ minWidth: '0',
+ },
+ toolTrailing: {
+ pointerEvents: {
+ 'default': 'none',
+ '@media (hover: none)': 'auto',
+ [stylex.when.ancestor(':hover')]: 'auto',
+ [stylex.when.ancestor(':focus-within')]: 'auto',
+ },
+ display: 'inline-flex',
+ flex: 'none',
+ gap: '8px',
+ alignItems: 'center',
+ opacity: {
+ 'default': 0,
+ '@media (hover: none)': 1,
+ [stylex.when.ancestor(':hover')]: 1,
+ [stylex.when.ancestor(':focus-within')]: 1,
+ },
+ transition: `opacity 150ms ${cssVar.motionEaseOut}`,
+ },
+ toolTrailingVisible: { pointerEvents: 'auto', opacity: 1 },
+ typeTag: {
+ display: 'inline-flex',
+ flex: 'none',
+ alignItems: 'center',
+ paddingBlock: '1px',
+ paddingInline: '4px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '4px',
+ color: cssVar.colorTextTertiary,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+});
diff --git a/src/features/ChatInput/ActionBar/Tools/useControls.tsx b/src/features/ChatInput/ActionBar/Tools/useControls.tsx
index 8304bfe2b77..94ab25f5f19 100644
--- a/src/features/ChatInput/ActionBar/Tools/useControls.tsx
+++ b/src/features/ChatInput/ActionBar/Tools/useControls.tsx
@@ -6,9 +6,6 @@ import type { ItemType } from '@lobehub/ui';
import {
Avatar,
confirmModal,
- createStaticStyles,
- cssVar,
- cx,
Icon,
Popover,
SearchBar,
@@ -18,6 +15,7 @@ import {
Tooltip,
} from '@lobehub/ui';
import { McpIcon, SkillsIcon } from '@lobehub/ui/icons';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import {
BadgeCheck,
@@ -75,7 +73,7 @@ import {
} from './capabilityTools';
import ComposioServerItem from './ComposioServerItem';
import ComposioSkillIcon from './ComposioSkillIcon';
-import { SKILL_ICON_GAP, SKILL_ICON_SIZE, SKILL_TRAILING_CONTROL_SIZE } from './constants';
+import { SKILL_ICON_SIZE } from './constants';
import LobehubSkillIcon from './LobehubSkillIcon';
import LobehubSkillServerItem from './LobehubSkillServerItem';
import MarketAgentSkillPopoverContent from './MarketAgentSkillPopoverContent';
@@ -83,6 +81,7 @@ import MarketSkillIcon from './MarketSkillIcon';
import SkillRow from './SkillRow';
import ToolItem from './ToolItem';
import ToolItemDetailPopover from './ToolItemDetailPopover';
+import { styles } from './useControls.styles';
const officialTag = (
<Tooltip placement={'top'} title={'LobeHub'}>
@@ -146,360 +145,6 @@ type SkillMenuItem = NonNullable<ItemType> & {
searchText?: string;
};
-const styles = createStaticStyles(({ css }) => ({
- activationGroupHeader: css`
- cursor: pointer;
-
- display: flex;
- gap: 12px;
- align-items: center;
- justify-content: space-between;
-
- width: 100%;
- min-width: 0;
- padding-block: 4px;
- `,
- activationGroupChevron: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- width: ${SKILL_TRAILING_CONTROL_SIZE}px;
- height: ${SKILL_TRAILING_CONTROL_SIZE}px;
-
- color: ${cssVar.colorTextTertiary};
- `,
- activationGroupTitle: css`
- display: flex;
- gap: 7px;
- align-items: center;
-
- min-width: 0;
- min-height: 18px;
- `,
- activationGroupTitleBlock: css`
- display: flex;
- gap: ${SKILL_ICON_GAP}px;
- align-items: center;
- min-width: 0;
- `,
- activationGroupIcon: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- width: ${SKILL_ICON_SIZE}px;
- `,
- activationGroupTitleBody: css`
- display: flex;
- flex: 0 1 auto;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- `,
- activationGroupTitleText: css`
- overflow: hidden;
-
- min-width: 0;
-
- font-size: 14px;
- font-weight: 500;
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- text-transform: none;
- white-space: nowrap;
- `,
- count: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
- `,
- activationGroupActions: css`
- display: flex;
- flex: none;
- gap: 8px;
- align-items: center;
- `,
- switchWrap: css`
- display: inline-flex;
- flex: none;
- align-items: center;
- `,
- iconAuto: css`
- color: ${cssVar.colorInfo};
- `,
- iconDefault: css`
- color: ${cssVar.colorTextTertiary};
- `,
- iconDisabled: css`
- color: ${cssVar.colorError};
- `,
- iconPinned: css`
- color: ${cssVar.colorInfo};
- `,
- policyButton: css`
- cursor: pointer;
-
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- /* Connector rows hand this button to the menu's extra slot, a plain block
- wrapper — without vertical-align its strut adds descender space below the
- button and pushes those rows taller than the rest. */
- width: ${SKILL_TRAILING_CONTROL_SIZE}px;
- height: ${SKILL_TRAILING_CONTROL_SIZE}px;
- padding: 0;
- border: 0;
- border-radius: 6px;
-
- color: ${cssVar.colorTextTertiary};
- vertical-align: top;
-
- background: transparent;
-
- transition:
- color 0.2s,
- background 0.2s;
-
- &:hover {
- color: ${cssVar.colorTextSecondary};
- background: ${cssVar.colorFillTertiary};
- }
-
- &:disabled {
- cursor: not-allowed;
- opacity: 0.45;
- background: transparent;
- }
- `,
- deleteButton: css`
- cursor: pointer;
-
- display: flex;
- gap: 10px;
- align-items: center;
-
- width: 100%;
- min-height: 36px;
- padding-block: 8px;
- padding-inline: 10px;
- border: 0;
- border-radius: 6px;
-
- font-size: 14px;
- line-height: 20px;
- color: ${cssVar.colorError};
-
- background: transparent;
-
- transition: background 150ms ${cssVar.motionEaseOut};
-
- &:hover {
- background: ${cssVar.colorErrorBg};
- }
-
- &:disabled {
- cursor: not-allowed;
- opacity: 0.45;
- background: transparent;
- }
- `,
- deleteDivider: css`
- height: 1px;
- margin-block: 2px;
- margin-inline: 4px;
- background: ${cssVar.colorBorderSecondary};
- `,
- deleteIcon: css`
- color: ${cssVar.colorError};
- `,
- policyCheck: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- width: 16px;
- height: 16px;
-
- color: ${cssVar.colorInfo};
- `,
- policyItem: css`
- cursor: pointer;
-
- display: flex;
- gap: 10px;
- align-items: center;
-
- width: 100%;
- min-height: 36px;
- padding-block: 8px;
- padding-inline: 10px;
- border: 0;
- border-radius: 6px;
-
- font-size: 14px;
- line-height: 20px;
- color: ${cssVar.colorText};
-
- background: transparent;
-
- transition: background 150ms ${cssVar.motionEaseOut};
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
-
- &:disabled {
- cursor: not-allowed;
- opacity: 0.45;
- background: transparent;
- }
- `,
- policyItemIcon: css`
- display: flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- width: 16px;
- height: 16px;
- `,
- policyPanel: css`
- min-width: 132px;
- padding: 4px;
- border-radius: ${cssVar.borderRadius};
-
- background: ${cssVar.colorBgElevated};
- box-shadow:
- 0 0 15px 0 #00000008,
- 0 2px 30px 0 #00000014;
- `,
- /* Capability rows (memory / web search) host their own settings under the
- activation policy, so the panel takes the width those settings had as
- standalone popovers instead of the compact 132px policy list. */
- policyPanelWide: css`
- width: 320px;
- `,
- policyText: css`
- flex: 1;
- text-align: start;
- `,
- toolLabel: css`
- display: flex;
- flex: 1;
- gap: ${SKILL_ICON_GAP}px;
- align-items: center;
-
- min-width: 0;
- `,
- toolLabelBody: css`
- overflow: hidden;
- display: flex;
- flex: 0 1 auto;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- `,
- toolLabelText: css`
- overflow: hidden;
- flex: 0 1 auto;
-
- min-width: 0;
-
- line-height: 1.4;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- toolRow: css`
- display: flex;
- gap: 16px;
- align-items: center;
- justify-content: space-between;
-
- width: 100%;
- min-width: 0;
-
- &:hover [data-tool-trailing],
- &:focus-within [data-tool-trailing] {
- pointer-events: auto;
- opacity: 1;
- }
- `,
- toolTrailing: css`
- pointer-events: none;
-
- display: inline-flex;
- flex: none;
- gap: 8px;
- align-items: center;
-
- opacity: 0;
-
- transition: opacity 150ms ${cssVar.motionEaseOut};
-
- @media (hover: none) {
- pointer-events: auto;
- opacity: 1;
- }
- `,
- toolTrailingVisible: css`
- pointer-events: auto;
- opacity: 1;
- `,
- typeTag: css`
- display: inline-flex;
- flex: none;
- align-items: center;
-
- padding-block: 1px;
- padding-inline: 4px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 4px;
-
- color: ${cssVar.colorTextTertiary};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- addSkillRow: css`
- display: flex;
- gap: ${SKILL_ICON_GAP}px;
- align-items: center;
-
- width: calc(100% + 24px);
- min-height: 32px;
- margin-inline: -12px;
- padding-inline: 12px;
- border: 0;
- border-radius: 6px;
-
- font-size: 14px;
- color: ${cssVar.colorText};
-
- background: transparent;
-
- transition: background 150ms ${cssVar.motionEaseOut};
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
-
- /* The footer adds 8px block padding; cancel it on the last action row so the
- bottom row sits flush against the popup edge instead of leaving a gap. */
- &:last-child {
- margin-block-end: -8px;
- }
- `,
- addSkillLabel: css`
- flex: 1;
- text-align: start;
- `,
-}));
-
export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } = {}) => {
const { t } = useTranslation('setting');
const agentId = useAgentId();
@@ -645,11 +290,11 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
(checkedSet.has(id) ? 'pinned' : disabledIdSet.has(id) ? 'disabled' : defaultMode);
const renderCheck = (value: SkillPolicyMode) =>
mode === value ? (
- <span className={cx(styles.policyCheck)}>
+ <span {...stylex.props(styles.policyCheck)}>
<Icon icon={Check} size={14} />
</span>
) : (
- <span className={cx(styles.policyCheck)} />
+ <span {...stylex.props(styles.policyCheck)} />
);
// Right-click / "..." menu is an action list (Pin / Auto / Disable), not a
@@ -663,7 +308,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
const renderPolicyItem = (value: SkillPolicyMode, icon: ReactNode) => (
<button
- className={cx(styles.policyItem)}
+ {...stylex.props(styles.policyItem)}
disabled={!canEdit}
type="button"
onClick={async (event) => {
@@ -673,15 +318,15 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
await updateSkillPolicy(id, value);
}}
>
- <span className={cx(styles.policyItemIcon)}>{icon}</span>
- <span className={cx(styles.policyText)}>{t(policyActionKey[value])}</span>
+ <span {...stylex.props(styles.policyItemIcon)}>{icon}</span>
+ <span {...stylex.props(styles.policyText)}>{t(policyActionKey[value])}</span>
{renderCheck(value)}
</button>
);
const content = (
<div
- className={cx(styles.policyPanel, Boolean(panelExtra) && styles.policyPanelWide)}
+ {...stylex.props(styles.policyPanel, Boolean(panelExtra) && styles.policyPanelWide)}
onClick={(event) => event.stopPropagation()}
onContextMenu={(event) => event.stopPropagation()}
>
@@ -690,9 +335,11 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
renderPolicyItem(
'pinned',
<Icon
- className={cx(mode === 'pinned' ? styles.iconPinned : styles.iconDefault)}
icon={Pin}
size={15}
+ className={
+ stylex.props(mode === 'pinned' ? styles.iconPinned : styles.iconDefault).className
+ }
/>,
)}
{!deleteOnly &&
@@ -700,9 +347,11 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
renderPolicyItem(
'auto',
<Icon
- className={cx(mode === 'auto' ? styles.iconAuto : styles.iconDefault)}
icon={Zap}
size={15}
+ className={
+ stylex.props(mode === 'auto' ? styles.iconAuto : styles.iconDefault).className
+ }
/>,
)}
{!deleteOnly &&
@@ -710,17 +359,20 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
renderPolicyItem(
'disabled',
<Icon
- className={cx(mode === 'disabled' ? styles.iconDisabled : styles.iconDefault)}
icon={Ban}
size={15}
+ className={
+ stylex.props(mode === 'disabled' ? styles.iconDisabled : styles.iconDefault)
+ .className
+ }
/>,
)}
{!deleteOnly && (configureConfig || deleteConfig) && (
- <div className={cx(styles.deleteDivider)} />
+ <div {...stylex.props(styles.deleteDivider)} />
)}
{configureConfig && (
<button
- className={cx(styles.policyItem)}
+ {...stylex.props(styles.policyItem)}
disabled={!canEdit}
type="button"
onClick={(event) => {
@@ -730,15 +382,15 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
configureConfig.onConfigure();
}}
>
- <span className={cx(styles.policyItemIcon)}>
+ <span {...stylex.props(styles.policyItemIcon)}>
<Icon icon={Wrench} size={15} />
</span>
- <span className={cx(styles.policyText)}>{t('tools.builtins.configure')}</span>
+ <span {...stylex.props(styles.policyText)}>{t('tools.builtins.configure')}</span>
</button>
)}
{deleteConfig && (
<button
- className={cx(styles.deleteButton)}
+ {...stylex.props(styles.deleteButton)}
disabled={!canEdit}
type="button"
onClick={(event) => {
@@ -759,10 +411,14 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
});
}}
>
- <span className={cx(styles.policyItemIcon)}>
- <Icon className={cx(styles.deleteIcon)} icon={Trash2} size={15} />
+ <span {...stylex.props(styles.policyItemIcon)}>
+ <Icon
+ className={stylex.props(styles.deleteIcon).className}
+ icon={Trash2}
+ size={15}
+ />
</span>
- <span className={cx(styles.policyText)}>{t('tools.builtins.uninstall')}</span>
+ <span {...stylex.props(styles.policyText)}>{t('tools.builtins.uninstall')}</span>
</button>
)}
{panelExtra}
@@ -782,7 +438,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
>
<button
aria-label={t('tools.skillActivateMode.title')}
- className={cx(styles.policyButton)}
+ {...stylex.props(styles.policyButton)}
disabled={!canEdit}
type="button"
onPointerEnter={closeToolDetailPopovers}
@@ -819,29 +475,29 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
detailContent?: ReactNode,
) => (
<SkillRow
- className={cx(styles.toolRow)}
+ className={stylex.props(styles.toolRow, stylex.defaultMarker()).className}
detailContent={detailContent}
detailDisabled={policyOpenId !== null}
- labelClassName={cx(styles.toolLabel)}
+ labelClassName={stylex.props(styles.toolLabel).className}
label={
<>
{icon}
- <span className={cx(styles.toolLabelBody)}>
- <span className={cx(styles.toolLabelText)}>{label}</span>
+ <span {...stylex.props(styles.toolLabelBody)}>
+ <span {...stylex.props(styles.toolLabelText)}>{label}</span>
{extraTag}
</span>
</>
}
trailing={
<>
- {badge && <span className={cx(styles.typeTag)}>{badge}</span>}
+ {badge && <span {...stylex.props(styles.typeTag)}>{badge}</span>}
{action}
</>
}
- trailingClassName={cx(
- styles.toolTrailing,
- policyOpenId === id && styles.toolTrailingVisible,
- )}
+ trailingClassName={
+ stylex.props(styles.toolTrailing, policyOpenId === id && styles.toolTrailingVisible)
+ .className
+ }
onContextMenu={() => openSkillPolicyMenu(id)}
/>
),
@@ -1769,7 +1425,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
}) => (
<div
data-skill-activation-group
- className={cx(styles.activationGroupHeader)}
+ {...stylex.props(styles.activationGroupHeader)}
role="button"
tabIndex={0}
onClick={(event) => {
@@ -1777,17 +1433,17 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
onToggle();
}}
>
- <div className={cx(styles.activationGroupTitleBlock)}>
- <span className={cx(styles.activationGroupIcon)}>{icon}</span>
- <span className={cx(styles.activationGroupTitleBody)}>
- <span className={cx(styles.activationGroupTitleText)}>{title}</span>
- {typeof count === 'number' && <span className={cx(styles.count)}>{count}</span>}
+ <div {...stylex.props(styles.activationGroupTitleBlock)}>
+ <span {...stylex.props(styles.activationGroupIcon)}>{icon}</span>
+ <span {...stylex.props(styles.activationGroupTitleBody)}>
+ <span {...stylex.props(styles.activationGroupTitleText)}>{title}</span>
+ {typeof count === 'number' && <span {...stylex.props(styles.count)}>{count}</span>}
</span>
</div>
- <div className={cx(styles.activationGroupActions)}>
+ <div {...stylex.props(styles.activationGroupActions)}>
{autoSwitch && (
<span
- className={cx(styles.switchWrap)}
+ {...stylex.props(styles.switchWrap)}
onClick={(event) => {
event.stopPropagation();
}}
@@ -1813,7 +1469,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
/>
</span>
)}
- <div className={cx(styles.activationGroupChevron)}>
+ <div {...stylex.props(styles.activationGroupChevron)}>
<Icon icon={open ? ChevronDown : ChevronRight} size={13} />
</div>
</div>
@@ -1840,7 +1496,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
<>
<button
aria-label={t('plus.addSkills', { ns: 'chat' })}
- className={cx(styles.addSkillRow)}
+ {...stylex.props(styles.addSkillRow)}
type="button"
onClick={(event) => {
event.stopPropagation();
@@ -1849,11 +1505,11 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
}}
>
<Icon icon={Store} size={SKILL_ICON_SIZE} />
- <span className={cx(styles.addSkillLabel)}>{t('plus.addSkills', { ns: 'chat' })}</span>
+ <span {...stylex.props(styles.addSkillLabel)}>{t('plus.addSkills', { ns: 'chat' })}</span>
</button>
<button
aria-label={t('tools.plugins.management')}
- className={cx(styles.addSkillRow)}
+ {...stylex.props(styles.addSkillRow)}
type="button"
onClick={(event) => {
event.stopPropagation();
@@ -1862,7 +1518,7 @@ export const useControls = ({ closeDropdown }: { closeDropdown?: () => void } =
}}
>
<Icon icon={Settings} size={SKILL_ICON_SIZE} />
- <span className={cx(styles.addSkillLabel)}>{t('tools.plugins.management')}</span>
+ <span {...stylex.props(styles.addSkillLabel)}>{t('tools.plugins.management')}</span>
</button>
</>
) : undefined;
diff --git a/src/features/ChatInput/ActionBar/Upload/index.tsx b/src/features/ChatInput/ActionBar/Upload/index.tsx
index 94e6da11d4c..f47899366f4 100644
--- a/src/features/ChatInput/ActionBar/Upload/index.tsx
+++ b/src/features/ChatInput/ActionBar/Upload/index.tsx
@@ -1,5 +1,6 @@
import { validateVideoFileSize } from '@lobechat/utils/client';
-import { css, cx, Icon, toast, Tooltip, Upload } from '@lobehub/ui';
+import { Icon, toast, Tooltip, Upload } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { FileUp, FolderUp, ImageUp, Paperclip } from 'lucide-react';
import { memo, Suspense, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -20,14 +21,16 @@ import { type ActionDropdownMenuItems } from '../components/ActionDropdown';
import { ChatInputAction } from '../components/ChatInputAction';
import { MENU_ICON_SIZE, useKnowledgeMenuItems } from './useKnowledgeMenuItems';
-const hotArea = css`
- &::before {
- content: '';
- position: absolute;
- inset: 0;
- background-color: transparent;
- }
-`;
+const styles = stylex.create({
+ hotArea: {
+ '::before': {
+ content: '""',
+ position: 'absolute',
+ inset: 0,
+ backgroundColor: 'transparent',
+ },
+ },
+});
interface FileUploadProps {
includeKnowledge?: boolean;
@@ -102,11 +105,11 @@ const FileUpload = memo<FileUploadProps>(({ includeKnowledge = true }) => {
await upload(files, agentId);
}}
>
- <div className={cx(hotArea)}>{t('upload.action.imageUpload')}</div>
+ <div {...stylex.props(styles.hotArea)}>{t('upload.action.imageUpload')}</div>
</Upload>
) : (
<Tooltip placement={'right'} title={t('upload.action.imageDisabled')}>
- <div className={cx(hotArea)}>{t('upload.action.imageUpload')}</div>
+ <div {...stylex.props(styles.hotArea)}>{t('upload.action.imageUpload')}</div>
</Tooltip>
),
},
@@ -145,7 +148,7 @@ const FileUpload = memo<FileUploadProps>(({ includeKnowledge = true }) => {
if (filesToUpload.length > 0) await upload(filesToUpload, agentId);
}}
>
- <div className={cx(hotArea)}>{t('upload.action.fileUpload')}</div>
+ <div {...stylex.props(styles.hotArea)}>{t('upload.action.fileUpload')}</div>
</Upload>
),
},
@@ -185,7 +188,7 @@ const FileUpload = memo<FileUploadProps>(({ includeKnowledge = true }) => {
if (filesToUpload.length > 0) await upload(filesToUpload, agentId);
}}
>
- <div className={cx(hotArea)}>{t('upload.action.folderUpload')}</div>
+ <div {...stylex.props(styles.hotArea)}>{t('upload.action.folderUpload')}</div>
</Upload>
),
},
diff --git a/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx b/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx
index 6008b20c82a..ab20b99f0ad 100644
--- a/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx
+++ b/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx
@@ -9,9 +9,9 @@ import {
type PopoverTrigger,
} from '@lobehub/ui';
import {
+ // oxlint-disable-next-line stylex-migration/no-emotion-styles -- global rules for every open menu's submenu parts, which have no slot
createGlobalStyle,
- createStaticStyles,
- cssVar,
+ cssVar as cssVarValue,
cx,
DropdownMenuPopup,
DropdownMenuPortal,
@@ -20,6 +20,8 @@ import {
DropdownMenuTrigger,
renderDropdownMenuItems,
} from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { type CSSProperties, type ReactNode } from 'react';
import {
isValidElement,
@@ -37,18 +39,16 @@ import { useIsMobile } from '@/hooks/useIsMobile';
import { type MenuOpenChangeDetails, shouldVetoMenuClose } from './menuCloseVeto';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- trigger: css`
- outline: none;
-
- /* Keyboard users still need a landmark for where Enter will land. */
- &:focus-visible {
- border-radius: ${cssVar.borderRadius};
- outline: 2px solid ${cssVar.colorPrimary};
- outline-offset: 2px;
- }
- `,
-}));
+const styles = stylex.create({
+ trigger: {
+ // Keyboard users still need a landmark for where Enter will land.
+ outlineStyle: { 'default': 'none', ':focus-visible': 'solid' },
+ borderRadius: { 'default': null, ':focus-visible': cssVar.borderRadius },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineColor: { 'default': null, ':focus-visible': cssVar.colorPrimary },
+ outlineOffset: { 'default': null, ':focus-visible': '2px' },
+ },
+});
const SubmenuScrollStyle = createGlobalStyle`
/* base-ui DropdownMenu.Item reserves an indicator slot (empty aria-hidden
@@ -101,7 +101,7 @@ const SubmenuScrollStyle = createGlobalStyle`
/* Align base-ui separator color with the stats-footer's border-block-start
(colorBorderSecondary) so all dividers in the menu look consistent. */
[data-submenu] > [role='menu'] [role='separator'] {
- background: ${cssVar.colorBorderSecondary};
+ background: ${cssVarValue.colorBorderSecondary};
}
/* base-ui group label is rendered inside a [role='presentation'] with its
@@ -128,13 +128,6 @@ const SubmenuScrollStyle = createGlobalStyle`
Skills / Web Search / Attachments rows mark their extra icon with .lobe-submenu-chevron)
render that chevron themselves; hide base-ui's default triangle submenu arrow
— always the last child of the trigger's content — so the two don't stack. */
- .lobe-submenu-chevron {
- display: flex;
- align-items: center;
- justify-content: center;
- line-height: 1;
- }
-
[role='menuitem']:has(.lobe-submenu-chevron) > * > *:last-child {
display: none;
}
@@ -444,7 +437,10 @@ const ActionDropdown = memo<ActionDropdownProps>(
onOpenChange={handleOpenChange}
onOpenChangeComplete={handleOpenChangeComplete}
>
- <DropdownMenuTrigger className={styles.trigger} {...resolvedTriggerProps}>
+ <DropdownMenuTrigger
+ className={stylex.props(styles.trigger).className}
+ {...resolvedTriggerProps}
+ >
{children}
</DropdownMenuTrigger>
<DropdownMenuPortal container={resolvedPortalContainer} {...restPortalProps}>
diff --git a/src/features/ChatInput/ActionBar/components/ActionPopover.tsx b/src/features/ChatInput/ActionBar/components/ActionPopover.tsx
index ad4b29e5f23..84182073be8 100644
--- a/src/features/ChatInput/ActionBar/components/ActionPopover.tsx
+++ b/src/features/ChatInput/ActionBar/components/ActionPopover.tsx
@@ -1,28 +1,14 @@
'use client';
import { type PopoverProps } from '@lobehub/ui';
-import { createStaticStyles, cssVar, cx, Flexbox, Popover, Spin } from '@lobehub/ui';
+import { Flexbox, Popover, Spin } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import { type ReactNode } from 'react';
import { memo, Suspense } from 'react';
import DebugNode from '@/components/DebugNode';
import { useIsMobile } from '@/hooks/useIsMobile';
-const prefixCls = 'ant';
-
-const styles = createStaticStyles(({ css }) => ({
- popoverContent: css`
- .${prefixCls}-form {
- .${prefixCls}-form-item:first-child {
- padding-block: 0 4px;
- }
- .${prefixCls}-form-item:last-child {
- padding-block: 4px 0;
- }
- }
- `,
-}));
-
export interface ActionPopoverProps extends Omit<PopoverProps, 'title' | 'content' | 'children'> {
children?: ReactNode;
content?: ReactNode;
@@ -55,9 +41,7 @@ const ActionPopover = memo<ActionPopoverProps>(
const resolvedClassNames =
typeof customClassNames === 'function' ? customClassNames : customClassNames;
const contentClassName =
- typeof resolvedClassNames === 'object' && resolvedClassNames?.content
- ? cx(styles.popoverContent, resolvedClassNames.content)
- : styles.popoverContent;
+ typeof resolvedClassNames === 'object' ? resolvedClassNames?.content : undefined;
// Properly handle styles (can be object or function)
const resolvedStyles = typeof customStyles === 'function' ? customStyles : customStyles;
diff --git a/src/features/ChatInput/ActionBar/components/SubmenuChevron.tsx b/src/features/ChatInput/ActionBar/components/SubmenuChevron.tsx
new file mode 100644
index 00000000000..9c4fe739381
--- /dev/null
+++ b/src/features/ChatInput/ActionBar/components/SubmenuChevron.tsx
@@ -0,0 +1,20 @@
+import { Icon } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
+import { ChevronRight } from 'lucide-react';
+import { memo } from 'react';
+
+const styles = stylex.create({
+ root: { display: 'flex', alignItems: 'center', justifyContent: 'center', lineHeight: 1 },
+});
+
+const SubmenuChevron = memo(() => (
+ <Icon
+ className={`lobe-submenu-chevron ${stylex.props(styles.root).className}`}
+ icon={ChevronRight}
+ size={16}
+ />
+));
+
+SubmenuChevron.displayName = 'SubmenuChevron';
+
+export default SubmenuChevron;
diff --git a/src/features/ChatInput/ActionBar/index.tsx b/src/features/ChatInput/ActionBar/index.tsx
index e2ad8b9f7f1..af833fdd1d5 100644
--- a/src/features/ChatInput/ActionBar/index.tsx
+++ b/src/features/ChatInput/ActionBar/index.tsx
@@ -1,5 +1,7 @@
import { type ChatInputActionsProps } from '@lobehub/editor/react';
import { ChatInputActions } from '@lobehub/editor/react';
+import * as stylex from '@stylexjs/stylex';
+import { type StyleXStyles } from '@stylexjs/stylex';
import { memo, useMemo } from 'react';
import { useGlobalStore } from '@/store/global';
@@ -55,8 +57,12 @@ export interface ActionToolbarProps {
extraActionItems?: ChatInputActionsProps['items'];
}
-const ActionToolbar = memo<ActionToolbarProps>(
- ({ borderRadius, disableCollapse = false, dropdownPlacement, extraActionItems = [] }) => {
+interface ActionToolbarComponentProps extends ActionToolbarProps {
+ xstyle?: StyleXStyles;
+}
+
+const ActionToolbar = memo<ActionToolbarComponentProps>(
+ ({ borderRadius, disableCollapse = false, dropdownPlacement, extraActionItems = [], xstyle }) => {
const [expandInputActionbar, toggleExpandInputActionbar] = useGlobalStore((s) => [
systemStatusSelectors.expandInputActionbar(s),
s.toggleExpandInputActionbar,
@@ -88,6 +94,7 @@ const ActionToolbar = memo<ActionToolbarProps>(
<ActionBarContext value={contextValue}>
<ChatInputActions
autoCollapse={!disableCollapse}
+ className={stylex.props(xstyle).className}
collapseOffset={mobile ? 48 : 80}
defaultGroupCollapse={!disableCollapse}
groupCollapse={disableCollapse ? false : !expandInputActionbar}
diff --git a/src/features/ChatInput/ChatInputNotice/Content.tsx b/src/features/ChatInput/ChatInputNotice/Content.tsx
index 33ff05daabb..dc84becfb6c 100644
--- a/src/features/ChatInput/ChatInputNotice/Content.tsx
+++ b/src/features/ChatInput/ChatInputNotice/Content.tsx
@@ -1,17 +1,8 @@
'use client';
-import {
- Alert,
- Button,
- createStaticStyles,
- cssVar,
- cx,
- Flexbox,
- Icon,
- Popover,
- Text,
- Tooltip,
-} from '@lobehub/ui';
+import { Alert, Button, Flexbox, Icon, Popover, Text, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { AlertTriangle } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -20,61 +11,51 @@ import { useIsMobile } from '@/hooks/useIsMobile';
import type { ChatInputNotice } from './useChatInputNotice';
-const styles = createStaticStyles(({ css }) => ({
- action: css`
- flex: none;
- height: 24px;
- padding-inline: 10px;
- `,
- actionWrapper: css`
- display: inline-flex;
- `,
- alert: css`
- gap: 6px !important;
- align-items: flex-start !important;
-
- min-width: 0;
- padding-inline: 8px 10px !important;
- border-radius: ${cssVar.borderRadius};
-
- font-size: ${cssVar.fontSizeSM};
- `,
- list: css`
- overflow-y: auto;
- overscroll-behavior: contain;
- width: min(360px, calc(100vw - 32px));
- max-height: min(320px, calc(100vh - 96px));
- `,
- notice: css`
- width: 100%;
- padding-block: 6px !important;
- `,
- summary: css`
- min-width: 36px;
- height: 26px;
- padding-inline: 6px;
-
- && {
- color: ${cssVar.colorWarning};
- background: color-mix(in srgb, ${cssVar.colorWarning} 12%, ${cssVar.colorBgContainer});
- }
-
- &&:hover,
- &&:active,
- &&[data-popup-open] {
- color: ${cssVar.colorWarning};
- background: color-mix(in srgb, ${cssVar.colorWarning} 18%, ${cssVar.colorBgContainer});
- }
- `,
- title: css`
- min-width: 0;
-
- font-size: 12px;
- line-height: 18px !important;
- overflow-wrap: anywhere;
- white-space: normal;
- `,
-}));
+// The `!important`s of the emotion version are gone: lobe-ui's Alert and Button styles
+// live in a CSS layer, so these unlayered StyleX rules win without them.
+const summaryWarning = `color-mix(in srgb, ${cssVar.colorWarning} 12%, ${cssVar.colorBgContainer})`;
+const summaryWarningActive = `color-mix(in srgb, ${cssVar.colorWarning} 18%, ${cssVar.colorBgContainer})`;
+
+const styles = stylex.create({
+ action: { flex: 'none', height: '24px', paddingInline: '10px' },
+ actionWrapper: { display: 'inline-flex' },
+ alert: {
+ gap: '6px',
+ alignItems: 'flex-start',
+ minWidth: '0',
+ paddingInlineStart: '8px',
+ paddingInlineEnd: '10px',
+ borderRadius: cssVar.borderRadius,
+ fontSize: cssVar.fontSizeSM,
+ },
+ list: {
+ overflowY: 'auto',
+ overscrollBehavior: 'contain',
+ width: 'min(360px, calc(100vw - 32px))',
+ maxHeight: 'min(320px, calc(100vh - 96px))',
+ },
+ notice: { width: '100%', paddingBlock: '6px' },
+ summary: {
+ minWidth: '36px',
+ height: '26px',
+ paddingInline: '6px',
+ color: cssVar.colorWarning,
+ backgroundColor: {
+ 'default': summaryWarning,
+ ':hover': summaryWarningActive,
+ ':active': summaryWarningActive,
+ ':is([data-popup-open])': summaryWarningActive,
+ },
+ backgroundImage: 'none',
+ },
+ title: {
+ minWidth: '0',
+ fontSize: '12px',
+ lineHeight: '18px',
+ overflowWrap: 'anywhere',
+ whiteSpace: 'normal',
+ },
+});
const popoverStyles = { content: { padding: 8 } } as const;
@@ -87,7 +68,7 @@ const NoticeAlert = ({ notice }: NoticeAlertProps) => {
const enableButton = notice.action === 'enableModel' && (
<Button
- className={styles.action}
+ className={stylex.props(styles.action).className}
disabled={notice.actionDisabled}
loading={notice.actionLoading}
size={'small'}
@@ -101,7 +82,7 @@ const NoticeAlert = ({ notice }: NoticeAlertProps) => {
const action =
enableButton && notice.actionDisabled ? (
<Tooltip title={notice.actionDisabledReason}>
- <span className={styles.actionWrapper}>{enableButton}</span>
+ <span {...stylex.props(styles.actionWrapper)}>{enableButton}</span>
</Tooltip>
) : (
enableButton
@@ -114,8 +95,8 @@ const NoticeAlert = ({ notice }: NoticeAlertProps) => {
type={notice.type}
variant={'borderless'}
classNames={{
- alert: cx(styles.alert, styles.notice),
- title: styles.title,
+ alert: stylex.props(styles.alert, styles.notice).className,
+ title: stylex.props(styles.title).className,
}}
/>
);
@@ -151,7 +132,7 @@ export const ChatInputNoticeContent = memo(({ notices }: { notices: ChatInputNot
styles={popoverStyles}
trigger={isMobile ? 'click' : ['hover', 'click']}
content={
- <Flexbox className={styles.list} gap={8}>
+ <Flexbox className={stylex.props(styles.list).className} gap={8}>
<Text fontSize={12} type={'secondary'} weight={500}>
{summary}
</Text>
@@ -163,7 +144,7 @@ export const ChatInputNoticeContent = memo(({ notices }: { notices: ChatInputNot
>
<Button
aria-label={summary}
- className={styles.summary}
+ className={stylex.props(styles.summary).className}
icon={<Icon icon={AlertTriangle} size={14} />}
size={'small'}
type={'text'}
diff --git a/src/features/ChatInput/Desktop/ContextContainer/ContextItem/Content.tsx b/src/features/ChatInput/Desktop/ContextContainer/ContextItem/Content.tsx
index e3d90cf8a51..db4876c53ff 100644
--- a/src/features/ChatInput/Desktop/ContextContainer/ContextItem/Content.tsx
+++ b/src/features/ChatInput/Desktop/ContextContainer/ContextItem/Content.tsx
@@ -1,52 +1,42 @@
-import { createStaticStyles, Image } from '@lobehub/ui';
+import { Image } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import FileIcon from '@/components/FileIcon';
import { type UploadFileItem } from '@/types/files/upload';
-const styles = createStaticStyles(({ css }) => ({
- image: css`
- width: 100%;
- height: 100%;
- margin-block: 0 !important;
- border-radius: 2px;
-
- box-shadow: none;
-
- img {
- width: 100%;
- height: 100%;
- border-radius: 2px;
- object-fit: cover;
- }
- `,
- imageRoot: css`
- border-radius: 2px;
- `,
- video: css`
- overflow: hidden;
- width: 100%;
- height: 100%;
- border-radius: 2px;
- `,
-}));
+const styles = stylex.create({
+ image: { width: '100%', height: '100%', borderRadius: '2px', objectFit: 'cover' },
+ imageRoot: { borderRadius: '2px' },
+ imageWrapper: {
+ width: '100%',
+ height: '100%',
+ marginBlock: '0',
+ borderRadius: '2px',
+ boxShadow: 'none',
+ },
+ video: { overflow: 'hidden', width: '100%', height: '100%', borderRadius: '2px' },
+});
const Content = memo<UploadFileItem>(({ file, previewUrl }) => {
if (file.type.startsWith('image')) {
return (
<Image
alt={file.name}
- className={styles.imageRoot}
- classNames={{ wrapper: styles.image }}
+ className={stylex.props(styles.imageRoot).className}
height={20}
src={previewUrl}
width={20}
+ classNames={{
+ image: stylex.props(styles.image).className,
+ wrapper: stylex.props(styles.imageWrapper).className,
+ }}
/>
);
}
if (file.type.startsWith('video')) {
- return <video className={styles.video} src={previewUrl} />;
+ return <video {...stylex.props(styles.video)} src={previewUrl} />;
}
return <FileIcon fileName={file.name} fileType={file.type} size={16} />;
diff --git a/src/features/ChatInput/Desktop/ContextContainer/ContextItem/index.tsx b/src/features/ChatInput/Desktop/ContextContainer/ContextItem/index.tsx
index ee320ee8b62..a35ac5c64e0 100644
--- a/src/features/ChatInput/Desktop/ContextContainer/ContextItem/index.tsx
+++ b/src/features/ChatInput/Desktop/ContextContainer/ContextItem/index.tsx
@@ -1,13 +1,6 @@
-import {
- ActionIcon,
- createStaticStyles,
- cssVar,
- Flexbox,
- Icon,
- Progress,
- Tag,
- Tooltip,
-} from '@lobehub/ui';
+import { ActionIcon, Flexbox, Icon, Progress, Tag, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { CircleAlertIcon, CircleCheckIcon, Loader2Icon, RotateCwIcon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -24,60 +17,36 @@ import { openFilePreviewModal } from './FilePreviewModal.loader';
import { useUploadCompletion } from './useUploadCompletion';
import { getFileBasename, getUploadChipSize, getUploadChipState } from './utils';
-const styles = createStaticStyles(({ css }) => ({
- chip: css`
- max-width: 100%;
- height: 28px;
- `,
- content: css`
- display: flex;
- gap: 4px;
- align-items: center;
-
- min-width: 0;
- max-width: 380px;
- `,
- size: css`
- flex-shrink: 0;
-
- font-variant-numeric: tabular-nums;
- line-height: 18px;
- color: ${cssVar.colorTextTertiary};
- white-space: nowrap;
- `,
- thumbnail: css`
- flex-shrink: 0;
- width: 20px;
- height: 20px;
- line-height: 0;
- `,
- statusIcon: css`
- display: flex;
- flex-shrink: 0;
- align-items: center;
- justify-content: center;
-
- width: 12px;
- height: 12px;
-
- line-height: 0;
- `,
- // Tooltips are unselectable by default; the error carries the request id a
- // user copies into a support report.
- errorText: css`
- user-select: text;
- `,
- name: css`
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
-
- line-height: 18px;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
+const styles = stylex.create({
+ chip: { maxWidth: '100%', height: '28px' },
+ content: { display: 'flex', gap: '4px', alignItems: 'center', minWidth: '0', maxWidth: '380px' },
+ size: {
+ flexShrink: 0,
+ fontVariantNumeric: 'tabular-nums',
+ lineHeight: '18px',
+ color: cssVar.colorTextTertiary,
+ whiteSpace: 'nowrap',
+ },
+ thumbnail: { flexShrink: 0, width: '20px', height: '20px', lineHeight: 0 },
+ statusIcon: {
+ display: 'flex',
+ flexShrink: 0,
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '12px',
+ height: '12px',
+ lineHeight: 0,
+ },
+ errorText: { userSelect: 'text' },
+ name: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: '0',
+ lineHeight: '18px',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+});
type FileItemProps = UploadFileItem;
@@ -107,7 +76,7 @@ const ContextItem = memo<FileItemProps>((props) => {
<Flexbox align={'center'} justify={'center'} style={{ height: '1lh' }}>
<Icon icon={CircleAlertIcon} size={12} />
</Flexbox>
- <span className={styles.errorText}>{error}</span>
+ <span {...stylex.props(styles.errorText)}>{error}</span>
</Flexbox>
) : (
<UploadDetail size={file.size} status={status} tasks={tasks} uploadState={uploadState} />
@@ -119,19 +88,19 @@ const ContextItem = memo<FileItemProps>((props) => {
<Tag
closable
aria-busy={busy}
- className={styles.chip}
+ className={stylex.props(styles.chip).className}
size={'large'}
onClick={canPreview ? handleClick : undefined}
onClose={handleClose}
>
<Tooltip title={detail}>
- <Flexbox horizontal align={'center'} className={styles.content}>
- <Flexbox className={styles.thumbnail}>
+ <Flexbox horizontal align={'center'} className={stylex.props(styles.content).className}>
+ <Flexbox className={stylex.props(styles.thumbnail).className}>
<Content {...props} />
</Flexbox>
- <span className={styles.name}>{basename}</span>
+ <span {...stylex.props(styles.name)}>{basename}</span>
{(indicator !== 'file' || showCompletion) && (
- <Flexbox className={styles.statusIcon}>
+ <Flexbox className={stylex.props(styles.statusIcon).className}>
{showCompletion ? (
<Icon
aria-label={t('upload.preview.status.success')}
@@ -158,7 +127,7 @@ const ContextItem = memo<FileItemProps>((props) => {
aria-valuemax={100}
aria-valuemin={0}
aria-valuenow={progress}
- className={styles.statusIcon}
+ {...stylex.props(styles.statusIcon)}
role={'progressbar'}
>
<Progress
@@ -174,7 +143,7 @@ const ContextItem = memo<FileItemProps>((props) => {
)}
</Flexbox>
)}
- {sizeLabel && <span className={styles.size}>{sizeLabel}</span>}
+ {sizeLabel && <span {...stylex.props(styles.size)}>{sizeLabel}</span>}
</Flexbox>
</Tooltip>
{canRetry && (
diff --git a/src/features/ChatInput/Desktop/ContextContainer/ContextList.tsx b/src/features/ChatInput/Desktop/ContextContainer/ContextList.tsx
index 0a4ec7f0d81..081ad06324b 100644
--- a/src/features/ChatInput/Desktop/ContextContainer/ContextList.tsx
+++ b/src/features/ChatInput/Desktop/ContextContainer/ContextList.tsx
@@ -1,4 +1,5 @@
-import { createStaticStyles, Flexbox, ScrollShadow } from '@lobehub/ui';
+import { Flexbox, ScrollShadow } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useChatInputUploadKey } from '@/features/ChatInput/hooks/useChatInputUpload';
@@ -9,12 +10,7 @@ import ContextItem from './ContextItem';
import ElementItem from './ElementItem';
import SelectionItem from './SelectionItem';
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- overflow-x: scroll;
- width: 100%;
- `,
-}));
+const styles = stylex.create({ container: { overflowX: 'scroll', width: '100%' } });
const ContextList = memo(() => {
const contextSelectionKey = useChatInputStore((s) => s.contextSelectionKey);
@@ -42,7 +38,7 @@ const ContextList = memo(() => {
<ScrollShadow
hideScrollBar
horizontal
- className={styles.container}
+ className={stylex.props(styles.container).className}
orientation={'horizontal'}
size={8}
>
diff --git a/src/features/ChatInput/Desktop/ContextContainer/ElementItem.tsx b/src/features/ChatInput/Desktop/ContextContainer/ElementItem.tsx
index 740cb469192..9c2910c7d73 100644
--- a/src/features/ChatInput/Desktop/ContextContainer/ElementItem.tsx
+++ b/src/features/ChatInput/Desktop/ContextContainer/ElementItem.tsx
@@ -1,63 +1,55 @@
import type { ChatContextContent } from '@lobechat/types';
-import { createStaticStyles, cssVar, Tag, Tooltip } from '@lobehub/ui';
+import { Tag, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { SquareDashedMousePointer } from 'lucide-react';
import { memo } from 'react';
import { useChatInputStore } from '@/features/ChatInput/store';
import { useFileStore } from '@/store/file';
-const styles = createStaticStyles(({ css }) => ({
- name: css`
- overflow: hidden;
- max-width: 200px;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- selector: css`
- overflow: hidden;
-
- max-width: min(420px, 70vw);
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- tagBadge: css`
- padding-block: 0;
- padding-inline: 4px;
- border-radius: 4px;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillSecondary};
- `,
- thumbnail: css`
- display: block;
-
- max-width: min(420px, 70vw);
- max-height: 240px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: 6px;
-
- object-fit: contain;
- background: ${cssVar.colorBgContainer};
- `,
- tooltip: css`
- max-width: min(460px, 75vw);
- `,
- url: css`
- overflow: hidden;
-
- font-size: 12px;
- color: ${cssVar.colorTextQuaternary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
+const styles = stylex.create({
+ name: { overflow: 'hidden', maxWidth: '200px', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
+ selector: {
+ overflow: 'hidden',
+ maxWidth: 'min(420px, 70vw)',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ tagBadge: {
+ paddingBlock: '0',
+ paddingInline: '4px',
+ borderRadius: '4px',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ thumbnail: {
+ display: 'block',
+ maxWidth: 'min(420px, 70vw)',
+ maxHeight: '240px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: '6px',
+ objectFit: 'contain',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ tooltip: { maxWidth: 'min(460px, 75vw)' },
+ url: {
+ overflow: 'hidden',
+ fontSize: '12px',
+ color: cssVar.colorTextQuaternary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+});
/**
* The chip for a DOM element picked from the in-app browser. Unlike a plain
@@ -70,17 +62,17 @@ const ElementItem = memo<ChatContextContent>(({ element, id, preview }) => {
if (!element) return null;
const tooltip = (
- <div className={styles.tooltip}>
+ <div {...stylex.props(styles.tooltip)}>
{element.thumbnailUrl && (
<img
alt={element.selector || element.tag}
- className={styles.thumbnail}
+ {...stylex.props(styles.thumbnail)}
src={element.thumbnailUrl}
/>
)}
- <div className={styles.selector}>{element.selector || `<${element.tag}>`}</div>
+ <div {...stylex.props(styles.selector)}>{element.selector || `<${element.tag}>`}</div>
{(element.pageTitle || element.url) && (
- <div className={styles.url}>{element.pageTitle || element.url}</div>
+ <div {...stylex.props(styles.url)}>{element.pageTitle || element.url}</div>
)}
</div>
);
@@ -96,8 +88,8 @@ const ElementItem = memo<ChatContextContent>(({ element, id, preview }) => {
>
<Tooltip title={tooltip}>
<span>
- <span className={styles.tagBadge}>{`<${element.tag}>`}</span>{' '}
- <span className={styles.name}>{preview}</span>
+ <span {...stylex.props(styles.tagBadge)}>{`<${element.tag}>`}</span>{' '}
+ <span {...stylex.props(styles.name)}>{preview}</span>
</span>
</Tooltip>
</Tag>
diff --git a/src/features/ChatInput/Desktop/ContextContainer/SelectionItem.tsx b/src/features/ChatInput/Desktop/ContextContainer/SelectionItem.tsx
index 901c76edff4..3df83106810 100644
--- a/src/features/ChatInput/Desktop/ContextContainer/SelectionItem.tsx
+++ b/src/features/ChatInput/Desktop/ContextContainer/SelectionItem.tsx
@@ -1,76 +1,57 @@
import type { ChatContextContent } from '@lobechat/types';
-import { createStaticStyles, cssVar, Tag, Tooltip } from '@lobehub/ui';
+import { Tag, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { Code2Icon, TextIcon } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useChatInputStore } from '@/features/ChatInput/store';
import { useFileStore } from '@/store/file';
-const styles = createStaticStyles(({ css }) => ({
- codeLine: css`
- display: grid;
- grid-template-columns: 36px minmax(0, 1fr);
- gap: 10px;
- `,
- codePreview: css`
- overflow: auto;
-
- max-width: min(560px, 80vw);
- max-height: 220px;
- margin: 0;
- padding-block: 8px;
- padding-inline: 0;
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- line-height: 1.55;
- `,
- content: css`
- overflow: hidden;
-
- min-width: 0;
-
- color: ${cssVar.colorText};
- text-overflow: ellipsis;
- white-space: pre;
- `,
- lineNumber: css`
- user-select: none;
- color: ${cssVar.colorTextQuaternary};
- text-align: end;
- `,
- meta: css`
- overflow: hidden;
-
- max-width: min(560px, 80vw);
- padding-block-end: 6px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- name: css`
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
-
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- textPreview: css`
- max-width: min(420px, 70vw);
- color: ${cssVar.colorText};
- white-space: pre-wrap;
- `,
- truncated: css`
- padding-block-start: 4px;
- color: ${cssVar.colorTextQuaternary};
- `,
-}));
+const styles = stylex.create({
+ codeLine: { display: 'grid', gridTemplateColumns: '36px minmax(0, 1fr)', gap: '10px' },
+ codePreview: {
+ overflow: 'auto',
+ maxWidth: 'min(560px, 80vw)',
+ maxHeight: '220px',
+ margin: '0',
+ paddingBlock: '8px',
+ paddingInline: '0',
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ lineHeight: 1.55,
+ },
+ content: {
+ overflow: 'hidden',
+ minWidth: '0',
+ color: cssVar.colorText,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'pre',
+ },
+ lineNumber: { userSelect: 'none', color: cssVar.colorTextQuaternary, textAlign: 'end' },
+ meta: {
+ overflow: 'hidden',
+ maxWidth: 'min(560px, 80vw)',
+ paddingBlockEnd: '6px',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: cssVar.colorBorderSecondary,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ name: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: '0',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ textPreview: { maxWidth: 'min(420px, 70vw)', color: cssVar.colorText, whiteSpace: 'pre-wrap' },
+ truncated: { paddingBlockStart: '4px', color: cssVar.colorTextQuaternary },
+});
const MAX_PREVIEW_LENGTH = 8;
const MAX_CODE_PREVIEW_LINES = 8;
@@ -115,7 +96,7 @@ const SelectionItem = memo<ChatContextContent>(
const tooltip = useMemo(() => {
if (!isCodeSelection) {
- return <div className={styles.textPreview}>{preview || content}</div>;
+ return <div {...stylex.props(styles.textPreview)}>{preview || content}</div>;
}
const lines = content.split('\n');
@@ -124,20 +105,20 @@ const SelectionItem = memo<ChatContextContent>(
return (
<div>
- <div className={styles.meta}>
+ <div {...stylex.props(styles.meta)}>
{getLocationText({ filePath, lineRange, title }) || preview || title}
</div>
- <pre className={styles.codePreview}>
+ <pre {...stylex.props(styles.codePreview)}>
{previewLines.map((line, index) => (
- <div className={styles.codeLine} key={`${index}-${line}`}>
- <span className={styles.lineNumber}>{startLine + index}</span>
- <code className={styles.content}>{line || ' '}</code>
+ <div {...stylex.props(styles.codeLine)} key={`${index}-${line}`}>
+ <span {...stylex.props(styles.lineNumber)}>{startLine + index}</span>
+ <code {...stylex.props(styles.content)}>{line || ' '}</code>
</div>
))}
{lines.length > MAX_CODE_PREVIEW_LINES && (
- <div className={`${styles.codeLine} ${styles.truncated}`}>
- <span className={styles.lineNumber}>...</span>
- <code className={styles.content}>...</code>
+ <div {...stylex.props(styles.codeLine, styles.truncated)}>
+ <span {...stylex.props(styles.lineNumber)}>...</span>
+ <code {...stylex.props(styles.content)}>...</code>
</div>
)}
</pre>
@@ -155,7 +136,7 @@ const SelectionItem = memo<ChatContextContent>(
}}
>
<Tooltip title={tooltip}>
- <span className={styles.name}>{displayText}</span>
+ <span {...stylex.props(styles.name)}>{displayText}</span>
</Tooltip>
</Tag>
);
diff --git a/src/features/ChatInput/Desktop/index.tsx b/src/features/ChatInput/Desktop/index.tsx
index 717e7451f85..e2ec7e80e37 100644
--- a/src/features/ChatInput/Desktop/index.tsx
+++ b/src/features/ChatInput/Desktop/index.tsx
@@ -2,7 +2,10 @@
import { type ChatInputProps } from '@lobehub/editor/react';
import { ChatInput, ChatInputActionBar } from '@lobehub/editor/react';
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- leftContent is an arbitrary ReactNode
import { Center, createStaticStyles, cx, Flexbox, Skeleton, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo, type ReactNode, use, useEffect } from 'react';
import { createPortal } from 'react-dom';
import { useTranslation } from 'react-i18next';
@@ -27,53 +30,40 @@ import { type PlaceholderVariant } from '../InputEditor/Placeholder';
import { useDocumentDrop } from '../InputEditor/ReferDocument/useDocumentDrop';
import { useTopicDrop } from '../InputEditor/ReferTopic/useTopicDrop';
import { useWorkspaceFileDrop } from '../InputEditor/useWorkspaceFileDrop';
+import { composerHoverMarker } from '../markers.stylex';
import SendArea from '../SendArea';
import TypoBar from '../TypoBar';
import ContextContainer from './ContextContainer';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- container: css`
- .show-on-hover {
- opacity: 0;
- }
-
- &:hover {
- .show-on-hover {
- opacity: 1;
- }
- }
- `,
- footnote: css`
- font-size: 10px;
- `,
- fullscreen: css`
- position: absolute;
- z-index: 100;
- inset: 0;
-
- width: 100%;
- height: 100%;
- margin-block-start: 0;
+const styles = stylex.create({
+ footnote: { fontSize: '10px' },
+ fullscreen: {
+ position: 'absolute',
+ zIndex: 100,
+ inset: 0,
+ width: '100%',
+ height: '100%',
+ marginBlockStart: '0',
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ },
+ inputFullscreen: {
+ borderStyle: 'none',
+ borderStartStartRadius: '0 !important',
+ borderStartEndRadius: '0 !important',
+ borderEndStartRadius: '0 !important',
+ borderEndEndRadius: '0 !important',
+ },
+ leftActions: { flex: 'none', minWidth: '0' },
+ leftSlot: { overflow: 'hidden', flex: '1', minWidth: '0' },
+});
- background: ${cssVar.colorBgContainer};
- `,
- inputFullscreen: css`
- border: none;
- border-radius: 0 !important;
- `,
+const fallback = createStaticStyles(({ css }) => ({
leftActions: css`
- flex: none;
- min-width: 0;
-
> * {
flex: none !important;
}
`,
- leftSlot: css`
- overflow: hidden;
- flex: 1;
- min-width: 0;
- `,
}));
interface DesktopChatInputProps extends ActionToolbarProps {
@@ -205,7 +195,11 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
// does not create a false gap after the microphone action.
const leftSlotContent = (
<Flexbox horizontal align={'center'} flex={'none'} gap={2}>
- <Flexbox horizontal align={'center'} className={styles.leftActions}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={cx(stylex.props(styles.leftActions).className, fallback.leftActions)}
+ >
{leftContent ?? (
<ActionBar
disableCollapse
@@ -220,7 +214,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
</Flexbox>
);
const leftSlot = noticeNode ? (
- <Flexbox horizontal align={'center'} className={styles.leftSlot}>
+ <Flexbox horizontal align={'center'} className={stylex.props(styles.leftSlot).className}>
{leftSlotContent}
</Flexbox>
) : (
@@ -229,7 +223,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
const content = (
<Flexbox
- className={cx(styles.container, expand && styles.fullscreen)}
+ className={stylex.props(composerHoverMarker, expand && styles.fullscreen).className}
gap={8}
paddingBlock={expand ? 0 : showFootnote ? '0 12px' : '0 8px'}
style={{ display: hidden ? 'none' : undefined }}
@@ -275,7 +269,10 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
updateSystemStatus({ chatInputHeight: height });
}}
{...inputContainerProps}
- className={cx(expand && styles.inputFullscreen, inputContainerProps?.className)}
+ className={cx(
+ stylex.props(expand && styles.inputFullscreen).className,
+ inputContainerProps?.className,
+ )}
>
<InputEditor
initialContent={initialContent}
@@ -286,7 +283,7 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
{controlBarSlot ?? (showControlBar && <ControlBar />)}
{showFootnote && !expand && (
<Center style={{ pointerEvents: 'none', zIndex: 100 }}>
- <Text className={styles.footnote} type={'secondary'}>
+ <Text className={stylex.props(styles.footnote).className} type={'secondary'}>
{t('input.disclaimer')}
</Text>
</Center>
diff --git a/src/features/ChatInput/Dictation/index.tsx b/src/features/ChatInput/Dictation/index.tsx
index 4f12b84d344..fbf163d91a2 100644
--- a/src/features/ChatInput/Dictation/index.tsx
+++ b/src/features/ChatInput/Dictation/index.tsx
@@ -1,6 +1,8 @@
'use client';
-import { createStaticStyles, Spin, Tooltip } from '@lobehub/ui';
+import { Spin, Tooltip } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { Mic, RotateCcw, X } from 'lucide-react';
import type { MouseEvent } from 'react';
import { memo, useCallback, useEffect } from 'react';
@@ -16,86 +18,66 @@ import { useDictationControlFocus } from './useDictationControlFocus';
import { useDictationPrefetch } from './useDictationPrefetch';
import { useRealtimeDictation } from './useRealtimeDictation';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- cancel: css`
- color: ${cssVar.colorTextSecondary};
- `,
- controlRow: css`
- display: flex;
- flex: none;
- gap: 4px;
- align-items: center;
- `,
- controls: css`
- display: flex;
- flex: none;
- gap: 4px;
- align-items: center;
-
- padding: 2px;
- border-radius: 9999px;
-
- background: ${cssVar.colorFillSecondary};
- `,
- listening: css`
- transition:
- color 160ms ease,
- background 160ms ease,
- transform 120ms ease;
-
- && {
- color: contrast-color(${cssVar.colorPrimary});
- background: ${cssVar.colorPrimary};
- }
-
- &&:hover {
- color: contrast-color(${cssVar.colorPrimaryHover});
- background: ${cssVar.colorPrimaryHover};
- }
-
- &&:active {
- transform: scale(0.94);
- color: contrast-color(${cssVar.colorPrimaryActive});
- background: ${cssVar.colorPrimaryActive};
- }
-
- &&:focus-visible {
- outline: 2px solid currentcolor;
- outline-offset: -3px;
- box-shadow: none;
- }
-
- @media (prefers-reduced-motion: reduce) {
- transition: none;
- }
- `,
- listeningStatus: css`
- position: absolute;
-
- overflow: hidden;
-
- width: 1px;
- height: 1px;
- margin: -1px;
- padding: 0;
- border: 0;
-
- white-space: nowrap;
-
- clip: rect(0, 0, 0, 0);
- `,
- status: css`
- overflow: hidden;
-
- max-width: 160px;
- padding-inline: 6px 2px;
-
- font-size: ${cssVar.fontSizeSM};
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
+const styles = stylex.create({
+ cancel: { color: cssVar.colorTextSecondary },
+ controlRow: { display: 'flex', flex: 'none', gap: '4px', alignItems: 'center' },
+ controls: {
+ display: 'flex',
+ flex: 'none',
+ gap: '4px',
+ alignItems: 'center',
+ padding: '2px',
+ borderRadius: '9999px',
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ // The emotion version stacked `&&` to outrank the action button's own colors; the
+ // button's lobe-ui styles are layered, so plain StyleX rules win without it.
+ listening: {
+ color: {
+ 'default': `contrast-color(${cssVar.colorPrimary})`,
+ ':hover': `contrast-color(${cssVar.colorPrimaryHover})`,
+ ':active': `contrast-color(${cssVar.colorPrimaryActive})`,
+ },
+ backgroundColor: {
+ 'default': cssVar.colorPrimary,
+ ':hover': cssVar.colorPrimaryHover,
+ ':active': cssVar.colorPrimaryActive,
+ },
+ backgroundImage: { 'default': 'none', ':hover': 'none', ':active': 'none' },
+ transform: { 'default': null, ':active': 'scale(0.94)' },
+ transition: {
+ 'default': 'color 160ms ease, background 160ms ease, transform 120ms ease',
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
+ outlineStyle: { 'default': null, ':focus-visible': 'solid' },
+ outlineWidth: { 'default': null, ':focus-visible': '2px' },
+ outlineColor: { 'default': null, ':focus-visible': 'currentcolor' },
+ outlineOffset: { 'default': null, ':focus-visible': '-3px' },
+ boxShadow: { 'default': null, ':focus-visible': 'none' },
+ },
+ listeningStatus: {
+ position: 'absolute',
+ overflow: 'hidden',
+ width: '1px',
+ height: '1px',
+ margin: '-1px',
+ padding: '0',
+ borderStyle: 'none',
+ whiteSpace: 'nowrap',
+ clip: 'rect(0, 0, 0, 0)',
+ },
+ status: {
+ overflow: 'hidden',
+ maxWidth: '160px',
+ paddingInlineStart: '6px',
+ paddingInlineEnd: '2px',
+ fontSize: cssVar.fontSizeSM,
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+});
const Dictation = memo(() => {
const { t } = useTranslation('chat');
@@ -249,17 +231,17 @@ const Dictation = memo(() => {
return (
<div
aria-label={t('voiceDictation.statusLabel')}
- className={styles.controlRow}
+ {...stylex.props(styles.controlRow)}
data-status="listening"
data-testid="voice-dictation-controls"
role="group"
>
- <span aria-live="polite" className={styles.listeningStatus} role="status">
+ <span aria-live="polite" {...stylex.props(styles.listeningStatus)} role="status">
{statusText}
</span>
<ChatInputAction
aria-label={t('voiceDictation.stop')}
- className={styles.listening}
+ className={stylex.props(styles.listening).className}
data-testid="voice-dictation-stop"
icon={Mic}
ref={stopRef}
@@ -274,7 +256,7 @@ const Dictation = memo(() => {
/>
<ChatInputAction
aria-label={t('voiceDictation.cancel')}
- className={styles.cancel}
+ className={stylex.props(styles.cancel).className}
data-testid="voice-dictation-cancel"
icon={X}
ref={cancelRef}
@@ -293,13 +275,13 @@ const Dictation = memo(() => {
return (
<div
aria-label={t('voiceDictation.statusLabel')}
- className={styles.controlRow}
+ {...stylex.props(styles.controlRow)}
data-status={status}
data-testid="voice-dictation-controls"
role="group"
>
- <div className={styles.controls}>
- <span aria-live="polite" className={styles.status} role="status">
+ <div {...stylex.props(styles.controls)}>
+ <span aria-live="polite" {...stylex.props(styles.status)} role="status">
{statusText}
</span>
{status === 'error' && retryable ? (
@@ -319,7 +301,7 @@ const Dictation = memo(() => {
</div>
<ChatInputAction
aria-label={status === 'error' ? t('voiceDictation.dismiss') : t('voiceDictation.cancel')}
- className={styles.cancel}
+ className={stylex.props(styles.cancel).className}
data-testid="voice-dictation-cancel"
icon={X}
ref={cancelRef}
diff --git a/src/features/ChatInput/InputEditor/ActionTag/ActionMention.tsx b/src/features/ChatInput/InputEditor/ActionTag/ActionMention.tsx
index a3b90f3a2e0..c196b526feb 100644
--- a/src/features/ChatInput/InputEditor/ActionTag/ActionMention.tsx
+++ b/src/features/ChatInput/InputEditor/ActionTag/ActionMention.tsx
@@ -1,5 +1,6 @@
-import { cx, Flexbox, Icon, Tooltip } from '@lobehub/ui';
+import { Flexbox, Icon, Tooltip } from '@lobehub/ui';
import { SkillsIcon } from '@lobehub/ui/icons';
+import * as stylex from '@stylexjs/stylex';
import { TargetIcon, TerminalIcon, WrenchIcon } from 'lucide-react';
import type { FC, MouseEvent } from 'react';
import { memo } from 'react';
@@ -105,11 +106,15 @@ export const ActionMention = memo<ActionMentionProps>(
}
>
<span
- className={cx(styles.actionTag, styles[styleKey], isClickable && styles.clickable)}
onClick={handleClick}
+ {...stylex.props(styles.actionTag, styles[styleKey], isClickable && styles.clickable)}
>
- <Icon className={styles.actionTagIcon} icon={IconComponent} size={14} />
- <span className={styles.actionTagLabel}>{label}</span>
+ <Icon
+ className={stylex.props(styles.actionTagIcon).className}
+ icon={IconComponent}
+ size={14}
+ />
+ <span {...stylex.props(styles.actionTagLabel)}>{label}</span>
</span>
</Tooltip>
);
diff --git a/src/features/ChatInput/InputEditor/ActionTag/style.ts b/src/features/ChatInput/InputEditor/ActionTag/style.ts
index e000a6e6482..2f14625abe0 100644
--- a/src/features/ChatInput/InputEditor/ActionTag/style.ts
+++ b/src/features/ChatInput/InputEditor/ActionTag/style.ts
@@ -1,59 +1,70 @@
-import { createStaticStyles } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
-import { TAG_MARGIN_INLINE_END } from '../constants';
+// `.selected` is added by the editor's selection observer, not by React, so it is matched
+// as a same-element class.
+const SELECTED = ':is(.selected)';
-const colored = (color: string, borderRadius: string) => `
- color: ${color};
-
- &.selected {
- border-radius: ${borderRadius};
- outline: 2px solid ${color};
- outline-offset: 1px;
- }
-`;
-
-export const styles = createStaticStyles(({ css, cssVar }) => ({
- actionTag: css`
- cursor: default;
- user-select: none;
-
- display: inline-flex;
- gap: 4px;
+export const styles = stylex.create({
+ actionTag: {
+ cursor: 'default',
+ userSelect: 'none',
+ display: 'inline-flex',
+ gap: '4px',
/* The label sets the tag's baseline, so it sits on the surrounding text's
baseline; an icon-first inline-flex would take the SVG's bottom edge. */
- align-items: baseline;
-
- margin-inline-end: ${TAG_MARGIN_INLINE_END}px;
- padding-inline: 2px;
- `,
- actionTagIcon: css`
- align-self: center;
- `,
- actionTagLabel: css`
- font-weight: 500;
- `,
- agentSkillTag: css`
- ${colored(cssVar.colorSuccess, cssVar.borderRadius)}
- `,
- clickable: css`
- cursor: pointer;
- border-radius: ${cssVar.borderRadius};
- transition: background 0.2s;
-
- &:hover {
- background: ${cssVar.colorFillTertiary};
- }
- `,
- commandTag: css`
- ${colored(cssVar.purple, cssVar.borderRadius)}
- `,
- projectSkillTag: css`
- ${colored(cssVar.colorSuccess, cssVar.borderRadius)}
- `,
- skillTag: css`
- ${colored(cssVar.colorSuccess, cssVar.borderRadius)}
- `,
- toolTag: css`
- ${colored(cssVar.colorInfo, cssVar.borderRadius)}
- `,
-}));
+ alignItems: 'baseline',
+ // TAG_MARGIN_INLINE_END (../constants) — StyleX cannot fold an imported constant.
+ marginInlineEnd: '4px',
+ paddingInline: '2px',
+ },
+ actionTagIcon: { alignSelf: 'center' },
+ actionTagLabel: { fontWeight: 500 },
+ agentSkillTag: {
+ color: cssVar.colorSuccess,
+ borderRadius: { default: null, [SELECTED]: cssVar.borderRadius },
+ outlineStyle: { default: null, [SELECTED]: 'solid' },
+ outlineWidth: { default: null, [SELECTED]: '2px' },
+ outlineColor: { default: null, [SELECTED]: cssVar.colorSuccess },
+ outlineOffset: { default: null, [SELECTED]: '1px' },
+ },
+ clickable: {
+ cursor: 'pointer',
+ borderRadius: cssVar.borderRadius,
+ transition: 'background 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+ commandTag: {
+ color: cssVar.purple,
+ borderRadius: { default: null, [SELECTED]: cssVar.borderRadius },
+ outlineStyle: { default: null, [SELECTED]: 'solid' },
+ outlineWidth: { default: null, [SELECTED]: '2px' },
+ outlineColor: { default: null, [SELECTED]: cssVar.purple },
+ outlineOffset: { default: null, [SELECTED]: '1px' },
+ },
+ projectSkillTag: {
+ color: cssVar.colorSuccess,
+ borderRadius: { default: null, [SELECTED]: cssVar.borderRadius },
+ outlineStyle: { default: null, [SELECTED]: 'solid' },
+ outlineWidth: { default: null, [SELECTED]: '2px' },
+ outlineColor: { default: null, [SELECTED]: cssVar.colorSuccess },
+ outlineOffset: { default: null, [SELECTED]: '1px' },
+ },
+ skillTag: {
+ color: cssVar.colorSuccess,
+ borderRadius: { default: null, [SELECTED]: cssVar.borderRadius },
+ outlineStyle: { default: null, [SELECTED]: 'solid' },
+ outlineWidth: { default: null, [SELECTED]: '2px' },
+ outlineColor: { default: null, [SELECTED]: cssVar.colorSuccess },
+ outlineOffset: { default: null, [SELECTED]: '1px' },
+ },
+ toolTag: {
+ color: cssVar.colorInfo,
+ borderRadius: { default: null, [SELECTED]: cssVar.borderRadius },
+ outlineStyle: { default: null, [SELECTED]: 'solid' },
+ outlineWidth: { default: null, [SELECTED]: '2px' },
+ outlineColor: { default: null, [SELECTED]: cssVar.colorInfo },
+ outlineOffset: { default: null, [SELECTED]: '1px' },
+ },
+});
diff --git a/src/features/ChatInput/InputEditor/InputHistoryPopup.tsx b/src/features/ChatInput/InputEditor/InputHistoryPopup.tsx
index 3896f97c0b2..39da0367c0f 100644
--- a/src/features/ChatInput/InputEditor/InputHistoryPopup.tsx
+++ b/src/features/ChatInput/InputEditor/InputHistoryPopup.tsx
@@ -1,48 +1,46 @@
-import { createStaticStyles, cx } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo, useEffect, useRef } from 'react';
import { createPortal } from 'react-dom';
import type { ChatInputHistoryEntry } from '../inputHistoryStorage';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- item: css`
- cursor: pointer;
-
- overflow: hidden;
-
- padding-block: 6px;
- padding-inline: 10px;
- border-radius: ${cssVar.borderRadius};
-
- font-size: 13px;
- line-height: 20px;
- color: ${cssVar.colorTextSecondary};
- text-overflow: ellipsis;
- white-space: nowrap;
-
- transition: background 0.1s ${cssVar.motionEaseOut};
- `,
- itemActive: css`
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
- `,
- root: css`
- position: absolute;
- z-index: 50;
- inset-block-end: calc(100% + 8px);
- inset-inline: 0;
-
- overflow-y: auto;
-
- max-height: 240px;
- padding: 4px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorBgElevated};
- box-shadow: ${cssVar.boxShadowSecondary};
- `,
-}));
+const styles = stylex.create({
+ item: {
+ cursor: 'pointer',
+ overflow: 'hidden',
+ paddingBlock: '6px',
+ paddingInline: '10px',
+ borderRadius: cssVar.borderRadius,
+ fontSize: '13px',
+ lineHeight: '20px',
+ color: cssVar.colorTextSecondary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ transition: `background 0.1s ${cssVar.motionEaseOut}`,
+ },
+ itemActive: {
+ color: cssVar.colorText,
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ root: {
+ position: 'absolute',
+ zIndex: 50,
+ insetBlockEnd: 'calc(100% + 8px)',
+ insetInline: '0',
+ overflowY: 'auto',
+ maxHeight: '240px',
+ padding: '4px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorderSecondary,
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorBgElevated,
+ backgroundImage: 'none',
+ boxShadow: cssVar.boxShadowSecondary,
+ },
+});
/**
* Normalize a stored markdown prompt into a single-line plain-text preview for
@@ -99,12 +97,12 @@ const InputHistoryPopup = memo<InputHistoryPopupProps>(
const indices = entries.map((_, index) => index).reverse();
return createPortal(
- <div className={styles.root} ref={rootRef}>
+ <div {...stylex.props(styles.root)} ref={rootRef}>
{indices.map((index) => {
const entry = entries[index];
return (
<div
- className={cx(styles.item, index === activeIndex && styles.itemActive)}
+ {...stylex.props(styles.item, index === activeIndex && styles.itemActive)}
data-index={index}
key={`${entry.createdAt}-${index}`}
onMouseEnter={() => onHover(index)}
diff --git a/src/features/ChatInput/InputEditor/LocalFileTag/LocalFileTag.tsx b/src/features/ChatInput/InputEditor/LocalFileTag/LocalFileTag.tsx
index 7ad219b87ad..a41b35ae6e7 100644
--- a/src/features/ChatInput/InputEditor/LocalFileTag/LocalFileTag.tsx
+++ b/src/features/ChatInput/InputEditor/LocalFileTag/LocalFileTag.tsx
@@ -1,15 +1,7 @@
import { isDesktop } from '@lobechat/const';
-import {
- Button,
- createStaticStyles,
- cssVar,
- cx,
- Flexbox,
- Icon,
- Popover,
- Tag,
- Text,
-} from '@lobehub/ui';
+import { Button, cx, Flexbox, Icon, Popover, Tag, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import type { LexicalEditor } from 'lexical';
import { $createNodeSelection, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW } from 'lexical';
import { ExternalLink, EyeIcon, FolderOpen } from 'lucide-react';
@@ -28,7 +20,6 @@ import { useChatStore } from '@/store/chat';
import { topicSelectors } from '@/store/chat/selectors';
import { parseLocalFileHref } from '../../../Conversation/Markdown/plugins/LocalFileLink/parse';
-import { TAG_MARGIN_INLINE_END } from '../constants';
import { getFileExtension } from '../MentionMenu/localFileDisplay';
const PREVIEWABLE_IMAGE_EXTENSIONS = new Set([
@@ -43,99 +34,83 @@ const PREVIEWABLE_IMAGE_EXTENSIONS = new Set([
'webp',
]);
-const styles = createStaticStyles(({ css }) => ({
- actionBar: css`
- flex-wrap: wrap;
- max-width: 320px;
- `,
- label: css`
- overflow: hidden;
- align-self: baseline;
-
- min-width: 0;
-
- font-weight: 400;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- path: css`
- max-width: 360px;
- padding-block: 8px;
- padding-inline: 10px;
- border-radius: ${cssVar.borderRadius};
-
- font-family: ${cssVar.fontFamilyCode};
- font-size: 12px;
- line-height: 1.5;
- color: ${cssVar.colorTextSecondary};
- word-break: break-all;
-
- background: ${cssVar.colorFillQuaternary};
- `,
- popover: css`
- max-width: 392px;
- `,
- previewFrame: css`
- overflow: hidden;
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: min(360px, 72vw);
- max-height: 240px;
- border: 1px solid ${cssVar.colorFillSecondary};
- border-radius: ${cssVar.borderRadiusLG};
-
- background: ${cssVar.colorFillQuaternary};
- `,
- previewImage: css`
- display: block;
- max-width: 100%;
- max-height: 240px;
- object-fit: contain;
- `,
- tag: css`
- cursor: default;
- user-select: none;
-
- display: inline-flex;
- gap: 6px;
- align-items: center;
-
- box-sizing: border-box;
- max-width: min(240px, 100%);
- height: 24px;
- margin-inline-end: ${TAG_MARGIN_INLINE_END}px;
- padding-block: 2px;
- padding-inline: 8px;
- border-radius: ${cssVar.borderRadius};
-
- font-size: inherit;
- line-height: 20px;
- color: ${cssVar.colorTextSecondary};
- vertical-align: baseline;
-
- &:hover {
- background: ${cssVar.colorFillSecondary};
- }
-
- &.selected {
- outline: 2px solid ${cssVar.colorInfo};
- outline-offset: 1px;
- }
- `,
- thumbnail: css`
- flex-shrink: 0;
-
- width: 16px;
- height: 16px;
- border-radius: ${cssVar.borderRadiusXS};
-
- object-fit: cover;
- background: ${cssVar.colorFillQuaternary};
- box-shadow: inset 0 0 0 1px ${cssVar.colorFillSecondary};
- `,
-}));
+const styles = stylex.create({
+ actionBar: { flexWrap: 'wrap', maxWidth: '320px' },
+ label: {
+ overflow: 'hidden',
+ alignSelf: 'baseline',
+ minWidth: '0',
+ fontWeight: 400,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ path: {
+ maxWidth: '360px',
+ paddingBlock: '8px',
+ paddingInline: '10px',
+ borderRadius: cssVar.borderRadius,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: '12px',
+ lineHeight: 1.5,
+ color: cssVar.colorTextSecondary,
+ wordBreak: 'break-all',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ popover: { maxWidth: '392px' },
+ previewFrame: {
+ overflow: 'hidden',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: 'min(360px, 72vw)',
+ maxHeight: '240px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorFillSecondary,
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ },
+ previewImage: { display: 'block', maxWidth: '100%', maxHeight: '240px', objectFit: 'contain' },
+ // `.selected` is added by the editor's selection observer, so it is matched as a
+ // same-element class.
+ tag: {
+ cursor: 'default',
+ userSelect: 'none',
+ display: 'inline-flex',
+ gap: '6px',
+ alignItems: 'center',
+ boxSizing: 'border-box',
+ maxWidth: 'min(240px, 100%)',
+ height: '24px',
+ // TAG_MARGIN_INLINE_END (../constants) — StyleX cannot fold an imported constant.
+ marginInlineEnd: '4px',
+ paddingBlock: '2px',
+ paddingInline: '8px',
+ borderRadius: cssVar.borderRadius,
+ fontSize: 'inherit',
+ lineHeight: '20px',
+ color: cssVar.colorTextSecondary,
+ verticalAlign: 'baseline',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ outlineStyle: { 'default': null, ':is(.selected)': 'solid' },
+ outlineWidth: { 'default': null, ':is(.selected)': '2px' },
+ outlineColor: { 'default': null, ':is(.selected)': cssVar.colorInfo },
+ outlineOffset: { 'default': null, ':is(.selected)': '1px' },
+ },
+ thumbnail: {
+ flexShrink: 0,
+ width: '16px',
+ height: '16px',
+ borderRadius: cssVar.borderRadiusXS,
+ objectFit: 'cover',
+ backgroundColor: cssVar.colorFillQuaternary,
+ backgroundImage: 'none',
+ boxShadow: `inset 0 0 0 1px ${cssVar.colorFillSecondary}`,
+ },
+});
export interface LocalFileTagData {
isDirectory?: boolean;
@@ -216,7 +191,12 @@ const LocalFileTagTrigger = memo<LocalFileTagTriggerProps>(
}, [editor, nodeKey, onClick]);
return (
- <Tag {...rest} className={cx(styles.tag, className)} ref={setSpanRef} title={title}>
+ <Tag
+ {...rest}
+ className={cx(stylex.props(styles.tag).className, className)}
+ ref={setSpanRef}
+ title={title}
+ >
{children}
</Tag>
);
@@ -311,21 +291,25 @@ export const LocalFileTag = memo<LocalFileTagProps>(({ className, editor, file,
);
const content = (
- <Flexbox className={styles.popover} gap={10} onClick={(event) => event.stopPropagation()}>
+ <Flexbox
+ className={stylex.props(styles.popover).className}
+ gap={10}
+ onClick={(event) => event.stopPropagation()}
+ >
{imageSrc && (
- <div className={styles.previewFrame}>
+ <div {...stylex.props(styles.previewFrame)}>
<img
alt={file.name}
- className={styles.previewImage}
+ {...stylex.props(styles.previewImage)}
data-testid="local-file-image-hover-preview"
draggable={false}
src={imageSrc}
/>
</div>
)}
- <Text className={styles.path}>{file.path}</Text>
+ <Text className={stylex.props(styles.path).className}>{file.path}</Text>
{(isDesktop || canPreview) && (
- <Flexbox horizontal className={styles.actionBar} gap={6}>
+ <Flexbox horizontal className={stylex.props(styles.actionBar).className} gap={6}>
{canPreview && (
<Button icon={<Icon icon={EyeIcon} />} size={'small'} onClick={handlePreview}>
{t('workingPanel.documents.preview')}
@@ -358,7 +342,7 @@ export const LocalFileTag = memo<LocalFileTagProps>(({ className, editor, file,
{imageSrc ? (
<img
alt=""
- className={styles.thumbnail}
+ {...stylex.props(styles.thumbnail)}
data-testid="local-file-image-preview"
draggable={false}
src={imageSrc}
@@ -371,7 +355,7 @@ export const LocalFileTag = memo<LocalFileTagProps>(({ className, editor, file,
variant={'raw'}
/>
)}
- <span className={styles.label}>{file.name}</span>
+ <span {...stylex.props(styles.label)}>{file.name}</span>
</LocalFileTagTrigger>
</Popover>
);
diff --git a/src/features/ChatInput/InputEditor/index.tsx b/src/features/ChatInput/InputEditor/index.tsx
index 99da5955ea7..c1abd5ee332 100644
--- a/src/features/ChatInput/InputEditor/index.tsx
+++ b/src/features/ChatInput/InputEditor/index.tsx
@@ -11,7 +11,9 @@ import { isCommandPressed } from '@lobechat/utils';
import type { IEditor, ISlashMenuOption, ISlashSectionOption } from '@lobehub/editor';
import { INSERT_MENTION_COMMAND, ReactAutoCompletePlugin } from '@lobehub/editor';
import { Editor, useEditorState } from '@lobehub/editor/react';
-import { combineKeys, css, cx } from '@lobehub/ui';
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- Lexical editor paragraphs take no className
+import { combineKeys, createStaticStyles, cx } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import Fuse from 'fuse.js';
import { KEY_ESCAPE_COMMAND } from 'lexical';
import { memo, type ReactNode, useCallback, useEffect, useMemo, useRef } from 'react';
@@ -72,23 +74,21 @@ import { INSERT_REFER_TOPIC_COMMAND } from './ReferTopic';
import { useLocalFileTag } from './useLocalFileTag';
import { useMentionCategories } from './useMentionCategories';
-const className = cx(
- css`
+const fallback = createStaticStyles(({ css }) => ({
+ editor: css`
p {
margin-block-end: 0;
}
`,
- mentionPlainClassName,
-);
+}));
+
+const className = cx(fallback.editor, mentionPlainClassName);
// Single-line dimmed preview of the highlighted history entry, shown through the
// editor's placeholder slot while the input is empty (history popup open).
-const ghostClassName = cx(css`
- overflow: hidden;
- display: block;
- text-overflow: ellipsis;
- white-space: nowrap;
-`);
+const ghostStyles = stylex.create({
+ root: { overflow: 'hidden', display: 'block', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
+});
type MentionOption = ISlashMenuOption | ISlashSectionOption;
@@ -633,7 +633,7 @@ const InputEditor = memo<{
/>
))
) : (
- <span className={ghostClassName}>{getHistoryPreviewText(ghostMarkdown)}</span>
+ <span {...stylex.props(ghostStyles.root)}>{getHistoryPreviewText(ghostMarkdown)}</span>
)
}
style={{
diff --git a/src/features/ChatInput/InputEditor/mentionStyle.ts b/src/features/ChatInput/InputEditor/mentionStyle.ts
index 674126558af..7975ab45838 100644
--- a/src/features/ChatInput/InputEditor/mentionStyle.ts
+++ b/src/features/ChatInput/InputEditor/mentionStyle.ts
@@ -1,19 +1,17 @@
-import { css, cx } from '@lobehub/ui';
+// oxlint-disable-next-line stylex-migration/no-emotion-styles -- @lobehub/editor mention spans take no className
+import { createStaticStyles } from '@lobehub/ui';
-// Override the default chip style from `@lobehub/editor`'s mention plugin so
-// @-mentions render as plain colored text, matching the look of other inline
-// tags (skills, tools, commands) in the chat UI.
-// The outline and fill live on the Lexical decorator span (themed `mention`
-// class), which wraps the inner `.editor_mention` span — so target the
-// wrapper. The yellow `.selected` highlight is kept so a mention picked for
-// deletion stays visible.
-export const mentionPlainClassName = cx(css`
- span:has(> .editor_mention),
- .editor_mention {
- border: none;
- }
+const fallback = createStaticStyles(({ css }) => ({
+ mentionPlain: css`
+ span:has(> .editor_mention),
+ .editor_mention {
+ border: none;
+ }
- span:has(> .editor_mention):not(.selected) {
- background: none;
- }
-`);
+ span:has(> .editor_mention):not(.selected) {
+ background: none;
+ }
+ `,
+}));
+
+export const mentionPlainClassName: string = fallback.mentionPlain;
diff --git a/src/features/ChatInput/Mobile/FilePreview/FileItem/File.tsx b/src/features/ChatInput/Mobile/FilePreview/FileItem/File.tsx
index db2ad6bce9b..11de2dbcbf3 100644
--- a/src/features/ChatInput/Mobile/FilePreview/FileItem/File.tsx
+++ b/src/features/ChatInput/Mobile/FilePreview/FileItem/File.tsx
@@ -1,4 +1,6 @@
-import { ActionIcon, createStaticStyles, cssVar, Flexbox, Text } from '@lobehub/ui';
+import { ActionIcon, Flexbox, Text } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { RotateCw, Trash } from 'lucide-react';
import { memo } from 'react';
@@ -7,37 +9,30 @@ import FileIcon from '@/components/FileIcon';
import UploadDetail from '@/features/ChatInput/components/UploadDetail';
import { type UploadFileItem } from '@/types/files';
-const styles = createStaticStyles(({ css }) => ({
- actions: css`
- position: absolute;
- inset-block-start: 0;
- inset-inline-end: 0;
- `,
- container: css`
- cursor: pointer;
-
- position: relative;
-
- overflow: hidden;
-
- width: 250px;
- height: 64px;
- padding-block: 4px;
- padding-inline: 8px 24px;
- border: 1px solid ${cssVar.colorBorder};
- border-radius: 8px;
-
- background: ${cssVar.colorFillTertiary};
- `,
- deleteButton: css`
- color: #fff;
- background: ${cssVar.colorBgMask};
-
- &:hover {
- background: ${cssVar.colorError};
- }
- `,
-}));
+const styles = stylex.create({
+ actions: { position: 'absolute', insetBlockStart: '0', insetInlineEnd: '0' },
+ container: {
+ cursor: 'pointer',
+ position: 'relative',
+ overflow: 'hidden',
+ width: '250px',
+ height: '64px',
+ paddingBlock: '4px',
+ paddingInlineStart: '8px',
+ paddingInlineEnd: '24px',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: cssVar.colorBorder,
+ borderRadius: '8px',
+ backgroundColor: cssVar.colorFillTertiary,
+ backgroundImage: 'none',
+ },
+ deleteButton: {
+ color: '#fff',
+ backgroundColor: { 'default': cssVar.colorBgMask, ':hover': cssVar.colorError },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+});
interface FileItemProps extends UploadFileItem {
onRemove?: () => void;
@@ -47,7 +42,13 @@ interface FileItemProps extends UploadFileItem {
const FileItem = memo<FileItemProps>(
({ error, errorCode, id, onRemove, onRetry, file, status, uploadState, tasks }) => {
return (
- <Flexbox horizontal align={'center'} className={styles.container} gap={12} key={id}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.container).className}
+ gap={12}
+ key={id}
+ >
<FileIcon fileName={file.name} fileType={file.type} />
<Flexbox style={{ overflow: 'hidden' }}>
<Text ellipsis>{file.name}</Text>
@@ -59,13 +60,13 @@ const FileItem = memo<FileItemProps>(
uploadState={uploadState}
/>
</Flexbox>
- <Flexbox horizontal className={styles.actions}>
+ <Flexbox horizontal className={stylex.props(styles.actions).className}>
{status === 'error' && errorCode ? (
<FileUploadErrorActions compact code={errorCode} />
) : status === 'error' ? (
<ActionIcon
glass
- className={styles.deleteButton}
+ className={stylex.props(styles.deleteButton).className}
icon={RotateCw}
size={'small'}
onClick={(e) => {
@@ -76,7 +77,7 @@ const FileItem = memo<FileItemProps>(
) : null}
<ActionIcon
glass
- className={styles.deleteButton}
+ className={stylex.props(styles.deleteButton).className}
icon={Trash}
size={'small'}
onClick={(e) => {
diff --git a/src/features/ChatInput/Mobile/FilePreview/FileItem/Image.tsx b/src/features/ChatInput/Mobile/FilePreview/FileItem/Image.tsx
index 095de93c75b..0bd9ebaf053 100644
--- a/src/features/ChatInput/Mobile/FilePreview/FileItem/Image.tsx
+++ b/src/features/ChatInput/Mobile/FilePreview/FileItem/Image.tsx
@@ -1,4 +1,6 @@
-import { ActionIcon, createStaticStyles, cssVar, cx, Flexbox, Image } from '@lobehub/ui';
+import { ActionIcon, Flexbox, Image } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { RotateCw, Trash } from 'lucide-react';
import { memo } from 'react';
@@ -6,25 +8,21 @@ import { FileUploadErrorActions } from '@/business/client/features/FileUploadErr
import { MIN_IMAGE_SIZE } from './style';
-const styles = createStaticStyles(({ css }) => ({
- deleteButton: css`
- color: #fff;
- background: ${cssVar.colorBgMask};
-
- &:hover {
- background: ${cssVar.colorError};
- }
- `,
- editableImage: css`
- background: ${cssVar.colorBgContainer};
- box-shadow: 0 0 0 1px ${cssVar.colorFill} inset;
- `,
- image: css`
- width: 64px !important;
- height: 64px !important;
- margin-block: 0 !important;
- `,
-}));
+// `image` used `!important` to beat lobe-ui's Image wrapper; that CSS is layered, so the
+// unlayered StyleX rules win without it.
+const styles = stylex.create({
+ deleteButton: {
+ color: '#fff',
+ backgroundColor: { 'default': cssVar.colorBgMask, ':hover': cssVar.colorError },
+ backgroundImage: { 'default': 'none', ':hover': 'none' },
+ },
+ editableImage: {
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ boxShadow: `0 0 0 1px ${cssVar.colorFill} inset`,
+ },
+ image: { width: '64px', height: '64px', marginBlock: '0' },
+});
interface FileItemProps {
alt?: string;
@@ -44,7 +42,7 @@ const FileItem = memo<FileItemProps>(
<Image
alwaysShowActions
alt={alt || ''}
- classNames={{ wrapper: cx(styles.image, styles.editableImage) }}
+ classNames={{ wrapper: stylex.props(styles.image, styles.editableImage).className }}
height={64}
isLoading={loading}
objectFit={'cover'}
@@ -58,7 +56,7 @@ const FileItem = memo<FileItemProps>(
) : error ? (
<ActionIcon
glass
- className={styles.deleteButton}
+ className={stylex.props(styles.deleteButton).className}
icon={RotateCw}
size={'small'}
onClick={(e) => {
@@ -69,7 +67,7 @@ const FileItem = memo<FileItemProps>(
) : null}
<ActionIcon
glass
- className={styles.deleteButton}
+ className={stylex.props(styles.deleteButton).className}
icon={Trash}
size={'small'}
onClick={(e) => {
diff --git a/src/features/ChatInput/Mobile/FilePreview/index.tsx b/src/features/ChatInput/Mobile/FilePreview/index.tsx
index a520a5b60b5..aa12ddf3b27 100644
--- a/src/features/ChatInput/Mobile/FilePreview/index.tsx
+++ b/src/features/ChatInput/Mobile/FilePreview/index.tsx
@@ -1,4 +1,5 @@
-import { createStaticStyles, Flexbox, PreviewGroup, ScrollShadow } from '@lobehub/ui';
+import { Flexbox, PreviewGroup, ScrollShadow } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
@@ -8,12 +9,7 @@ import { fileChatSelectors, useFileStore } from '@/store/file';
import FileItem from './FileItem';
-const styles = createStaticStyles(({ css }) => ({
- container: css`
- overflow-x: scroll;
- width: 100%;
- `,
-}));
+const styles = stylex.create({ container: { overflowX: 'scroll', width: '100%' } });
const FilePreview = memo(() => {
const expand = useChatInputStore((s) => s.expand);
@@ -25,7 +21,7 @@ const FilePreview = memo(() => {
<ScrollShadow
hideScrollBar
horizontal
- className={styles.container}
+ className={stylex.props(styles.container).className}
orientation={'horizontal'}
size={8}
>
diff --git a/src/features/ChatInput/Mobile/index.tsx b/src/features/ChatInput/Mobile/index.tsx
index b9e3f26b1db..6429ae981d5 100644
--- a/src/features/ChatInput/Mobile/index.tsx
+++ b/src/features/ChatInput/Mobile/index.tsx
@@ -1,7 +1,9 @@
'use client';
import { ChatInput, ChatInputActionBar } from '@lobehub/editor/react';
-import { createStaticStyles, cssVar, cx, Flexbox } from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import ChatInputNotice from '@/features/ChatInput/ChatInputNotice';
@@ -15,33 +17,21 @@ import SendArea from '../SendArea';
const FilePreview = dynamic(() => import('./FilePreview'), { ssr: false });
-const styles = createStaticStyles(({ css }) => ({
- container: css``,
- fullscreen: css`
- position: absolute;
- z-index: 100;
- inset: 0;
-
- width: 100%;
- height: 100%;
- padding: 12px;
-
- background: ${cssVar.colorBgLayout};
- `,
- leftActions: css`
- flex: none;
- min-width: 0;
-
- > * {
- flex: none !important;
- }
- `,
- leftSlot: css`
- overflow: hidden;
- flex: 1;
- min-width: 0;
- `,
-}));
+const styles = stylex.create({
+ fullscreen: {
+ position: 'absolute',
+ zIndex: 100,
+ inset: 0,
+ width: '100%',
+ height: '100%',
+ padding: '12px',
+ backgroundColor: cssVar.colorBgLayout,
+ backgroundImage: 'none',
+ },
+ leftActions: { flex: 'none', minWidth: '0' },
+ leftActionsItem: { flex: 'none' },
+ leftSlot: { overflow: 'hidden', flex: '1', minWidth: '0' },
+});
const DesktopChatInput = memo(() => {
const [slashMenuRef, expand] = useChatInputStore((s) => [s.slashMenuRef, s.expand]);
@@ -53,7 +43,7 @@ const DesktopChatInput = memo(() => {
<>
{!expand && fileNode}
<Flexbox
- className={cx(styles.container, expand && styles.fullscreen)}
+ className={stylex.props(expand && styles.fullscreen).className}
gap={8}
paddingBlock={'0 12px'}
paddingInline={12}
@@ -73,10 +63,19 @@ const DesktopChatInput = memo(() => {
header={
<ChatInputActionBar
left={
- <Flexbox horizontal align={'center'} className={styles.leftSlot} gap={4}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.leftSlot).className}
+ gap={4}
+ >
<Flexbox horizontal align={'center'} flex={'none'} gap={2}>
- <Flexbox horizontal align={'center'} className={styles.leftActions}>
- <ActionBar disableCollapse />
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={stylex.props(styles.leftActions).className}
+ >
+ <ActionBar disableCollapse xstyle={styles.leftActionsItem} />
</Flexbox>
<ComposerExpandButton />
</Flexbox>
diff --git a/src/features/ChatInput/SendArea/ExpandButton.tsx b/src/features/ChatInput/SendArea/ExpandButton.tsx
index 4472c9b036f..95d92f2b88f 100644
--- a/src/features/ChatInput/SendArea/ExpandButton.tsx
+++ b/src/features/ChatInput/SendArea/ExpandButton.tsx
@@ -1,4 +1,5 @@
import { ActionIcon } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { Maximize2Icon, Minimize2Icon } from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -6,13 +7,25 @@ import { useTranslation } from 'react-i18next';
import { useChatInputStore } from '@/features/ChatInput/store';
import { usePermission } from '@/hooks/usePermission';
+import { composerHoverMarker } from '../markers.stylex';
+
+const styles = stylex.create({
+ revealOnComposerHover: {
+ opacity: {
+ default: null,
+ [stylex.when.ancestor(':not(:hover)', composerHoverMarker)]: 0,
+ [stylex.when.ancestor(':hover', composerHoverMarker)]: 1,
+ },
+ },
+});
+
const ExpandButton = memo(() => {
const { t } = useTranslation('editor');
const [expand, setExpand, editor] = useChatInputStore((s) => [s.expand, s.setExpand, s.editor]);
const { allowed: canUseChatInputAction, reason } = usePermission('create_content');
return (
<ActionIcon
- className="show-on-hover"
+ className={stylex.props(styles.revealOnComposerHover).className}
disabled={!canUseChatInputAction}
icon={expand ? Minimize2Icon : Maximize2Icon}
size={{ blockSize: 32, size: 16, strokeWidth: 2.3 }}
diff --git a/src/features/ChatInput/VoiceMessage/index.tsx b/src/features/ChatInput/VoiceMessage/index.tsx
index 4632b325069..7836aa6d436 100644
--- a/src/features/ChatInput/VoiceMessage/index.tsx
+++ b/src/features/ChatInput/VoiceMessage/index.tsx
@@ -1,16 +1,21 @@
'use client';
import { type VoiceMessageRecording } from '@lobechat/types';
-import { createStaticStyles, Icon, Tooltip } from '@lobehub/ui';
+import { Icon, Tooltip } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { ArrowUp, type LucideProps, RotateCcw, X } from 'lucide-react';
import { memo, useCallback, useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
+import { sx } from '@/styles/sx';
+
import { ChatInputAction } from '../ActionBar/components/ChatInputAction';
import { useAgentId } from '../hooks/useAgentId';
import { useEffectiveModel } from '../hooks/useEffectiveModel';
+import { voiceSendButtonMarker } from '../markers.stylex';
import { useChatInputStore, useStoreApi } from '../store';
import { formatVoiceDuration } from './mediaRecorder';
+import { styles } from './style';
import { useIntentionalHover } from './useIntentionalHover';
import {
getVoiceMessageActionState,
@@ -46,397 +51,6 @@ const VoiceMessageIcon = ({
VoiceMessageIcon.displayName = 'VoiceMessageIcon';
-const styles = createStaticStyles(({ css, cssVar }) => ({
- bar: css`
- width: 4px;
- min-height: 4px;
- border-radius: 9999px;
-
- background: ${cssVar.colorPrimary};
-
- transition: height 80ms linear;
-
- @media (prefers-reduced-motion: reduce) {
- transition: none;
- }
- `,
- cancelButton: css`
- cursor: default;
-
- position: relative;
-
- display: inline-flex;
- flex: none;
- align-items: center;
- justify-content: center;
-
- width: 32px;
- height: 32px;
- padding: 0;
- border: 0;
- border-radius: 9999px;
-
- color: ${cssVar.colorTextSecondary};
-
- background: ${cssVar.colorFillSecondary};
-
- transition:
- color 120ms ease,
- background 120ms ease,
- transform 120ms ease;
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimary};
- outline-offset: 2px;
- }
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFill};
- }
-
- &:active {
- transform: scale(0.96);
- }
-
- @media (width <= 600px) {
- &::after {
- content: '';
- position: absolute;
- inset: -6px;
- }
- }
-
- @media (prefers-reduced-motion: reduce) {
- transition: none;
- }
- `,
- container: css`
- display: flex;
- flex: none;
- gap: 6px;
- align-items: center;
-
- width: min(300px, calc(100vw - 112px));
- min-width: min(220px, calc(100vw - 112px));
- height: 32px;
- padding-inline: 2px;
-
- animation: voice-message-enter 160ms ease-out;
-
- @media (prefers-reduced-motion: reduce) {
- animation: none;
- }
-
- @keyframes voice-message-enter {
- from {
- transform: translateX(8px);
- opacity: 0;
- }
-
- to {
- transform: translateX(0);
- opacity: 1;
- }
- }
- `,
- error: css`
- position: absolute;
- z-index: 1;
- inset-block-start: 50%;
- inset-inline: 12px 44px;
- transform: translateY(-50%);
-
- overflow: hidden;
-
- font-size: ${cssVar.fontSizeSM};
- line-height: 1.3;
- color: ${cssVar.colorError};
- text-align: center;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- pill: css`
- position: relative;
-
- overflow: hidden;
- flex: 1;
-
- min-width: 0;
- height: 100%;
- border-radius: 9999px;
-
- background: ${cssVar.colorFillSecondary};
- `,
- progress: css`
- position: absolute;
- z-index: 3;
- inset-block-end: 0;
- inset-inline: 6px;
-
- overflow: hidden;
-
- height: 2px;
- border-radius: 1px;
-
- background: ${cssVar.colorFillSecondary};
- `,
- progressValue: css`
- height: 100%;
- border-radius: inherit;
-
- opacity: 0.72;
- background: ${cssVar.colorBgContainer};
-
- transition: width 120ms linear;
-
- @media (prefers-reduced-motion: reduce) {
- transition: none;
- }
- `,
- sendArrow: css`
- position: absolute;
- z-index: 2;
- inset-block-start: 50%;
- inset-inline-end: 2px;
- transform: translateY(-50%);
-
- display: inline-flex;
- align-items: center;
- justify-content: center;
-
- width: 28px;
- height: 28px;
-
- opacity: 1;
-
- transition:
- opacity 100ms ease,
- transform 160ms ease;
-
- @media (prefers-reduced-motion: reduce) {
- transition: none;
- }
- `,
- sendButton: css`
- cursor: default;
-
- position: absolute;
- z-index: 2;
- inset: 0;
-
- overflow: hidden;
-
- width: 100%;
- padding: 0;
- border: 0;
- border-radius: inherit;
-
- color: ${cssVar.colorBgContainer};
-
- background: transparent;
-
- &::before {
- content: '';
-
- position: absolute;
- z-index: 0;
- inset: 0;
-
- border-radius: inherit;
-
- background: ${cssVar.colorPrimary};
- clip-path: circle(14px at calc(100% - 16px) 50%);
-
- transition: clip-path 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
- }
-
- &[data-error='true']::before {
- background: ${cssVar.colorError};
- }
-
- &[data-expanded='true'] {
- cursor: wait;
- color: ${cssVar.colorTextSecondary};
- background: ${cssVar.colorBgContainer};
- }
-
- &[data-expanded='true']::before {
- background: ${cssVar.colorFill};
- }
-
- &[data-hover-expanded='true']::before,
- &:focus-visible::before,
- &[data-expanded='true']::before {
- clip-path: circle(150% at calc(100% - 16px) 50%);
- }
-
- &[data-hover-expanded='true'] > span:first-child,
- &:focus-visible > span:first-child,
- &[data-expanded='true'] > span:first-child {
- transform: translateY(0);
- opacity: 1;
- }
-
- &[data-expanded='true'] > span:first-child {
- gap: 8px;
- padding-inline: 14px;
- font-size: ${cssVar.fontSizeSM};
- font-weight: normal;
- }
-
- &[data-hover-expanded='true'] > span:last-child,
- &:focus-visible > span:last-child,
- &[data-expanded='true'] > span:last-child {
- transform: translateY(-50%) translateX(6px);
- opacity: 0;
- }
-
- &[data-expanded='true'] > span:first-child > span:last-child {
- display: none;
- }
-
- &[data-expanded='true'] > span:first-child > span:nth-child(2) {
- display: none;
- }
-
- &[data-expanded='true'] > span:first-child > span:first-child > i {
- animation: voice-message-busy-dot 900ms ease-in-out infinite;
- }
-
- &[data-expanded='true'] > span:first-child > span:first-child > i:nth-child(2) {
- animation-delay: 120ms;
- }
-
- &[data-expanded='true'] > span:first-child > span:first-child > i:nth-child(3) {
- animation-delay: 240ms;
- }
-
- &[data-expanded='true'] > span:first-child > span:first-child > i:last-child {
- display: none;
- }
-
- &:focus-visible {
- outline: 2px solid ${cssVar.colorPrimary};
- outline-offset: -3px;
- }
-
- &:disabled {
- cursor: not-allowed;
- }
-
- &:disabled::before {
- opacity: 0.45;
- }
-
- &[data-expanded='true']:disabled {
- cursor: wait;
- }
-
- &[data-expanded='true']:disabled::before {
- opacity: 1;
- }
-
- @media (prefers-reduced-motion: reduce) {
- &::before {
- transition: none;
- }
-
- &[data-expanded='true'] > span:first-child > span:first-child > i {
- animation: none;
- }
- }
-
- @keyframes voice-message-busy-dot {
- 0%,
- 60%,
- 100% {
- transform: scale(0.72);
- opacity: 0.38;
- }
-
- 30% {
- transform: scale(1);
- opacity: 1;
- }
- }
- `,
- sendDots: css`
- display: inline-flex;
- gap: 3px;
- align-items: center;
-
- > i {
- width: 3px;
- height: 3px;
- border-radius: 9999px;
- background: currentcolor;
- }
- `,
- sendLabel: css`
- position: absolute;
- z-index: 2;
- inset: 0;
- transform: translateY(4px);
-
- display: flex;
- gap: 8px;
- align-items: center;
- justify-content: center;
-
- min-width: 0;
- padding-inline: 10px;
-
- font-size: ${cssVar.fontSize};
- font-weight: ${cssVar.fontWeightStrong};
- white-space: nowrap;
-
- opacity: 0;
-
- transition:
- opacity 100ms ease,
- transform 160ms ease;
-
- @media (prefers-reduced-motion: reduce) {
- transition: none;
- }
- `,
- sendText: css`
- overflow: hidden;
- min-width: 0;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- waveform: css`
- pointer-events: none;
-
- position: absolute;
- z-index: 1;
- inset: 0;
-
- display: flex;
- gap: 4px;
- align-items: center;
- justify-content: center;
- `,
- visuallyHidden: css`
- position: absolute;
-
- overflow: hidden;
-
- width: 1px;
- height: 1px;
- margin: -1px;
- padding: 0;
- border: 0;
-
- white-space: nowrap;
-
- clip: rect(0, 0, 0, 0);
- clip-path: inset(50%);
- `,
-}));
-
export interface VoiceMessageControlProps {
actionLabel: string;
actionText?: string;
@@ -455,10 +69,19 @@ export interface VoiceMessageControlProps {
waveform: number[];
}
-const SendDots = () => (
- <span aria-hidden className={styles.sendDots}>
+const SendDots = ({ busy, hidden }: { busy?: boolean; hidden?: boolean }) => (
+ <span aria-hidden {...stylex.props(styles.sendDots, hidden && styles.hidden)}>
{Array.from({ length: 4 }, (_, index) => (
- <i key={index} />
+ <i
+ key={index}
+ {...stylex.props(
+ styles.sendDot,
+ busy && styles.sendDotBusy,
+ busy && index === 1 && styles.sendDotBusySecond,
+ busy && index === 2 && styles.sendDotBusyThird,
+ busy && index === 3 && styles.hidden,
+ )}
+ />
))}
</span>
);
@@ -485,19 +108,21 @@ export const VoiceMessageControl = memo<VoiceMessageControlProps>(
const { handlePointerEnter, handlePointerLeave, isHoverExpanded } =
useIntentionalHover(sendButtonRef);
+ const sendOpen = Boolean(expanded || isHoverExpanded);
+
return (
<div
aria-label={groupLabel}
- className={styles.container}
+ {...stylex.props(styles.container)}
data-testid="voice-message-recorder"
role="group"
>
- <span aria-live="polite" className={styles.visuallyHidden}>
+ <span aria-live="polite" {...stylex.props(styles.visuallyHidden)}>
{statusAnnouncement}
</span>
<button
aria-label={cancelLabel}
- className={styles.cancelButton}
+ {...stylex.props(styles.cancelButton)}
data-testid="voice-message-cancel"
type="button"
onClick={onCancel}
@@ -505,20 +130,21 @@ export const VoiceMessageControl = memo<VoiceMessageControlProps>(
<Icon icon={X} size={17} />
</button>
- <div className={styles.pill} data-testid="voice-message-pill">
- <span className={styles.visuallyHidden}>{durationLabel}</span>
+ <div {...stylex.props(styles.pill)} data-testid="voice-message-pill">
+ <span {...stylex.props(styles.visuallyHidden)}>{durationLabel}</span>
{errorText ? (
- <span className={styles.error} title={errorText}>
+ <span {...stylex.props(styles.error)} title={errorText}>
{errorText}
</span>
) : (
- <div aria-hidden className={styles.waveform}>
+ <div aria-hidden {...stylex.props(styles.waveform)}>
{waveform.map((level, index) => (
<span
- className={styles.bar}
key={index}
- style={{ height: `${Math.max(4, Math.round(level * 18))}px` }}
+ {...sx(styles.bar, {
+ height: `${Math.max(4, Math.round(level * 18))}px`,
+ })}
/>
))}
</div>
@@ -527,7 +153,6 @@ export const VoiceMessageControl = memo<VoiceMessageControlProps>(
<Tooltip title={tooltip}>
<button
aria-label={actionLabel}
- className={styles.sendButton}
data-error={isRetry}
data-expanded={expanded}
data-hover-expanded={isHoverExpanded}
@@ -535,24 +160,39 @@ export const VoiceMessageControl = memo<VoiceMessageControlProps>(
disabled={sendDisabled}
ref={sendButtonRef}
type="button"
+ {...stylex.props(
+ voiceSendButtonMarker,
+ styles.sendButton,
+ isRetry && styles.sendButtonError,
+ isHoverExpanded && styles.sendButtonHoverExpanded,
+ expanded && styles.sendButtonExpanded,
+ )}
onClick={onAction}
onPointerEnter={(event) => handlePointerEnter(event.pointerType)}
onPointerLeave={(event) => handlePointerLeave(event.pointerType)}
>
- <span className={styles.sendLabel}>
- <SendDots />
- <span className={styles.sendText}>{actionText}</span>
- <SendDots />
+ <span
+ {...stylex.props(
+ styles.sendLabel,
+ sendOpen && styles.sendLabelOpen,
+ expanded && styles.sendLabelExpanded,
+ )}
+ >
+ <SendDots busy={expanded} />
+ <span {...stylex.props(styles.sendText, expanded && styles.hidden)}>
+ {actionText}
+ </span>
+ <SendDots hidden={expanded} />
</span>
- <span className={styles.sendArrow}>
+ <span {...stylex.props(styles.sendArrow, sendOpen && styles.sendArrowHidden)}>
<Icon icon={isRetry ? RotateCcw : ArrowUp} size={18} />
</span>
</button>
</Tooltip>
{progress !== undefined && (
- <div aria-hidden className={styles.progress}>
- <div className={styles.progressValue} style={{ width: `${progress}%` }} />
+ <div aria-hidden {...stylex.props(styles.progress)}>
+ <div {...sx(styles.progressValue, { width: `${progress}%` })} />
</div>
)}
</div>
diff --git a/src/features/ChatInput/VoiceMessage/style.ts b/src/features/ChatInput/VoiceMessage/style.ts
new file mode 100644
index 00000000000..9c0d3057d7c
--- /dev/null
+++ b/src/features/ChatInput/VoiceMessage/style.ts
@@ -0,0 +1,256 @@
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
+
+import { voiceSendButtonMarker } from '../markers.stylex';
+
+const REDUCED_MOTION = '@media (prefers-reduced-motion: reduce)';
+const SEND_CIRCLE_COLLAPSED = 'circle(14px at calc(100% - 16px) 50%)';
+const SEND_CIRCLE_EXPANDED = 'circle(150% at calc(100% - 16px) 50%)';
+
+const voiceMessageEnter = stylex.keyframes({
+ from: { transform: 'translateX(8px)', opacity: 0 },
+ to: { transform: 'translateX(0)', opacity: 1 },
+});
+
+const voiceMessageBusyDot = stylex.keyframes({
+ '0%, 60%, 100%': { transform: 'scale(0.72)', opacity: 0.38 },
+ '30%': { transform: 'scale(1)', opacity: 1 },
+});
+
+export const styles = stylex.create({
+ bar: {
+ width: '4px',
+ minHeight: '4px',
+ borderRadius: '9999px',
+ backgroundColor: cssVar.colorPrimary,
+ backgroundImage: 'none',
+ transition: { default: 'height 80ms linear', [REDUCED_MOTION]: 'none' },
+ },
+ cancelButton: {
+ 'cursor': 'default',
+ 'position': 'relative',
+ 'display': 'inline-flex',
+ 'flex': 'none',
+ 'alignItems': 'center',
+ 'justifyContent': 'center',
+ 'width': '32px',
+ 'height': '32px',
+ 'padding': '0',
+ 'borderStyle': 'none',
+ 'borderRadius': '9999px',
+ 'color': { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ 'backgroundColor': { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFill },
+ 'backgroundImage': { 'default': 'none', ':hover': 'none' },
+ 'transition': {
+ 'default': 'color 120ms ease,\n background 120ms ease,\n transform 120ms ease',
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
+ 'outlineWidth': { 'default': null, ':focus-visible': '2px' },
+ 'outlineStyle': { 'default': null, ':focus-visible': 'solid' },
+ 'outlineColor': { 'default': null, ':focus-visible': cssVar.colorPrimary },
+ 'outlineOffset': { 'default': null, ':focus-visible': '2px' },
+ 'transform': { 'default': null, ':active': 'scale(0.96)' },
+ '::after': {
+ content: { 'default': null, '@media (width <= 600px)': "''" },
+ position: { 'default': null, '@media (width <= 600px)': 'absolute' },
+ inset: { 'default': null, '@media (width <= 600px)': '-6px' },
+ },
+ },
+ container: {
+ display: 'flex',
+ flex: 'none',
+ gap: '6px',
+ alignItems: 'center',
+ width: 'min(300px, calc(100vw - 112px))',
+ minWidth: 'min(220px, calc(100vw - 112px))',
+ height: '32px',
+ paddingInline: '2px',
+ animationName: { default: voiceMessageEnter, [REDUCED_MOTION]: 'none' },
+ animationDuration: { default: '160ms', [REDUCED_MOTION]: '0s' },
+ animationTimingFunction: { default: 'ease-out', [REDUCED_MOTION]: 'ease' },
+ },
+ error: {
+ position: 'absolute',
+ zIndex: 1,
+ insetBlockStart: '50%',
+ insetInlineStart: '12px',
+ insetInlineEnd: '44px',
+ transform: 'translateY(-50%)',
+ overflow: 'hidden',
+ fontSize: cssVar.fontSizeSM,
+ lineHeight: 1.3,
+ color: cssVar.colorError,
+ textAlign: 'center',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ pill: {
+ position: 'relative',
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: '0',
+ height: '100%',
+ borderRadius: '9999px',
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ progress: {
+ position: 'absolute',
+ zIndex: 3,
+ insetBlockEnd: '0',
+ insetInline: '6px',
+ overflow: 'hidden',
+ height: '2px',
+ borderRadius: '1px',
+ backgroundColor: cssVar.colorFillSecondary,
+ backgroundImage: 'none',
+ },
+ progressValue: {
+ height: '100%',
+ borderRadius: 'inherit',
+ opacity: 0.72,
+ backgroundColor: cssVar.colorBgContainer,
+ backgroundImage: 'none',
+ transition: { default: 'width 120ms linear', [REDUCED_MOTION]: 'none' },
+ },
+ sendArrow: {
+ position: 'absolute',
+ zIndex: 2,
+ insetBlockStart: '50%',
+ insetInlineEnd: '2px',
+ transform: {
+ default: 'translateY(-50%)',
+ [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]:
+ 'translateY(-50%) translateX(6px)',
+ },
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '28px',
+ height: '28px',
+ opacity: { default: 1, [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]: 0 },
+ transition: { default: 'opacity 100ms ease, transform 160ms ease', [REDUCED_MOTION]: 'none' },
+ },
+ sendArrowHidden: {
+ transform: 'translateY(-50%) translateX(6px)',
+ opacity: 0,
+ },
+ sendButton: {
+ 'cursor': { 'default': 'default', ':disabled': 'not-allowed' },
+ 'position': 'absolute',
+ 'zIndex': 2,
+ 'inset': '0',
+ 'overflow': 'hidden',
+ 'width': '100%',
+ 'padding': '0',
+ 'borderWidth': '0',
+ 'borderStyle': 'none',
+ 'borderRadius': 'inherit',
+ 'color': cssVar.colorBgContainer,
+ 'backgroundColor': 'transparent',
+ 'backgroundImage': 'none',
+ 'outlineWidth': { 'default': null, ':focus-visible': '2px' },
+ 'outlineStyle': { 'default': null, ':focus-visible': 'solid' },
+ 'outlineColor': { 'default': null, ':focus-visible': cssVar.colorPrimary },
+ 'outlineOffset': { 'default': null, ':focus-visible': '-3px' },
+ '::before': {
+ content: "''",
+ position: 'absolute',
+ zIndex: 0,
+ inset: '0',
+ borderRadius: 'inherit',
+ opacity: { 'default': null, ':disabled': 0.45 },
+ backgroundColor: cssVar.colorPrimary,
+ backgroundImage: 'none',
+ clipPath: { 'default': SEND_CIRCLE_COLLAPSED, ':focus-visible': SEND_CIRCLE_EXPANDED },
+ transition: {
+ default: 'clip-path 160ms cubic-bezier(0.2, 0.8, 0.2, 1)',
+ [REDUCED_MOTION]: 'none',
+ },
+ },
+ },
+ sendButtonError: {
+ '::before': { backgroundColor: cssVar.colorError },
+ },
+ sendButtonExpanded: {
+ 'cursor': 'wait',
+ 'color': cssVar.colorTextSecondary,
+ 'backgroundColor': cssVar.colorBgContainer,
+ '::before': {
+ opacity: 1,
+ backgroundColor: cssVar.colorFill,
+ clipPath: SEND_CIRCLE_EXPANDED,
+ },
+ },
+ sendButtonHoverExpanded: {
+ '::before': { clipPath: SEND_CIRCLE_EXPANDED },
+ },
+ sendDot: {
+ width: '3px',
+ height: '3px',
+ borderRadius: '9999px',
+ backgroundColor: 'currentcolor',
+ backgroundImage: 'none',
+ },
+ sendDotBusy: {
+ animationName: { default: voiceMessageBusyDot, [REDUCED_MOTION]: 'none' },
+ animationDuration: { default: '900ms', [REDUCED_MOTION]: '0s' },
+ animationTimingFunction: { default: 'ease-in-out', [REDUCED_MOTION]: 'ease' },
+ animationIterationCount: { default: 'infinite', [REDUCED_MOTION]: 1 },
+ },
+ sendDotBusySecond: { animationDelay: '120ms' },
+ sendDotBusyThird: { animationDelay: '240ms' },
+ sendDots: { display: 'inline-flex', gap: '3px', alignItems: 'center' },
+ sendLabel: {
+ position: 'absolute',
+ zIndex: 2,
+ inset: '0',
+ transform: {
+ default: 'translateY(4px)',
+ [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]: 'translateY(0)',
+ },
+ display: 'flex',
+ gap: '8px',
+ alignItems: 'center',
+ justifyContent: 'center',
+ minWidth: '0',
+ paddingInline: '10px',
+ fontSize: cssVar.fontSize,
+ fontWeight: cssVar.fontWeightStrong,
+ whiteSpace: 'nowrap',
+ opacity: { default: 0, [stylex.when.ancestor(':focus-visible', voiceSendButtonMarker)]: 1 },
+ transition: { default: 'opacity 100ms ease, transform 160ms ease', [REDUCED_MOTION]: 'none' },
+ },
+ sendLabelExpanded: {
+ gap: '8px',
+ paddingInline: '14px',
+ fontSize: cssVar.fontSizeSM,
+ fontWeight: 'normal',
+ },
+ sendLabelOpen: { transform: 'translateY(0)', opacity: 1 },
+ sendText: { overflow: 'hidden', minWidth: '0', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
+ hidden: { display: 'none' },
+ visuallyHidden: {
+ position: 'absolute',
+ overflow: 'hidden',
+ width: '1px',
+ height: '1px',
+ margin: '-1px',
+ padding: '0',
+ borderWidth: '0',
+ borderStyle: 'none',
+ whiteSpace: 'nowrap',
+ clip: 'rect(0, 0, 0, 0)',
+ clipPath: 'inset(50%)',
+ },
+ waveform: {
+ pointerEvents: 'none',
+ position: 'absolute',
+ zIndex: 1,
+ inset: '0',
+ display: 'flex',
+ gap: '4px',
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+});
diff --git a/src/features/ChatInput/components/SelectorTrigger.tsx b/src/features/ChatInput/components/SelectorTrigger.tsx
index 06413b6d3a3..ad4392e6854 100644
--- a/src/features/ChatInput/components/SelectorTrigger.tsx
+++ b/src/features/ChatInput/components/SelectorTrigger.tsx
@@ -1,53 +1,50 @@
-import { createStaticStyles, cssVar, cx, Icon } from '@lobehub/ui';
+import { Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { ChevronDownIcon, ZapIcon } from 'lucide-react';
import type { ComponentPropsWithRef } from 'react';
import { memo } from 'react';
-const styles = createStaticStyles(({ css }) => ({
- label: css`
- overflow: hidden;
+import { sx } from '@/styles/sx';
- min-width: 0;
- max-width: 200px;
-
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
- secondary: css`
- flex: none;
- color: ${cssVar.colorTextTertiary};
- transition: color 0.2s;
- `,
- trigger: css`
- cursor: pointer;
-
- display: flex;
- flex: 0 1 auto;
- gap: 6px;
- align-items: center;
-
- min-width: 0;
- max-width: 100%;
- height: 28px;
- padding-inline: 8px;
- border-radius: 6px;
-
- font-size: 12px;
- color: ${cssVar.colorTextSecondary};
- white-space: nowrap;
-
- transition: all 0.2s;
-
- &:hover {
- color: ${cssVar.colorText};
- background: ${cssVar.colorFillSecondary};
-
- [data-secondary] {
- color: ${cssVar.colorTextSecondary};
- }
- }
- `,
-}));
+const styles = stylex.create({
+ label: {
+ overflow: 'hidden',
+ minWidth: '0',
+ maxWidth: '200px',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ },
+ // Dims one step while the trigger (the default marker) is idle, and follows it on hover.
+ secondary: {
+ flex: 'none',
+ color: {
+ default: cssVar.colorTextTertiary,
+ [stylex.when.ancestor(':hover')]: cssVar.colorTextSecondary,
+ },
+ transition: 'color 0.2s',
+ },
+ trigger: {
+ cursor: 'pointer',
+ display: 'flex',
+ flexGrow: '0',
+ flexShrink: '1',
+ flexBasis: 'auto',
+ gap: '6px',
+ alignItems: 'center',
+ minWidth: '0',
+ maxWidth: '100%',
+ height: '28px',
+ paddingInline: '8px',
+ borderRadius: '6px',
+ fontSize: '12px',
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ whiteSpace: 'nowrap',
+ transition: 'all 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
+ backgroundImage: { 'default': null, ':hover': 'none' },
+ },
+});
/**
* The chip both composer model selectors open from — the heterogeneous one and
@@ -74,15 +71,15 @@ interface TriggerProps extends ComponentPropsWithRef<'div'> {
}
const SelectorTrigger = memo<TriggerProps>(
- ({ ariaLabel, className, fast, secondaryText, text, ...rest }) => (
- <div {...rest} aria-label={ariaLabel} className={cx(styles.trigger, className)}>
+ ({ ariaLabel, className, fast, secondaryText, style, text, ...rest }) => (
+ <div
+ {...rest}
+ aria-label={ariaLabel}
+ {...sx(styles.trigger, stylex.defaultMarker(), className, style)}
+ >
{fast && <Icon icon={ZapIcon} size={12} />}
- <span className={styles.label}>{text}</span>
- {secondaryText && (
- <span data-secondary className={styles.secondary}>
- {secondaryText}
- </span>
- )}
+ <span {...stylex.props(styles.label)}>{text}</span>
+ {secondaryText && <span {...stylex.props(styles.secondary)}>{secondaryText}</span>}
<Icon icon={ChevronDownIcon} size={12} />
</div>
),
diff --git a/src/features/ChatInput/components/UploadDetail/index.tsx b/src/features/ChatInput/components/UploadDetail/index.tsx
index 756e2a634a2..3bc0e1c5eba 100644
--- a/src/features/ChatInput/components/UploadDetail/index.tsx
+++ b/src/features/ChatInput/components/UploadDetail/index.tsx
@@ -1,4 +1,5 @@
-import { createStaticStyles, Flexbox, Text } from '@lobehub/ui';
+import { Flexbox, Text } from '@lobehub/ui';
+import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -8,12 +9,9 @@ import { type FileUploadState, type FileUploadStatus } from '@/types/files';
import UploadStatus from './UploadStatus';
-const styles = createStaticStyles(({ css }) => ({
- status: css`
- padding-inline: 0;
- background: none;
- `,
-}));
+const styles = stylex.create({
+ status: { paddingInline: '0', backgroundColor: 'transparent', backgroundImage: 'none' },
+});
interface UploadDetailProps {
error?: string;
@@ -35,7 +33,11 @@ const UploadDetail = memo<UploadDetailProps>(({ error, uploadState, status, size
</Text>
) : (
<div>
- <FileParsingStatus {...tasks} hideEmbeddingButton className={styles.status} />
+ <FileParsingStatus
+ {...tasks}
+ hideEmbeddingButton
+ className={stylex.props(styles.status).className}
+ />
</div>
)}
</Flexbox>
diff --git a/src/features/ChatInput/components/buildSelectorSubmenu.tsx b/src/features/ChatInput/components/buildSelectorSubmenu.tsx
index 3c0a0a1238c..3c709a8dc81 100644
--- a/src/features/ChatInput/components/buildSelectorSubmenu.tsx
+++ b/src/features/ChatInput/components/buildSelectorSubmenu.tsx
@@ -1,16 +1,16 @@
import type { DropdownItem } from '@lobehub/ui';
-import { createStaticStyles, cssVar, Icon } from '@lobehub/ui';
+import { Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import * as stylex from '@stylexjs/stylex';
import { CheckIcon } from 'lucide-react';
import type { ReactNode } from 'react';
-const styles = createStaticStyles(({ css }) => ({
+const styles = stylex.create({
// The packaged `extra` slot is styled for keyboard hints, so it defaults to the
// code font. This one carries a model name, which belongs in the UI font — and
// `inherit` cannot express that, since this span sits inside that slot.
- value: css`
- font-family: ${cssVar.fontFamily};
- `,
-}));
+ value: { fontFamily: cssVar.fontFamily },
+});
const checkIcon = <Icon icon={CheckIcon} size={16} />;
@@ -49,7 +49,7 @@ export const buildSelectorSubmenu = <T extends string>({
label: option.label,
onClick: () => onSelect(option.value),
})),
- extra: <span className={styles.value}>{valueLabel}</span>,
+ extra: <span {...stylex.props(styles.value)}>{valueLabel}</span>,
key: label,
label,
type: 'submenu',
diff --git a/src/features/ChatInput/markers.stylex.ts b/src/features/ChatInput/markers.stylex.ts
new file mode 100644
index 00000000000..d0022b64e70
--- /dev/null
+++ b/src/features/ChatInput/markers.stylex.ts
@@ -0,0 +1,4 @@
+import * as stylex from '@stylexjs/stylex';
+
+export const composerHoverMarker = stylex.defineMarker();
+export const voiceSendButtonMarker = stylex.defineMarker();
diff --git a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx
index 7665beec4e1..e6702d3a58f 100644
--- a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx
+++ b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/HeteroPlus.tsx
@@ -3,20 +3,13 @@
import { cssVar, Icon, Upload } from '@lobehub/ui';
import * as stylex from '@stylexjs/stylex';
import dayjs from 'dayjs';
-import {
- CalendarClockIcon,
- CheckIcon,
- ChevronRight,
- FileUp,
- PlusIcon,
- TargetIcon,
- TypeIcon,
-} from 'lucide-react';
+import { CalendarClockIcon, CheckIcon, FileUp, PlusIcon, TargetIcon, TypeIcon } from 'lucide-react';
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { type ActionDropdownMenuItems } from '@/features/ChatInput/ActionBar/components/ActionDropdown';
import { ChatInputAction } from '@/features/ChatInput/ActionBar/components/ChatInputAction';
+import SubmenuChevron from '@/features/ChatInput/ActionBar/components/SubmenuChevron';
import { insertGoalTag } from '@/features/ChatInput/InputEditor/ActionTag/goalTag';
import { useChatInputStore } from '@/features/ChatInput/store';
import { useConversationStore } from '@/features/Conversation';
@@ -121,7 +114,7 @@ const HeteroPlus = memo<HeteroPlusProps>(({ providerType }) => {
})),
// Trailing chevron (replaces base-ui's default triangle submenu arrow,
// which ActionDropdown hides via the .lobe-submenu-chevron rule).
- extra: <Icon className="lobe-submenu-chevron" icon={ChevronRight} size={16} />,
+ extra: <SubmenuChevron />,
icon: CalendarClockIcon,
key: 'scheduleSend',
label: t('input.schedule.title'),