3.4.15 • Published 3 years ago

@bbc/psammead-image-placeholder v3.4.15

Weekly downloads
2,018
License
Apache-2.0
Repository
github
Last release
3 years ago

psammead-image-placeholder - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

The psammead-image-placeholder component has two placeholders available. The default is a div with a base-64 encoded SVG background image that depicts the BBC logo. The component accepts a ratio as a prop. In the Psammead component library, Image Placeholder is used within the psammead-figure component.

The alternative is an AMP supported placeholder which uses the same base-64 encoded SVG but as multiple amp-img components, which are loaded based on the current screen size. The component adheres to the parent amp-img size and functions as both a fallback and placeholder. See the AMP documentation on fallbacks and placeholders.

When to use this component

Psammead Image Placeholder is designed to appear as a temporary stand-in to be replaced by an actual image, for example in the case of lazy loading.

Installation

npm install @bbc/psammead-image-placeholder

Usage

ImagePlaceholder

The ImagePlaceholder component is expected to contain an image as a child element.

import ImagePlaceholder from '@bbc/psammead-image-placeholder';

const WrapperComponent = ({
  ratio,
}) => (
  <ImagePlaceholder ratio={ratio}>
    <img src="http://some-image.url">
  </ImagePlaceholder>
);

ImagePlaceholderAmp

The ImagePlaceholderAmp component is expected to be used as a child element of an amp-img component. Information about amp-img can be found on the AMP documentation website

import ImagePlaceholderAmp from '@bbc/psammead-image-placeholder';

const WrapperComponent = () => (
  <amp-img
    src="http://some-image.url"
    width="645px"
    height="128px"
  >
    <ImagePlaceholderAmp />
  </amp-img>
);

Props

ImagePlaceholder

ArgumentTypeRequiredDefaultExample
RatioNumber, ratio between height and widthYesN/A65.625
darkModeBool, true (dark) or false (normal)Nofalsefalse
forwardStyleStyling object that applies additional stylingNonull{ background: 'none' }

ImagePlaceholderAmp

ArgumentTypeRequiredDefaultExample
darkModeBool, true (dark) or false (normal)Nofalsefalse

Accessibility notes

As a div with a background image or as an amp-img for it's AMP counterpart, Psammead Image Placeholder is a presentational element without semantic meaning. As such it does not need to meet colour contrast requirements.

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.

3.4.14

3 years ago

3.4.15

3 years ago

3.4.13

3 years ago

3.4.11

3 years ago

3.4.12

3 years ago

3.4.10

3 years ago

3.4.9

3 years ago

3.4.8

3 years ago

3.4.7

3 years ago

3.4.6

3 years ago

3.4.5

3 years ago

3.4.4

3 years ago

3.4.3

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.3.0

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.2.0

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.16

4 years ago

3.0.14

4 years ago

3.0.15

4 years ago

3.0.13

4 years ago

3.0.12

4 years ago

3.0.11

4 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.4

4 years ago

3.0.5

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0-alpha.0

4 years ago

1.2.47

4 years ago

1.2.46

4 years ago

1.2.45

4 years ago

1.2.44

4 years ago

1.2.42

4 years ago

1.2.43

4 years ago

1.2.41

4 years ago

1.2.37

4 years ago

1.2.36

5 years ago

1.2.35

5 years ago

1.2.34

5 years ago

1.2.33

5 years ago

1.2.32

5 years ago

1.2.31

5 years ago

1.2.30

5 years ago

1.2.29

5 years ago

1.2.28

5 years ago

1.2.27

5 years ago

1.2.26

5 years ago

1.2.25

5 years ago

1.2.23

5 years ago

1.2.24

5 years ago

1.2.22

5 years ago

1.2.21

5 years ago

1.2.20

5 years ago

1.2.19

5 years ago

1.2.18

5 years ago

1.2.17

5 years ago

1.2.16

5 years ago

1.2.15

5 years ago

1.2.14

5 years ago

1.2.13

5 years ago

1.2.12

5 years ago

1.2.11

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago