NaNoWriMo Promotes Manuscription
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@bbc/psammead-play-button

3.0.1 • Public • Published

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

Argument Type Required Default Example
service string Yes N/A 'news'
title string Yes N/A 'Foo.'
onClick function Yes N/A () => {}
duration string No null '2:30'
durationSpoken string No null '2 minutes 30 seconds'
datetime string No null 'PT2M30S'
type string No 'video' 'audio'
className string No null 'bar'
guidanceMessage string No null '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.

Install

npm i @bbc/psammead-play-button

DownloadsWeekly Downloads

1,366

Version

3.0.1

License

Apache-2.0

Unpacked Size

61.1 kB

Total Files

9

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar