Files
newsui/packages/docs/app/components/media/page.tsx
T

272 lines
7.5 KiB
TypeScript
Raw Normal View History

2026-05-19 21:09:56 +08:00
'use client';
import { Demo } from '@/components/Demo';
import { PropsTable } from '@/components/PropsTable';
import { Layout, Section, Article, Headline, BodyText } from '@newspaperui/components';
import { Image, Figure } from '@newspaperui/components';
export default function MediaPage() {
return (
<div className="prose prose-lg max-w-none">
<h1></h1>
<p className="text-xl text-gray-600">
NewspaperUI ImageFigure Video
</p>
<h2>Image </h2>
<p>
<code>Image</code>
</p>
<PropsTable
data={[
{
name: 'src',
type: 'string',
required: true,
description: '图片 URL',
},
{
name: 'alt',
type: 'string',
required: true,
description: '图片替代文本(无障碍)',
},
{
name: 'span',
type: 'number',
description: '图片占据的列数',
},
{
name: 'aspectRatio',
type: 'string',
default: '"16/9"',
description: '图片宽高比',
},
{
name: 'objectFit',
type: '"cover" | "contain" | "fill"',
default: '"cover"',
description: '图片填充方式',
},
{
name: 'className',
type: 'string',
description: '自定义 CSS 类名',
},
]}
/>
<Demo
title="基础图片"
description="在文章中插入图片"
code={`<Article span={12}>
<Headline weight="High">带图片的文章</Headline>
<Image
src="https://via.placeholder.com/800x600"
alt="示例图片"
span={12}
/>
<BodyText>图片下方的文字说明</BodyText>
</Article>`}
>
<Layout columns={24}>
<Section columns={24}>
<Article span={12}>
<Headline weight="High"></Headline>
<Image
src="https://via.placeholder.com/800x600"
alt="示例图片"
span={12}
/>
<BodyText></BodyText>
</Article>
</Section>
</Layout>
</Demo>
<h2>Figure </h2>
<p>
<code>Figure</code>
</p>
<PropsTable
data={[
{
name: 'src',
type: 'string',
required: true,
description: '图片 URL',
},
{
name: 'alt',
type: 'string',
required: true,
description: '图片替代文本',
},
{
name: 'caption',
type: 'string',
required: true,
description: '图注文字',
},
{
name: 'span',
type: 'number',
description: 'Figure 占据的列数',
},
{
name: 'aspectRatio',
type: 'string',
default: '"16/9"',
description: '图片宽高比',
},
{
name: 'className',
type: 'string',
description: '自定义 CSS 类名',
},
]}
/>
<Demo
title="带图注的图片"
description="使用 Figure 组件添加图注"
code={`<Article span={12}>
<Headline weight="High">新闻标题</Headline>
<Figure
src="https://via.placeholder.com/800x600"
alt="新闻配图"
caption="这是图片的说明文字,描述图片内容"
span={12}
/>
<BodyText>新闻正文内容...</BodyText>
</Article>`}
>
<Layout columns={24}>
<Section columns={24}>
<Article span={12}>
<Headline weight="High"></Headline>
<Figure
src="https://via.placeholder.com/800x600"
alt="新闻配图"
caption="这是图片的说明文字,描述图片内容"
span={12}
/>
<BodyText>...</BodyText>
</Article>
</Section>
</Layout>
</Demo>
<h2>Video </h2>
<p>
<code>Video</code>
</p>
<PropsTable
data={[
{
name: 'src',
type: 'string',
required: true,
description: '视频 URL',
},
{
name: 'poster',
type: 'string',
description: '视频封面图片 URL',
},
{
name: 'span',
type: 'number',
description: '视频占据的列数',
},
{
name: 'controls',
type: 'boolean',
default: 'true',
description: '是否显示控制条',
},
{
name: 'autoPlay',
type: 'boolean',
default: 'false',
description: '是否自动播放',
},
{
name: 'loop',
type: 'boolean',
default: 'false',
description: '是否循环播放',
},
{
name: 'muted',
type: 'boolean',
default: 'false',
description: '是否静音',
},
{
name: 'className',
type: 'string',
description: '自定义 CSS 类名',
},
]}
/>
<Demo
title="嵌入视频"
description="在文章中嵌入视频内容"
code={`<Article span={16}>
<Headline weight="High">视频新闻</Headline>
<Video
src="https://example.com/video.mp4"
poster="https://via.placeholder.com/800x450"
span={16}
controls
/>
<BodyText>视频相关的文字说明...</BodyText>
</Article>`}
>
<Layout columns={24}>
<Section columns={24}>
<Article span={16}>
<Headline weight="High"></Headline>
<div className="bg-gray-200 aspect-video flex items-center justify-center">
<p className="text-gray-600"></p>
</div>
<BodyText>...</BodyText>
</Article>
</Section>
</Layout>
</Demo>
<h2>使</h2>
<ul>
<li>使 Image </li>
<li>使 Figure </li>
<li>使 Video </li>
<li> span </li>
<li> aspectRatio </li>
<li> alt </li>
<li></li>
</ul>
<h2></h2>
<p>
</p>
<h2></h2>
<ul>
<li>使WebPAVIF</li>
<li></li>
<li>使lazy loading</li>
<li></li>
<li>使 CDN </li>
</ul>
</div>
);
}