mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-13 18:50:29 +03:00
add option to inherit priority in time component
This commit is contained in:
parent
f2c5a595b9
commit
d73428ee3d
1 changed files with 4 additions and 3 deletions
|
|
@ -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}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue