Files
newsui/packages/components/src/Text/Byline.tsx
T

32 lines
911 B
TypeScript
Raw Normal View History

2026-05-20 01:30:41 +08:00
'use client';
import React, { ReactNode, CSSProperties } from 'react';
2026-05-19 21:09:56 +08:00
import { visualWeights, resolveFontSize } from '@newspaperui/theme';
2026-05-20 01:30:41 +08:00
import { cx } from '@newspaperui/utils';
2026-05-19 21:09:56 +08:00
export interface BylineProps {
2026-05-20 01:30:41 +08:00
className?: string;
style?: CSSProperties;
children: ReactNode; // e.g. "BY ALICE SMITH"
2026-05-19 21:09:56 +08:00
}
2026-05-20 01:30:41 +08:00
export const Byline: React.FC<BylineProps> = ({ className, style, children }) => {
const config = visualWeights.Byline.Standard!;
2026-05-19 21:09:56 +08:00
return (
<div
2026-05-20 01:30:41 +08:00
className={cx('nui-byline nui-small-caps', className)}
2026-05-19 21:09:56 +08:00
style={{
2026-05-20 01:30:41 +08:00
fontFamily: `var(${config.fontFamily})`,
2026-05-19 21:09:56 +08:00
fontSize: resolveFontSize(config.fontSize),
fontWeight: config.fontWeight,
lineHeight: config.lineHeight,
2026-05-20 01:30:41 +08:00
letterSpacing: config.letterSpacing,
color: `var(${config.color})`,
2026-05-19 21:09:56 +08:00
margin: config.margin,
2026-05-20 01:30:41 +08:00
...style,
2026-05-19 21:09:56 +08:00
}}
>
{children}
</div>
);
};