@bbc/psammead-media-indicator

中文文档
6.1.18发布于 2022/04/13Apache-2.0ESM + CJS近 30 天下载 6550

Provides a play icon and media duration for media page promos

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

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

Description

The MediaIndicator component provides a 'play', 'audio' or 'camera' icon as well as an optional duration timestamp depending on the type prop. The component by default renders the 'play' icon. This component has options for both providing and not providing a duration. If one isn't provided, it will simply render the play, audio or camera icon.

Installation

npm install @bbc/psammead-media-indicator

Props

ArgumentTypeRequiredDefaultExample
typestringno'video''audio'
scriptobjectyesN/A{ canon: { groupA: { fontSize: '28', lineHeight: '32',}, groupB: { fontSize: '32', lineHeight: '36', }, groupD: { fontSize: '44', lineHeight: '48', }, }, trafalgar: { groupA: { fontSize: '20', lineHeight: '24', }, groupB: { fontSize: '24', lineHeight: '28', }, groupD: { fontSize: '32', lineHeight: '36', }, }, }
servicestringyesN/A'news'
dirstringno'ltr''rtl'
isInlinebooleannofalsetrue
childrennodenonull

Supported types

  • 'video'
  • 'audio'
  • 'photogallery'

Usage

The typical use-case of this component is on top of images within promos for articles that contains a video asset at the top of the page. It indicates to the user that the link is to a video and how long the video is in duration.

Top story promos can also have related stories links called Index Alsos. When an Index Also item is a video, audio or photogallery, an icon should be displayed with the content using the MediaIndicator component passing the isInline prop.

import MediaIndicator from '@bbc/psammead-media-indicator';
import { latin } from '@bbc/gel-foundations/scripts';

<MediaIndicator type="audio" script={latin} service="news" />;

When using this component ensure you add the relevant spacing.

E.g.

import styled from '@emotion/styled';
import MediaIndicator from '@bbc/psammead-media-indicator';
import { latin } from '@bbc/gel-foundations/scripts';

const TimeDuration = styled.time`
  margin: 0 ${GEL_SPACING_HLF};
`;

<MediaIndicator type="audio" script={latin} service="news">
  <TimeDuration datetime="PT2M15S">2:15</TimeDuration>
</MediaIndicator>;

When to use this component

The MediaIndicator component is designed to be used on top of an image which is linking to a page containing a video, audio or photo item based on that image. It tells the user to expect video, audio or photographic content on the page as well as how long it is in duration if applicable.

Also, it is used in Top story promos within Index Alsos media links.

Accessibility notes

This component is marked as aria-hidden="true", which means that it should be ignored by screenreaders. It is expected that media promos provide detailed information about their content such as duration in visually hidden text in the promo headline.

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-media-indicator 共发布 127 个版本,首次发布于 2019/04/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
6.1.18latest2022/04/134 年前
6.1.172022/04/084 年前
6.1.162022/03/304 年前
6.1.152022/03/294 年前
6.1.142022/01/064 年前
6.1.132021/11/304 年前

其他发布通道:alpha → 5.0.0-alpha.0。

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

@bbc/psammead-media-indicator 是什么?

Provides a play icon and media duration for media page promos

如何安装 @bbc/psammead-media-indicator?

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

@bbc/psammead-media-indicator 支持 TypeScript 吗?

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

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

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

@bbc/psammead-media-indicator 可以商用吗?

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

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

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

@bbc/psammead-media-indicator 还在维护吗?

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