@bbc/psammead-figure
v2.0.13
Published
React styled component that generates a figure element
Downloads
265
Readme
psammead-figure -
Description
The psammead-figure
component is a styled <figure>
element. It has the same semantic meaning -- it should be used to surround images, tables or code snippets.
Installation
npm install @bbc/psammead-figure
Props
| Argument | Type | Required | Default | Example | | --------- | ---- | -------- | ------- | ------- | | No props. | | | | |
Usage
The following example shows psammead-figure
wrapping an
- psammead-image-placeholder, a
<div>
with background image - psammead-image, an
<img>
- psammead-caption, a
<figcaption>
- psammead-copyright, a
<p>
- psammead-visually-hidden-text, a hidden
<span>
available only to assistive technology
import Caption from '@bbc/psammead-caption';
import Copyright from '@bbc/psammead-copyright';
import Figure from '@bbc/psammead-figure';
import Image from '@bbc/psammead-image';
import ImagePlaceholder from '@bbc/psammead-image-placeholder';
import VisuallyHiddenText from '@bbc/psammead-visually-hidden-text';
const Wrapper = ({ alt, captionText, ratio, src, width }) => (
<Figure>
<ImagePlaceholder ratio={ratio}>
<Image alt={alt} src={src} width={width} />
<Copyright>
<VisuallyHiddenText>Image copyright, </VisuallyHiddenText>
{copyrightOwner}
</Copyright>
</ImagePlaceholder>
<Caption>
<VisuallyHiddenText>Image caption, </VisuallyHiddenText>
{captionText}
</Caption>
</Figure>
);
When to use this component
Use this component when a <figure>
element, which represents self-contained content that frequently has a caption, is required. Figures usually wrap an image.
Accessibility notes
The psammead-figure
is a <figure>
element with associated styles. When you use this component, it has the same semantic meaning as a regular figure element.
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.