Files
newsui/packages/components/src/layout/Article.tsx
T
sunzhongyi 941df8d79f fix(ci): normalize directory casing to lowercase for Linux CI
macOS is case-insensitive but Linux CI is case-sensitive.
Git was tracking uppercase Layout/Text/Media but imports used lowercase.
Renamed via git mv to make both consistent (lowercase).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-05-20 16:54:35 +08:00

46 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import React, { ReactNode, CSSProperties } from 'react';
import { clampSpan, cx } from '@newspaperui/utils';
import { useSection } from './Section';
export interface ArticleProps {
span?: number;
breakable?: boolean;
className?: string;
style?: CSSProperties;
children: ReactNode;
}
/**
* Article — 文章块,grid-column span 跨栏
*
* - 通过 span 属性控制在 Section 栅格中占据的列数
* - 自动 clamp 到父 Section 的最大列数
* - 支持 print 分页控制(breakable
*
* @example
* <Article span={14} breakable={false}>
* <Headline weight="High">Breaking News</Headline>
* <BodyText columns={2}>...</BodyText>
* </Article>
*/
export const Article: React.FC<ArticleProps> = ({
span, breakable = true, className, style, children,
}) => {
const section = useSection();
const cols = span ? clampSpan(span, section.columns) : section.columns;
return (
<article
className={cx('nui-article', className)}
style={{
gridColumn: `span ${cols}`,
breakInside: breakable ? 'auto' : 'avoid',
...style,
}}
data-span={cols}
>
{children}
</article>
);
};