用 Tailwind CSS 重构 ResultView 和 LiveClock 组件
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Box, IconButton, Tooltip, Typography } from '@mui/material';
|
import { Clock } from 'lucide-react';
|
||||||
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
|
||||||
import CopyButton from '@/components/CopyButton';
|
import CopyButton from '@/components/CopyButton';
|
||||||
import { useSnackbar } from '@/components/GlobalSnackbar';
|
import { useSnackbar } from '@/components/GlobalSnackbar';
|
||||||
import type { UnitType } from '@/config/pageTheme';
|
import type { UnitType } from '@/config/pageTheme';
|
||||||
@@ -38,29 +37,27 @@ const LiveClock = React.memo(({ unit, onUseNow }: LiveClockProps) => {
|
|||||||
}, [now, showMessage, t]);
|
}, [now, showMessage, t]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={timestampPageStyles.LIVE_CLOCK_CARD}>
|
<div className="flex items-center gap-3 px-4 py-2 mb-4 bg-blue-50 rounded-lg border border-blue-100">
|
||||||
<Typography variant="caption" sx={timestampPageStyles.LIVE_CLOCK_LABEL}>
|
<span className="text-blue-700 font-bold text-[0.65rem] uppercase tracking-wider whitespace-nowrap">
|
||||||
{t('timestamp:currentTs')}
|
{t('timestamp:currentTs')}
|
||||||
</Typography>
|
</span>
|
||||||
<Typography variant="subtitle2" sx={timestampPageStyles.LIVE_CLOCK_VALUE}>
|
<span className="flex-1 font-mono font-bold text-blue-700 text-sm tracking-tight leading-tight overflow-hidden text-ellipsis">
|
||||||
{displayVal}
|
{displayVal}
|
||||||
</Typography>
|
</span>
|
||||||
<Tooltip title={t('timestamp:useNowTooltip')}>
|
<button
|
||||||
<IconButton
|
|
||||||
size="small"
|
|
||||||
onClick={handleUseNow}
|
onClick={handleUseNow}
|
||||||
sx={timestampPageStyles.LIVE_CLOCK_ICON_BUTTON}
|
title={t('timestamp:useNowTooltip')}
|
||||||
|
className="p-1.5 rounded-md bg-white text-blue-700 shadow-sm hover:bg-blue-700 hover:text-white transition-colors"
|
||||||
>
|
>
|
||||||
<AccessTimeIcon fontSize="small" />
|
<Clock className="w-4 h-4" />
|
||||||
</IconButton>
|
</button>
|
||||||
</Tooltip>
|
|
||||||
<CopyButton
|
<CopyButton
|
||||||
text={displayVal}
|
text={displayVal}
|
||||||
tooltip={t('timestamp:copyTsTooltip')}
|
tooltip={t('timestamp:copyTsTooltip')}
|
||||||
size="small"
|
size="small"
|
||||||
color={timestampPageStyles.primaryColor}
|
color={timestampPageStyles.primaryColor}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { Box, Fade, Stack, Typography } from '@mui/material';
|
|
||||||
import dayjs from '@/utils/dayjs';
|
import dayjs from '@/utils/dayjs';
|
||||||
import CopyButton from '@/components/CopyButton';
|
import CopyButton from '@/components/CopyButton';
|
||||||
import type { UnitType } from '@/config/pageTheme';
|
import type { UnitType } from '@/config/pageTheme';
|
||||||
@@ -38,46 +37,44 @@ const ResultView = React.memo(
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
if (!showEmptyPlaceholder) return null;
|
if (!showEmptyPlaceholder) return null;
|
||||||
return (
|
return (
|
||||||
<Box sx={timestampPageStyles.RESULT_EMPTY_PLACEHOLDER}>{t('timestamp:resultEmpty')}</Box>
|
<div className="flex-1 flex items-center justify-center text-gray-400 text-sm font-semibold py-12 text-center">
|
||||||
|
{t('timestamp:resultEmpty')}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fade in={!!result}>
|
<div className="animate-in fade-in duration-300">
|
||||||
<Box>
|
<span className="block text-gray-500 mb-3 text-xs font-bold">
|
||||||
<Typography variant="caption" sx={timestampPageStyles.RESULT_LABEL}>
|
|
||||||
{t('timestamp:resultLabel')}
|
{t('timestamp:resultLabel')}
|
||||||
</Typography>
|
</span>
|
||||||
|
|
||||||
<Box sx={timestampPageStyles.RESULT_MAIN_BOX}>
|
<div className="bg-blue-50 p-5 rounded-xl relative mb-4 border border-blue-200 flex justify-between items-center">
|
||||||
<Typography variant="body1" sx={timestampPageStyles.RESULT_MAIN_TEXT}>
|
<span className="font-mono font-bold text-blue-700 break-all pr-4 text-xl tracking-tight leading-tight">
|
||||||
{result}
|
{result}
|
||||||
</Typography>
|
</span>
|
||||||
<CopyButton
|
<CopyButton
|
||||||
text={result}
|
text={result}
|
||||||
tooltip={t('timestamp:copyResultTooltip')}
|
tooltip={t('timestamp:copyResultTooltip')}
|
||||||
size="small"
|
size="small"
|
||||||
color={timestampPageStyles.primaryColor}
|
color={timestampPageStyles.primaryColor}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</div>
|
||||||
|
|
||||||
<Stack spacing={1.2} sx={timestampPageStyles.RESULT_EXTRA_STACK}>
|
<div className="bg-blue-50/50 p-4 rounded-xl border border-blue-100 flex flex-col gap-3">
|
||||||
{[
|
{[
|
||||||
{ label: t('timestamp:relativeTime'), value: extraInfo?.relative },
|
{ label: t('timestamp:relativeTime'), value: extraInfo?.relative },
|
||||||
{ label: t('timestamp:iso8601'), value: extraInfo?.iso },
|
{ label: t('timestamp:iso8601'), value: extraInfo?.iso },
|
||||||
{ label: t('timestamp:utcTime'), value: extraInfo?.utc },
|
{ label: t('timestamp:utcTime'), value: extraInfo?.utc },
|
||||||
].map((item) => (
|
].map((item) => (
|
||||||
<Box
|
<div key={item.label} className="flex justify-between items-center">
|
||||||
key={item.label}
|
<span className="text-gray-400 font-bold text-xs pr-2 whitespace-nowrap">
|
||||||
sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}
|
|
||||||
>
|
|
||||||
<Typography variant="caption" sx={timestampPageStyles.RESULT_EXTRA_LABEL}>
|
|
||||||
{item.label}
|
{item.label}
|
||||||
</Typography>
|
</span>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, minWidth: 0 }}>
|
<div className="flex items-center gap-2 min-w-0">
|
||||||
<Typography variant="caption" sx={timestampPageStyles.RESULT_EXTRA_VALUE}>
|
<span className="font-mono text-blue-700 font-semibold text-xs break-all text-right">
|
||||||
{item.value}
|
{item.value}
|
||||||
</Typography>
|
</span>
|
||||||
{item.value && (
|
{item.value && (
|
||||||
<CopyButton
|
<CopyButton
|
||||||
text={item.value}
|
text={item.value}
|
||||||
@@ -86,12 +83,11 @@ const ResultView = React.memo(
|
|||||||
color={timestampPageStyles.primaryColor}
|
color={timestampPageStyles.primaryColor}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</div>
|
||||||
</Box>
|
</div>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</div>
|
||||||
</Box>
|
</div>
|
||||||
</Fade>
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user