refactor(ui): implement dedicated package @page-agent/ui

This commit is contained in:
Simon
2025-12-15 17:34:12 +08:00
parent 2b8b6ef86a
commit d1c8ca8197
18 changed files with 150 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
import { I18n, type SupportedLanguage } from '../i18n'
import { truncate } from '../utils'
import { type Step, UIState } from './UIState'
import { I18n, type SupportedLanguage } from './i18n'
import { truncate } from './utils'
import styles from './Panel.module.css'

View File

@@ -1,6 +1,6 @@
import { Motion } from 'ai-motion'
import { isPageDark } from '../utils/checkDarkMode'
import { isPageDark } from './checkDarkMode'
import styles from './SimulatorMask.module.css'
import cursorStyles from './cursor.module.css'

6
packages/ui/src/env.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
/// <reference types="vite/client" />
declare module '*.module.css' {
const classes: Record<string, string>
export default classes
}

4
packages/ui/src/index.ts Normal file
View File

@@ -0,0 +1,4 @@
export { Panel, type PanelConfig, type PanelUpdate } from './Panel'
export { SimulatorMask } from './SimulatorMask'
export { UIState, type Step, type AgentStatus } from './UIState'
export { I18n, type SupportedLanguage, type TranslationKey } from './i18n'

6
packages/ui/src/utils.ts Normal file
View File

@@ -0,0 +1,6 @@
export function truncate(text: string, maxLength: number): string {
if (text.length > maxLength) {
return text.substring(0, maxLength) + '...'
}
return text
}