add option to inherit priority in time component

This commit is contained in:
Ajay Bura 2025-10-22 16:20:22 +05:30
parent f2c5a595b9
commit d73428ee3d

View file

@ -9,6 +9,7 @@ export type TimeProps = {
ts: number; ts: number;
hour24Clock: boolean; hour24Clock: boolean;
dateFormatString: string; dateFormatString: string;
inheritPriority?: boolean;
}; };
/** /**
@ -24,7 +25,7 @@ export type TimeProps = {
* @returns {React.ReactElement} A <Text as="time"> element with the formatted date/time. * @returns {React.ReactElement} A <Text as="time"> element with the formatted date/time.
*/ */
export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>( export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
({ compact, hour24Clock, dateFormatString, ts, className, ...props }, ref) => { ({ compact, hour24Clock, dateFormatString, ts, inheritPriority, className, ...props }, ref) => {
const formattedTime = timeHourMinute(ts, hour24Clock); const formattedTime = timeHourMinute(ts, hour24Clock);
let time = ''; let time = '';
@ -35,7 +36,7 @@ export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
} else if (yesterday(ts)) { } else if (yesterday(ts)) {
time = `Yesterday ${formattedTime}`; time = `Yesterday ${formattedTime}`;
} else { } else {
time = `${timeDayMonYear(ts, dateFormatString)} ${formattedTime}`; time = `${timeDayMonYear(ts, dateFormatString)}, ${formattedTime}`;
} }
return ( return (
@ -43,7 +44,7 @@ export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
as="time" as="time"
className={classNames(css.Time, className)} className={classNames(css.Time, className)}
size="T200" size="T200"
priority="300" priority={inheritPriority ? undefined : '300'}
{...props} {...props}
ref={ref} ref={ref}
> >