2.3.13 • Published 5 years ago

@nib-components/content-image v2.3.13

Weekly downloads
25
License
-
Repository
-
Last release
5 years ago

@nib-components/content-image

3 content-image components - Picture, PicturePanel, BackgroundImage.

Installation

npm install --save @nib-components/content-image

Picture Usage

import Picture from '@nib-components/content-image';

<Picture
  description={description}
  desktop={desktop}
  tablet={tablet}
  mobile={mobile}
  breakpoints={breakpoints}
/>

Picture Properties

description

The description of the picture.

Optional. A string.

desktop

The desktop property contains the standard and hdpi picture urls for the desktop view.

Required. An object. Contains standard and hdpi properties, which are both required string types.

tablet

The tablet property contains the standard and hdpi picture urls for the tablet view.

Required. An object. Contains standard and hdpi properties, which are both required string types.

mobile

The mobile property contains the standard and hdpi picture urls for the mobile view.

Required. An object. Contains standard and hdpi properties, which are both required string types.

breakpoints

The breakpoints property contains the min desktop pixels value, and the max mobile pixels value. This is not supplied from the picture decorator.

Required. An object. Contains desktopMin and mobileMax, which are both required number types.

className

Optional className property to add styling to the Picture component.

Optional. A string

PicturePanel Usage

import {PicturePanel} from '@nib-components/content-image';

<PicturePanel
  picture={picture}
  breakpoints={breakpoints}
/>

PicturePanel Properties

title

The title for the picture panel.

Optional. A string.

caption

The caption for the picture panel.

Optional. A string.

source

The source for the picture panel is a link object. See @nib-components/content-link.

Optional. An object containing Link properties.

picture

The picture property contains the properties that the Picture component takes, without the breakpoints.

Required. An object containing Picture properties.

breakpoints

The breakpoints property contains the min desktop pixels value, and the max mobile pixels value. This is passed to the Picture component.

Required. An object. Contains desktopMin and mobileMax, which are both required number types.

className

Optional className property to add styling to the PicturePanel component.

Optional. A string

BackgroundImage Usage

import {BackgroundImage} from '@nib-components/content-image';

<BackgroundImage
  description={description}
  desktop={desktop}
  tablet={tablet}
  mobile={mobile}
  breakpoints={breakpoints}
>
  {children}
</BackgroundImage>

BackgroundImage Properties

description

The description of the background image.

Optional. A string.

desktop

The desktop property contains the standard and hdpi image urls for the desktop view.

Required. An object. Contains standard and hdpi properties, which are both required string types.

tablet

The tablet property contains the standard and hdpi image urls for the tablet view.

Required. An object. Contains standard and hdpi properties, which are both required string types.

mobile

The mobile property contains the standard and hdpi image urls for the mobile view.

Required. An object. Contains standard and hdpi properties, which are both required string types.

breakpoints

The breakpoints property contains the min desktop pixels value, and the max mobile pixels value. This is not supplied from the picture decorator.

Required. An object. Contains desktopMin and mobileMax, which are both required number types.

className

Optional className property to add styling to the BackgroundImage component.

Optional. A string

Change log

1.0.0

Initial release.

Contributing

You can edit the files in ./src, whilst running npm run watch. This will compile for the ./dist folder.

Contentful

Picture Component

The picture schema, mapping and decorator can be imported from @nib-components/content-image -

import Picture, {pictureSchema, pictureMapping, pictureDecorator} from @nib-components/content-image;

A Picture entry should be added to the relevant Contentful space with the following entries -

NameField IDTypeRequired/Optional
TitlelabelShort textRequired
DescriptiondescriptionShort textOptional
Desktop 2xdesktop2xMedia (Image)Required
Desktop 1xdesktop1xMedia (Image)Optional
Tablet 2xtablet2pxMedia (Image)Optional
Tablet 1xtablet1pxMedia (Image)Optional
Mobile 2xmobile2pxMedia (Image)Optional
Mobile 1xmobile1pxMedia (Image)Optional

