6.1.0 • Published 3 years ago

@bbc/psammead-most-read v6.1.0

Weekly downloads
1,232
License
Apache-2.0
Repository
github
Last release
3 years ago

psammead-most-read - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

The MostRead component is designed to display the most read articles given a designated period of time which is dependent on service. The component comprises of a MostReadList containing an ordered list of MostReadItemWrapper. A MostReadItemWrapper is a list item comprised of and a MostReadLink, a link to the article, and a MostReadRank which is a numerical counter representing the article's ranking.

The MostReadLink and MostReadRank components also support a size prop. This prop currently only accepts a default and small size. Internally these values change the CSS used for sizing parts of the components. This will allow more sizes to be added in the future.

Installation

npm install @bbc/psammead-most-read

Components

MostReadList

Props

ArgumentTypeRequiredDefaultExample
numberOfItemsnumberyesN/A10
childrennodeyesN/A<MostReadItemWrapper dir="ltr"><MostReadRank service="news" script={latin} listIndex={1} numberOfItems={10} dir="ltr" /> <MostReadLink dir="ltr" href="/bbc.co.uk/news/articles/27051997" service="news" script={latin} title="This is a news article headline" /></MostReadItemWrapper>,
dirstringyes'ltr''ltr'
columnLayoutstringno'multiColumn'twoColumn

Usage

This component is to be used in conjunction with the other MostRead components, example can be seen below.

import React from 'react';
import {
  MostReadList,
  MostReadLink,
  MostReadRank,
  MostReadItemWrapper,
} from '@bbc/psammead-most-read';
import { latin } from '@bbc/gel-foundations/scripts';

<MostReadList
  items={items}
  service="news"
  script={latin}
  dir="ltr"
  columnLayout="twoColumn"
>
  <MostReadItemWrapper dir="ltr" children columnLayout="twoColumn">
    <MostReadRank
      service="news"
      script={latin}
      listIndex={1}
      numberOfItems={10}
      dir="ltr"
      columnLayout="twoColumn"
    />
    <MostReadLink
      dir="ltr"
      href="/bbc.co.uk/news/articles/27051997"
      service="news"
      script={latin}
      title="This is a news article headline"
    />
  </MostReadItemWrapper>
</MostReadList>;

MostReadItemWrapper

Props

ArgumentTypeRequiredDefaultExample
dirstringyes'ltr''ltr'
childrennodeyesN/A<MostReadRank service="news" script={latin} listIndex={1} numberOfItems={10} dir="ltr" /> <MostReadLink dir="ltr" href="/bbc.co.uk/news/articles/27051997" service="news" script={latin} title="This is a news article headline" />
columnLayoutstringno'multiColumn'twoColumn

Usage

This component is used to wrap MostReadLink and MostReadRank together, as seen below.

import React from 'react';
import { latin } from '@bbc/gel-foundations/scripts';
import {
  MostReadLink,
  MostReadRank,
  MostReadItemWrapper,
} from '@bbc/psammead-most-read';
<MostReadItemWrapper dir="ltr" children columnLayout="twoColumn">
  <MostReadRank
    service="news"
    script={latin}
    listIndex={1}
    numberOfItems={10}
    dir="ltr"
    columnLayout="twoColumn"
  />
  <MostReadLink
    dir="ltr"
    script={latin}
    service="news"
    title="This is a article headline"
    href="/bbc.co.uk/news/00000027051997"
  />
</MostReadItemWrapper>;

MostReadRank

Props

