The psammead-caption
component is a styled figcaption
element.
npm install @bbc/psammead-caption
Argument | Type | Required | Default | Example |
---|---|---|---|---|
Script | object | yes | latin | { 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', }, }, } |
service | string | Yes | N/A | 'news ' |
psammead-caption
can be used together with the psammead-figure
and psammead-visually-hidden-text
components in this way. This visually hidden text is to give context to users of Assistive Technology.
import Caption from '@bbc/psammead-caption';
import Figure from '@bbc/psammead-figure';
import VisuallyHiddenText from '@bbc/psammead-visually-hidden-text';
import { arabic } from '@bbc/gel-foundations/scripts';
const Wrapper = captionText => (
<Figure>
...
<Caption script={arabic} service="news">
<VisuallyHiddenText>Image caption, </VisuallyHiddenText>
{captionText}
</Caption>
</Figure>
);
The Caption
component should be used only within a figure
element. It is designed to be placed after an image or video component.
Since this is just a <figcaption>
tag with associated styles, when you use this component, it has the same semantic meaning as a regular figcaption element.
The font and background-color choices meet WCAG AA colour contrast guidelines.
When this caption is used for scripts that do not support italic text, we can consider creating a prop that toggles the font-style: italic
.
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.
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.
Psammead is Apache 2.0 licensed.