diff --git a/src/pages/TextStatistics/components/StatCard.tsx b/src/pages/TextStatistics/components/StatCard.tsx new file mode 100644 index 0000000..8b132c1 --- /dev/null +++ b/src/pages/TextStatistics/components/StatCard.tsx @@ -0,0 +1,17 @@ +interface StatCardProps { + label: string; + value: React.ReactNode; +} + +export default function StatCard({ label, value }: StatCardProps) { + return ( +
+ + {label} + + + {value} + +
+ ); +} diff --git a/src/pages/TextStatistics/index.tsx b/src/pages/TextStatistics/index.tsx index 25a29b3..bfd5696 100644 --- a/src/pages/TextStatistics/index.tsx +++ b/src/pages/TextStatistics/index.tsx @@ -1,18 +1,11 @@ import TextInputArea from '@/components/TextInputArea'; import { formatBytes } from '@/utils/format'; +import StatCard from './components/StatCard'; import { useTextStatistics } from './useTextStatistics'; -import { cn } from '@/lib/utils'; export default function Index() { const { text, stats, setText } = useTextStatistics(); - const statItems = [ - { label: '字符数', value: stats.characters }, - { label: '单词数', value: stats.words }, - { label: '行数', value: stats.lines }, - { label: '字节大小', value: formatBytes(stats.bytes) }, - ]; - return (
- {statItems.map((item) => ( -
- - {item.label} - - - {item.value} - -
- ))} + + + +
);