@bbc/psammead-figure

中文文档
2.0.13发布于 2021/09/30Apache-2.0ESM + CJS近 30 天下载 4789

React styled component that generates a figure element

原始使用文档
文档目录9 节
  1. Description
  2. Installation
  3. Props
  4. Usage
  5. When to use this component
  6. Accessibility notes
  7. Contributing
  8. Code of Conduct
  9. License

psammead-figure - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

The psammead-figure component is a styled <figure> element. It has the same semantic meaning -- it should be used to surround images, tables or code snippets.

Installation

npm install @bbc/psammead-figure

Props

ArgumentTypeRequiredDefaultExample
No props.

Usage

The following example shows psammead-figure wrapping an

import Caption from '@bbc/psammead-caption';
import Copyright from '@bbc/psammead-copyright';
import Figure from '@bbc/psammead-figure';
import Image from '@bbc/psammead-image';
import ImagePlaceholder from '@bbc/psammead-image-placeholder';
import VisuallyHiddenText from '@bbc/psammead-visually-hidden-text';

const Wrapper = ({ alt, captionText, ratio, src, width }) => (
  <Figure>
    <ImagePlaceholder ratio={ratio}>
      <Image alt={alt} src={src} width={width} />
      <Copyright>
        <VisuallyHiddenText>Image copyright, </VisuallyHiddenText>
        {copyrightOwner}
      </Copyright>
    </ImagePlaceholder>
    <Caption>
      <VisuallyHiddenText>Image caption, </VisuallyHiddenText>
      {captionText}
    </Caption>
  </Figure>
);

When to use this component

Use this component when a <figure> element, which represents self-contained content that frequently has a caption, is required. Figures usually wrap an image.

Accessibility notes

The psammead-figure is a <figure> element with associated styles. When you use this component, it has the same semantic meaning as a regular figure element.

Contributing

Psammead is completely open source. We are grateful for any contributions, whether they be new components, bug fixes or general improvements. Please see our primary contributing guide which can be found at the root of the Psammead respository.

Code of Conduct

We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.

License

Psammead is Apache 2.0 licensed.

版本与发布记录

@bbc/psammead-figure 共发布 62 个版本,首次发布于 2018/12/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.13latest2021/09/305 年前
2.0.122021/09/175 年前
2.0.112021/09/165 年前
2.0.102021/05/275 年前
2.0.92021/03/165 年前
2.0.82021/03/105 年前

关于 @bbc/psammead-figure 的常见问题

@bbc/psammead-figure 是什么?

React styled component that generates a figure element

如何安装 @bbc/psammead-figure?

在项目目录运行 npm install @bbc/psammead-figure,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@emotion/styled(^11.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bbc/psammead-figure 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bbc__psammead-figure 是否存在。

@bbc/psammead-figure 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bbc/psammead-figure 可以商用吗?

@bbc/psammead-figure 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@bbc/psammead-figure 的下载量有多少?

根据 npm 官方下载统计,@bbc/psammead-figure 在 2026/10/08 – 2026/11/06 这 30 天内被下载 4,789 次,日均约 160 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bbc/psammead-figure 还在维护吗?

最新版本 2.0.13 发布于 2021/09/30(5 年前);至今共发布 62 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/12/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。