inherit font weight for time component

This commit is contained in:
Ajay Bura 2025-09-25 12:17:14 +05:30
parent d36938e1fd
commit 67c6785bf3
2 changed files with 17 additions and 2 deletions

View file

@ -0,0 +1,6 @@
import { style } from '@vanilla-extract/css';
export const Time = style({
fontWeight: 'inherit',
flexShrink: 0,
});

View file

@ -1,6 +1,8 @@
import React, { ComponentProps } from 'react';
import { Text, as } from 'folds';
import classNames from 'classnames';
import { timeDayMonYear, timeHourMinute, today, yesterday } from '../../utils/time';
import * as css from './Time.css';
export type TimeProps = {
compact?: boolean;
@ -22,7 +24,7 @@ export type TimeProps = {
* @returns {React.ReactElement} A <Text as="time"> element with the formatted date/time.
*/
export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
({ compact, hour24Clock, dateFormatString, ts, ...props }, ref) => {
({ compact, hour24Clock, dateFormatString, ts, className, ...props }, ref) => {
const formattedTime = timeHourMinute(ts, hour24Clock);
let time = '';
@ -37,7 +39,14 @@ export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
}
return (
<Text as="time" style={{ flexShrink: 0 }} size="T200" priority="300" {...props} ref={ref}>
<Text
as="time"
className={classNames(css.Time, className)}
size="T200"
priority="300"
{...props}
ref={ref}
>
{time}
</Text>
);