ArgumentTypeRequiredDefaultExample
servicestringyesN/A'news'
scriptobjectyesN/A{ 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' } } }
listIndexnumberyesN/A1
numberOfItemsnumberyesN/A10
dirstringno"ltr""ltr"
columnLayoutstringno'multiColumn'twoColumn
sizestringno'default''small'

Usage

import React from 'react';
import { latin } from '@bbc/gel-foundations/scripts';
import { MostReadRank } from '@bbc/psammead-most-read';

<MostReadRank
  service="news"
  script={latin}
  listIndex={1}
  numberOfItems={5}
  dir="ltr"
  columnLayout="twoColumn"
  size="small"
/>;

MostReadLink

Props

ArgumentTypeRequiredDefaultExample
dirstringyes'ltr''ltr'
servicestringyesN/A'news'
scriptobjectyesN/A{ 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' } } }
titlestringyesN/A"This is a article headline"
hrefstringyesN/A"/bbc.co.uk/news/00000027051997"
childrennodenonull<Timestamp datetime="2019-03-01T14:00+00:00" script={script} padding={false} service={service}>Last updated: 5th November 2016</Timestamp>
sizestringno'default''small'

Usage

A typical use-case of this component is as displayed below. It contains an info element. The info element is a link which points to the corresponding article.

import React from 'react';
import { latin } from '@bbc/gel-foundations/scripts';
import { MostReadLink } from '@bbc/psammead-most-read';
import Timestamp from '@bbc/psammead-timestamp';

<MostReadLink
  dir="ltr"
  script={latin}
  service="news"
  title="This is a article headline"
  href="/bbc.co.uk/news/00000027051997"
  size="small"
>
  <Timestamp
    datetime="2019-03-01T14:00+00:00"
    script={script}
    padding={false}
    service={service}
  >
    Last updated: 5th November 2016
  </Timestamp>
</MostReadLink>;

When to use these components

These components are intended to be used on article, front, story and mostRead pages.

Accessibility notes

  • These components are expected to provide information about the Most Read articles in an ordered list when using a screenreader by announcing the region landmark, reading out the title 'Most Read', and read out each headline link in the correct order.
  • Due to the faux block link code, it is not expected to read out the rank as well.

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.

6.1.0

3 years ago

6.0.31

3 years ago

6.0.30

3 years ago

6.0.29

3 years ago

6.0.28

3 years ago

6.0.27

3 years ago

6.0.26

3 years ago

6.0.25

3 years ago

6.0.24

3 years ago

6.0.23

3 years ago

6.0.22

3 years ago

6.0.21

3 years ago

6.0.20

3 years ago

6.0.19

3 years ago

6.0.18

3 years ago

6.0.16

3 years ago

6.0.15

3 years ago

6.0.17

3 years ago

6.0.14

3 years ago

6.0.13

3 years ago

6.0.12

3 years ago

6.0.11

3 years ago

6.0.10

3 years ago

6.0.9

3 years ago

6.0.8

3 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.5

3 years ago

6.0.3

4 years ago

6.0.4

4 years ago

6.0.1

4 years ago

6.0.2

4 years ago

6.0.0

4 years ago

5.0.6

4 years ago

5.0.5

4 years ago

5.0.4

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0-alpha.0

4 years ago

4.1.18

4 years ago

4.1.17

4 years ago

4.1.16

4 years ago

4.1.15

4 years ago

4.1.14

4 years ago

4.1.13

4 years ago

4.1.12

4 years ago

4.1.9

4 years ago

4.1.10

4 years ago

4.1.11

4 years ago

4.1.8

4 years ago

4.1.7

4 years ago

4.1.6

4 years ago

4.1.5

4 years ago

4.1.4

4 years ago

4.1.3

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

2.0.3

4 years ago

3.0.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

1.1.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.5.2-alpha.7

4 years ago

0.5.2-alpha.6

4 years ago

0.5.2-alpha.5

4 years ago

0.5.2-alpha.4

4 years ago

0.5.2-alpha.1

4 years ago

0.5.2-alpha.2

4 years ago

0.5.2-alpha.3

4 years ago

0.5.1-alpha.4

4 years ago

0.5.1-alpha.3

4 years ago

0.5.1-alpha.1

4 years ago

0.5.1-alpha.2

4 years ago

0.5.0-alpha.3

4 years ago

0.5.0-alpha.2

4 years ago

0.5.0-alpha.1

4 years ago

0.4.0-alpha.2

4 years ago

0.4.0-alpha.1

4 years ago

0.3.0-alpha.1

4 years ago

0.2.1-alpha.2

4 years ago

0.2.1-alpha.1

4 years ago

0.2.0-alpha.2

4 years ago

0.2.0-alpha.1

4 years ago

0.1.0-alpha.6

4 years ago

0.1.0-alpha.5

4 years ago

0.1.0-alpha.4

4 years ago

0.1.0-alpha.3

4 years ago

0.1.0-alpha.2

4 years ago

0.1.0-alpha.1

5 years ago