@bbc/psammead-inline-link

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

React component for an Inline Link

原始使用文档
文档目录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-inline-link - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

The @bbc/psammead-inline-link package exports a single Inline Link component. It uses an a HTML element and colours from @bbc/psammead-styles.

Installation

npm install @bbc/psammead-inline-link

Props

ArgumentTypeRequiredDefaultExample
hrefStringYesN/Awww.bbc.co.uk

Usage

import InlineLink from '@bbc/psammead-inline-link';

const WrappingComponent = () => (
  <InlineLink href="https://www.bbc.com/news">Text here</InlineLink>
);

We have not included any typography styles inside this component. This is so it is reusable in multiple contexts. For example, you can use InlineLink inside our existing psammead-paragraph for body copy and psammead-headings for headlines and subheadings (h1s and h2s).

Example inline link in a paragraph:

import InlineLink from '@bbc/psammead-inline-link';
import Paragraph from '@bbc/psammead-paragraph';

const WrapperComponent = () => (
  <Paragraph>I am a paragraph that has a link to <InlineLink href="https://www.bbc.com/news">the BBC News front page</InlineLink>.<Paragraph>
);

Example inline link in a Headline or SubHeading:

import InlineLink from '@bbc/psammead-inline-link';
import { Headline, SubHeading } from '@bbc/psammead-headings';

const HeadlineWithALink = () => (
  <InlineLink href="https://www.bbc.com/news"><Headline>Headline</Headline></InlineLink>


  const SubHeadingWithALink = () => (
  <InlineLink href="https://www.bbc.com/news"><SubHeading>SubHeading</SubHeading></InlineLink>
);

Alternatively, if you want to just extend existing styles with other GEL Typography groups, you can do the following:

import InlineLink from '@bbc/psammead-inline-link';
import { GEL_PARAGON } from '@bbc/gel-foundations';

const GelParagonLink = styled(InlineLink)`
  ${GEL_PARAGON};
`;

const WrapperComponent = () => (
  <GelParagonLink href="https://www.bbc.com/news">
    Link with GEL Paragon typography
  </GelParagonLink>
);

When to use this component

This component can be used at any point on a page.

Accessibility notes

Since this is just a <a> tag with associated styles, when you use this component, it has the same semantic meaning as a regular anchor element.

The font and background-color choices for each hover/focused/visited/default states meet WCAG AA colour contrast guidelines. Also the border width increases on hover and focus which acts as a visible change that is not colour dependent for high-contrast modes, which often override colours/styles.

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-inline-link 共发布 97 个版本,首次发布于 2018/12/11;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.28latest2022/03/304 年前
3.0.272022/03/294 年前
3.0.262022/01/064 年前
3.0.252021/10/065 年前
3.0.242021/09/305 年前
3.0.232021/09/225 年前

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

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

@bbc/psammead-inline-link 是什么?

React component for an Inline Link

如何安装 @bbc/psammead-inline-link?

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

@bbc/psammead-inline-link 支持 TypeScript 吗?

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

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

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

@bbc/psammead-inline-link 可以商用吗?

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

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

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

@bbc/psammead-inline-link 还在维护吗?

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