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 14:22:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Byline — 署名(Inter small-caps)
|
|
|
|
|
|
*
|
|
|
|
|
|
* - Inter 字体 + OpenType small-caps 特性
|
|
|
|
|
|
* - 用于文章作者署名,通常置于标题下方
|
|
|
|
|
|
* - 字号、字重、间距由 visualWeights 数据驱动
|
|
|
|
|
|
*
|
|
|
|
|
|
* @example
|
|
|
|
|
|
* <Byline>BY ALICE SMITH</Byline>
|
|
|
|
|
|
*/
|
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>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|