@bbc/psammead-headings

中文文档
5.0.30发布于 2022/03/30Apache-2.0ESM + CJS近 30 天下载 5883

React styled components for a Headline and SubHeading

原始使用文档
文档目录9 节
  1. Description
  2. Installation
  3. Props
  4. Usage
  5. When to use this component
  6. Accessibility notes
  7. Contributing
  8. Code of Conduct
  9. License

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

Description

The Headings are a set of two components, Headline and SubHeading. They use a h1 and h2 HTML element respectively, with the Headline being designed for a single use on the page, with SubHeading being aimed at repeated use.

Installation

npm install @bbc/psammead-headings

Props

ArgumentTypeRequiredDefaultExample
scriptobjectyeslatin{ 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', }, }, }
servicestringyesN/A'news'
darkModeboolnofalsetrue

Usage

import { Headline, SubHeading } from '@bbc/psammead-headings';
import { latin } from '@bbc/gel-foundations/scripts';

const Wrapper = () => (
  <Fragment>
    <Heading script={latin} service="news">
      Some headline
    </Heading>
    <SubHeading script={latin} service="news">
      Some subheadline
    </SubHeading>
  </Fragment>
);

SubHeading components can be used as page anchors when passed an id prop. To take the above usage as an example:

<SubHeading id="some-subheadline" script={latin} service="news">
  Some subheadline
</SubHeading>

This usage will allow for the page anchor: www.bbc.com/news/articles/articleID#some-subheadline

When to use this component

These components can be used at any point on the page, however the Headline is designed to be used once at the top of the page. The SubHeading takes an optional id value and passes it to the h2 which can be used as an anchor when referencing content.

Accessibility notes

The SubHeading component has a tabindex of -1 so that it works correctly with screen readers when navigated to via a skip link.

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.

版本与发布记录

@bbc/psammead-headings 共发布 115 个版本,首次发布于 2018/12/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.0.30latest2022/03/304 年前
5.0.292022/03/294 年前
5.0.282022/01/064 年前
5.0.272021/10/065 年前
5.0.262021/09/305 年前
5.0.252021/09/225 年前

其他发布通道:beta → 0.1.1,alpha → 4.0.0-alpha.0。

关于 @bbc/psammead-headings 的常见问题

@bbc/psammead-headings 是什么?

React styled components for a Headline and SubHeading

如何安装 @bbc/psammead-headings?

在项目目录运行 npm install @bbc/psammead-headings,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@emotion/styled(^11.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bbc/psammead-headings 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bbc__psammead-headings 是否存在。

@bbc/psammead-headings 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bbc/psammead-headings 可以商用吗?

@bbc/psammead-headings 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@bbc/psammead-headings 的下载量有多少?

根据 npm 官方下载统计,@bbc/psammead-headings 在 2026/10/08 – 2026/11/06 这 30 天内被下载 5,883 次,日均约 196 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bbc/psammead-headings 还在维护吗?

最新版本 5.0.30 发布于 2022/03/30(4 年前);至今共发布 115 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/12/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。