@bbc/psammead-play-button

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

Provides a play button, with optional duration, for playable media.

原始使用文档
文档目录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-play-button - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

The PlayButton component renders a button with a 'video' or 'audio' icon and optional duration timestamp. Which icon is displayed is defined by the value of the type prop. The component displays a 'video' icon by default. This component has options for displaying a duration timestamp, which if not provided will render gracefully without. When clicked, the function passed to onClick will be called.

Installation

npm install @bbc/psammead-play-button

Props

ArgumentTypeRequiredDefaultExample
servicestringYesN/A'news'
titlestringYesN/A'Foo.'
onClickfunctionYesN/A() => {}
durationstringNonull'2:30'
durationSpokenstringNonull'2 minutes 30 seconds'
datetimestringNonull'PT2M30S'
typestringNo'video''audio'
classNamestringNonull'bar'
guidanceMessagestringNonull'Contains strong language.'

Supported types

  • 'video'
  • 'audio'

Usage

A typical use case for this component would be to indicate to a user that a media asset placeholder contains playable media, which is either 'video' or 'audio' and, if applicable, its duration. A function triggering playback would be passed to the button's onClick prop.

import PlayButton from '@bbc/psammead-play-button';

<PlayButton
  service="news"
  title="Dog barks at cat."
  onClick={handleClick}
  duration="2:30"
  durationSpoken="2 minutes 30 seconds"
  datetime="PT2M30S"
  type="audio"
  guidanceMessage="Contains strong language."
/>;

When to use this component

The PlayButton component is designed to be used in a media asset placeholder containing playable media. It indicates to the user to expect 'video' or 'audio' content, as well as its duration, if applicable.

Accessibility notes

This component is expected to provide information about the playable media to screenreaders and other assistive technology. It is required that the title of the media be passed to the title prop and, if duration is to be displayed, a human-friendly version to durationSpoken. If the video has guidance information, this is also read out in the assitive text. This is used to build a string, which is rendered in a VisuallyHiddenText element. The icon is marked as aria-hidden="true", which means it should be ignored by screenreaders.

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-play-button 共发布 84 个版本,首次发布于 2019/10/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.37latest2022/04/134 年前
3.0.362022/04/084 年前
3.0.352022/03/304 年前
3.0.342022/03/294 年前
3.0.332022/01/064 年前
3.0.322021/11/304 年前

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

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

@bbc/psammead-play-button 是什么?

Provides a play button, with optional duration, for playable media.

如何安装 @bbc/psammead-play-button?

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

@bbc/psammead-play-button 支持 TypeScript 吗?

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

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

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

@bbc/psammead-play-button 可以商用吗?

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

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

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

@bbc/psammead-play-button 还在维护吗?

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