The 2x images are used to generate the standard urls, and 1x are used to generate the hdpi/retina urls for each device.

An Image Sizes entry should also be added to Contentful to specify the size that the image should be on each device. It should contain the following entries -

NameField IDTypeRequired/Optional
TitlelabelShort textRequired
DesktopdesktopIntegerRequired
TablettabletIntegerRequired
MobilemobileIntegerRequired

The Image Sizes content can be set for various sections of a site e.g. hero sizes, panel sizes etc. These can be set on the General Options and need to be passed to the pictureDecorator where they are used to generate the picture urls.

Breakpoints

The breakpoints property is not retrieved from Contentful. It may come from the theme of a site or can be hardcoded e.g.

const breakpoints = {
    desktopMin: 800,
    mobileMax: 480
};

PicturePanel Component

The picture panel schema, mapping and decorator can be imported from @nib-components/content-image -

import {PicturePanel, picturePanelSchema, picturePanelMapping, picturePanelDecorator} from @nib-components/content-image;

A Picture entry and Image Sizes entry should be added to the relevant Contentful space. These are described above in the Picture Component section. The PicturePanel contains a Picture component.

A Picture Panel entry should also be added with the following entries -

NameField IDTypeRequired/Optional
TitlelabelShort textRequired
TitletitleShort textOptional
CaptioncaptionShort textOptional
PicturepictureReference (Picture)Required
SourcesourceReference (Link)Optional

Breakpoints

The breakpoints property is not retrieved from Contentful. It may come from the theme of a site or can be hardcoded e.g.

const breakpoints = {
    desktopMin: 800,
    mobileMax: 480
}

BackgroundImage Component

The picture schema, mapping and decorator can be imported from @nib-components/content-image and are also used for the BackgroundImage component -

import {BackgroundImage, pictureSchema, pictureMapping, pictureDecorator} from @nib-components/content-image;

The content coming from Contentful is the same format for the BackgroundImage component and Picture component. See Picture Component section above for details.

Breakpoints

The breakpoints property is not retrieved from Contentful. It may come from the theme of a site or can be hardcoded e.g.

const breakpoints = {
    desktopMin: 800,
    mobileMax: 480
}
2.3.13

5 years ago

2.3.12

5 years ago

2.3.11

5 years ago

2.3.10

5 years ago

2.3.8

5 years ago

2.3.6

5 years ago

2.3.5

5 years ago

2.3.4

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.12

6 years ago

2.2.11

6 years ago

2.2.9

6 years ago

2.2.8

6 years ago

2.2.7

6 years ago

2.2.6

6 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.1.19

6 years ago

2.1.18

6 years ago

2.1.17

6 years ago

2.1.16

6 years ago

2.1.15

6 years ago

2.1.14

6 years ago

2.1.13

6 years ago

2.1.12

6 years ago

2.1.11

6 years ago

2.1.10

6 years ago

2.1.9

6 years ago

2.1.8

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.46

6 years ago

2.0.45

6 years ago

2.0.44

6 years ago

2.0.43

6 years ago

2.0.42

6 years ago

2.0.41

6 years ago

2.0.40

6 years ago

2.0.39

6 years ago

2.0.38

6 years ago

2.0.37

6 years ago

2.0.36

6 years ago

2.0.35

6 years ago

2.0.34

6 years ago

2.0.33

6 years ago

2.0.32

6 years ago

2.0.31

6 years ago

2.0.30

6 years ago

2.0.29

6 years ago

2.0.28

6 years ago

2.0.27

6 years ago

2.0.26

6 years ago

2.0.25

6 years ago

2.0.24

6 years ago

2.0.23

6 years ago

2.0.22

6 years ago

2.0.21

6 years ago

2.0.19

6 years ago

2.0.18

6 years ago

2.0.17

6 years ago

2.0.16

6 years ago

2.0.15

6 years ago

2.0.14

6 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago