npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bbc/psammead-most-read

v6.1.0

Published

A component for the most read item

Downloads

591

Readme

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

| Argument | Type | Required | Default | Example | | -------- | ---- | -------- | ------- | ------- | | numberOfItems | number | yes | N/A | 10 | | children | node | yes | N/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>, | | dir | string | yes | 'ltr' | 'ltr'| | columnLayout | string | no | '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

| Argument | Type | Required | Default | Example | | -------- | ---- | -------- | ------- | ------- | | dir | string | yes | 'ltr' | 'ltr'| | children | node | yes | N/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" /> | | columnLayout | string | no | '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

| Argument | Type | Required | Default | Example | | -------- | ---- | -------- | ------- | ------- | | service | string | yes | N/A | 'news' | | script | object | yes | N/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' } } } | | listIndex | number | yes | N/A | 1 | | numberOfItems | number | yes | N/A | 10 | | dir | string | no | "ltr" | "ltr" | | columnLayout | string | no | 'multiColumn' | twoColumn | size | string | no | '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

| Argument | Type | Required | Default | Example | | -------- | ---- | -------- | ------- | ------- | | dir | string | yes | 'ltr' | 'ltr'| | service | string | yes | N/A | 'news' | | script | object | yes | N/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' } } } | | title | string | yes | N/A | "This is a article headline" | | href | string | yes | N/A | "/bbc.co.uk/news/00000027051997" | | children | node | no | null | <Timestamp datetime="2019-03-01T14:00+00:00" script={script} padding={false} service={service}>Last updated: 5th November 2016</Timestamp> | | size | string | no | '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.