@edx/frontend-component-cookie-policy-banner

中文文档
3.0.0发布于 2025/09/25AGPL-3.0CommonJS近 30 天下载 7547

The edX cookie policy banner component implemented in React.

原始使用文档
文档目录12 节
  1. Purpose
  2. Getting Started
  3. Installation
  4. Usage
  5. Updating the Repo
  6. Styling
  7. Local Testing With Other Repositories
  8. Storybook
  9. License
  10. edX Code of Conduct
  11. Contact
  12. Security reporting information

frontend-component-cookie-policy-banner

Greenkeeper badge npm npm license

We are not accepting public contributions to this repo at this time.

Purpose

edX cookie policy banner React component

Getting Started

Installation

npm i --save @edx/frontend-component-cookie-policy-banner

Usage

import CookiePolicyBanner from '@edx/frontend-component-cookie-policy-banner';

// Can import sass file this way
// Or as an import in one of your sass files with other third party sass files
import '@edx/frontend-component-cookie-policy-banner/build/frontend-component-cookie-policy-banner.scss';

const SomeWrappingComponent = () => (
  <div>
    <span>Blahblablah</span>
    <CookiePolicyBanner />
  </div>
);

Updating the Repo

We use semantic-release to update the package on NPM.

Please follow semantic-release guidelines on how to structure your commit message when merging a change.

Styling

As noted in a comment in the previous code example, you can import the styles associated with the CookiePolicyBanner component directly (if this is supported by your webpack config) or by importing the sass file as part of one of your existing sass files (probably where your other third-party sass files are imported).

Requirement:The CookiePolicyBanner sass file assumes the presence of an @edx/brand theme
// base.scss
@import 'thirdPartySass';
@import 'anotherThirdPartySass';

// Theme styles
@import '@edx/brand/paragon/fonts';
@import '@edx/brand/paragon/variables';

// Cookie Policy Banner style
@import '@edx/frontend-component-cookie-policy-banner/build/frontend-component-cookie-policy-banner';

Local Testing With Other Repositories

The current build is not included in the git repository so in order to test the component with dependent repositories, you will have to first build the component by running npm run prepublishOnly, then remove build and build/Release from .gitignore and commit the results to your branch. Make sure to remove the change to .gitignore before merging!

Once you've committed and pushed the build to your branch, you can bring it into a dependent repository's package.json by adding

"@edx/frontend-component-cookie-policy-banner": "git+https://github.com/openedx/frontend-component-cookie-policy-banner#<my_branch_name>"

and running npm install.

Note that whenever you make changes on your branch, you will have to rebuild, commit push the resulting build artifacts, and re-run npm install in the dependent repository.

Storybook

storybook

Storybook is a useful tool for showcasing the expected and potential usage of components.

Executing

As of Nov 2020, Storybook isn't compatible with webpack 5, so before running change your webpack version to 4.44.1.

npm run start

locally builds the Storybook for the CookiePolicyBanner component on port 3003.

License

The code in this repository is licensed under the AGPLv3 unless otherwise noted.

Please see LICENSE <LICENSE>_ for details.

edX Code of Conduct

All community members are expected to follow the Open edX Code of Conduct_. https://open.edx.org/code-of-conduct/

Contact

You can contact the edx open-source team at [email protected].

Security reporting information

Please do not report security issues in public. Send security concerns via email to [email protected].

版本与发布记录

@edx/frontend-component-cookie-policy-banner 共发布 38 个版本,首次发布于 2019/09/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.0latest2025/09/251.1 年前
2.6.02024/09/192 年前
2.5.02024/09/132 年前
2.4.12024/07/102 年前
2.4.02024/01/292 年前
2.3.02023/05/233 年前

关于 @edx/frontend-component-cookie-policy-banner 的常见问题

@edx/frontend-component-cookie-policy-banner 是什么?

The edX cookie policy banner component implemented in React.

如何安装 @edx/frontend-component-cookie-policy-banner?

在项目目录运行 npm install @edx/frontend-component-cookie-policy-banner,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^16.1.0 || ^17.0.0 || ^18.0.0)、react-dom(^16.1.0 || ^17.0.0 || ^18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@edx/frontend-component-cookie-policy-banner 支持 TypeScript 吗?

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

@edx/frontend-component-cookie-policy-banner 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@edx/frontend-component-cookie-policy-banner 可以商用吗?

@edx/frontend-component-cookie-policy-banner 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@edx/frontend-component-cookie-policy-banner 的下载量有多少?

根据 npm 官方下载统计,@edx/frontend-component-cookie-policy-banner 在 2026/10/13 – 2026/11/11 这 30 天内被下载 7,547 次,日均约 252 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@edx/frontend-component-cookie-policy-banner 还在维护吗?

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