@bbc/psammead-live-label

React component for a live label

Usage no npm install needed!

<script type="module">
  import bbcPsammeadLiveLabel from 'https://cdn.skypack.dev/@bbc/psammead-live-label';
</script>

README

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

Description

The LiveLabel component implements a span for use on live content.

Installation

npm install @bbc/psammead-live-label --save

Props

Argument Type Required Default Example
service string yes N/A 'news'
dir string no 'ltr' 'rtl'
ariaHidden bool no false true
liveText string no 'LIVE' 'Localised Live'
offScreenText string no null 'Live'
lang string no 'en-GB' 'en-GB'
children node no null <span>Headline</span>

Usage

import LiveLabel from '@bbc/psammead-live-label';
import { Headline, Link } from '@bbc/psammead-story-promo';
import { latin } from '@bbc/gel-foundations/scripts';

<Headline script={latin} service="news">
  <Link href="https://www.bbc.co.uk/news">
    <LiveLabel service={service} dir={dir} ariaHidden offScreenText="Live">
      The headline of the live promo
    </LiveLabel>
  </Link>
</Headline>;

When to use this component

The LiveLabel component can be used inside a Link in index pages to show a promo for a Live page.

Accessibility notes

The LiveLabel example above shows this component being hidden to screen readers with visually hidden text rendered alongside it. This is to ensure the screen reader announces the word 'Live' correctly. This does not need to be accounted for in other languages.

The ariaHidden prop is needed as styled components strips out aria tags on a server render.

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 repository.

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.