@bbc/psammead-section-label

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

区域标签的回放样式组件

中文使用文档
文档目录9 节
  1. 说明
  2. 安装
  3. 道具
  4. 使用量
  5. 何时使用此组件
  6. 无障碍说明
  7. 捐款
  8. 行为守则
  9. 许可证

光谱分节标签 - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

说明

这个 @bbc/psammead-section-label 软件包导出一个组件 - a section Label.

对于它使用的颜色和字体家族 @bbc/psammead-styles 财务报告和审定财务报表 @bbc/gel-foundations 在样式组件中执行的相距和GEL字型.

该节的标题应为: 字符串,将包裹在 <h2> 按构成部分(见 无障碍说明) (中文(简体) ).

安装

npm install @bbc/psammead-section-label

道具

参数类型需求默认示例
栏布尔没有truefalse
移动潜水器布尔没有truefalse
视觉隐藏布尔没有falsetrue
儿童字符串对不详'Most Read'
目录字符串没有'ltr''rtl'
小时字符串没有null'https://www.bbc/com/igbo/egwuregwu'
编号字符串没有不详top-stories-id
标签编号字符串没有不详top-stories-label
链接文本字符串没有null'See More'
脚本对象对不详{可口:{可口:{可口:{可口:`28',行高:`32',}可口:{可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口可口:可口:可口:可口:可口:可口:可口:可口:可口:可口:可口
服务字符串对不详'news'
背景颜色字符串没有C_GHOSTC_LUNAR
覆盖标题As字符串没有nullstrong

使用量

import SectionLabel from '@bbc/psammead-section-label';
import { latin } from '@bbc/gel-foundations/scripts';

const WrappingComponent = () => (
  <div aria-labelledby="example-section-label">
    <SectionLabel
      script={latin}
      dir="ltr"
      labelId="example-section-label"
      service="news"
    >
      Example section
    </SectionLabel>
  </div>
);

或者,没有水平栏:

import SectionLabel from '@bbc/psammead-section-label';
import { latin } from '@bbc/gel-foundations/scripts';

const WrappingComponent = () => (
  <div aria-labelledby="example-section-label">
    <SectionLabel
      script={latin}
      dir="ltr"
      bar={false}
      labelId="example-section-label"
      service="news"
    >
      Example section
    </SectionLabel>
  </div>
);

在移动中,此组件将分界线置于标题上方。 通过设置 mobileDivider 向 false数字 :

import SectionLabel from '@bbc/psammead-section-label';
import { latin } from '@bbc/gel-foundations/scripts';

const WrappingComponent = () => (
  <div aria-labelledby="example-section-label">
    <SectionLabel
      script={latin}
      dir="ltr"
      mobileDivider={false}
      labelId="example-section-label"
      service="news"
    >
      Example section
    </SectionLabel>
  </div>
);

您也可以在视觉上隐藏所有断点的分页 visuallyHidden 道具 :

import SectionLabel from '@bbc/psammead-section-label';
import { latin } from '@bbc/gel-foundations/scripts';

const WrappingComponent = () => (
  <div aria-labelledby="example-section-label">
    <SectionLabel
      script={latin}
      dir="ltr"
      visuallyHidden={true}
      labelId="example-section-label"
      service="news"
    >
      Example section
    </SectionLabel>
  </div>
);

您甚至可以使用此组件作为链接( 通常与该部分相关的内容索引): NB. 当这样做时 两者 页:1 href 财务报告和审定财务报表 页:1 linkText 必须提供。 如果缺少其中之一,则不会提供链接 .

import SectionLabel from '@bbc/psammead-section-label';
import { latin } from '@bbc/gel-foundations/scripts';

const WrappingComponent = () => (
  <div aria-labelledby="example-section-label">
    <SectionLabel
      script={latin}
      dir="ltr"
      href="https://www.bbc.com/news/index"
      id="example-section-label"
      linkText="See More"
      service="news"
    >
      Example section
    </SectionLabel>
  </div>
);

您可以覆盖信头( R)h2)到任何符合您的相容性要求的自定义 HTML 元素,取决于您想要在您的页面中用什么用例或语义来描述 overrideHeadingAs 道具 (英语).

import SectionLabel from '@bbc/psammead-section-label';
import { latin } from '@bbc/gel-foundations/scripts';

const WrappingComponent = () => (
  <div aria-labelledby="example-section-label">
    <SectionLabel
      script={latin}
      dir="ltr"
      labelId="example-section-label"
      service="news"
      overrideHeadingAs="strong"
    >
      Example section
    </SectionLabel>
  </div>
);

何时使用此组件

这个组件应该用来表示一个故事组合的开始. 应该 没有 包装故事 promos 或包含除该部分标题( aka' strapline)以外的任何内容 .

无障碍说明

虽然这个组件具有横向规则的外观,但它没有使用 <hr> 标记,因此没有相关的语义意义.

此组件将标题字符串包入一个 <h2> 键。 这个 labelId 道具将应用于 <h2> 作为 id 属性,允许以 aria-labelledby 属性。 见 实例 见上文.

设置 visuallyHidden 道具到真视界隐藏此组件用于所有断点,然而仍然可供屏幕阅读器和其他辅助技术使用.

当提供 href 编辑 linkText,区域标签包含 <a> 链接,即 aria-labelledby 页:1 labelId 说明。 这个 linkText 仅对视觉用户有用,因此标记为 aria-hidden="true" 防止向阅读者发布公告。 这个 aria-hidden="true" 非严格要求 - 设置 aria-labelledby 属性应防止屏幕阅读器读出 linkText然而,它添加了它,让屏幕阅读者和其他开发者清楚地知道 linkText 被屏幕阅读器忽略.

捐款

Psammead完全开源. 我们感谢任何贡献,无论是新的组件、错误修正还是总体改进。 请参看我们的主要贡献指南,可查阅: psammead 仓库的根。 。 。 .

行为守则

我们欢迎对这项工作的反馈和帮助。 通过参与这个项目,你同意遵守 行为守则请稍候再读一下.

许可证

萨姆米德 Apache 2.0 许可。 。 。 .

版本与发布记录

@bbc/psammead-section-label 共发布 115 个版本,首次发布于 2019/05/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
7.1.13latest2022/03/304 年前
7.1.122022/03/294 年前
7.1.112022/01/064 年前
7.1.102021/10/065 年前
7.1.92021/09/305 年前
7.1.82021/09/225 年前

其他发布通道:alpha → 6.0.0-alpha.0。

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

@bbc/psammead-section-label 是什么?

区域标签的回放样式组件

如何安装 @bbc/psammead-section-label?

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

@bbc/psammead-section-label 支持 TypeScript 吗?

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

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

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

@bbc/psammead-section-label 可以商用吗?

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

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

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

@bbc/psammead-section-label 还在维护吗?

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