@amsterdam/asc-ui

中文文档
0.38.0发布于 2022/11/28MPL-2.0TypeScriptESM + CJS近 30 天下载 1799

React UI Components that developers at de Gemeente Amsterdam can reuse in multiple projects

此软件包已被标记为弃用

Amsterdam Styled Components is no longer supported. Use Amsterdam Design System (https://designsystem.amsterdam) instead.

原始使用文档
文档目录3 节
  1. Installation
  2. Usage
  3. Basic tweak of an existing style

Amsterdam Styled Components UI

This is the React implementation of the styled-components

Installation

Add this package to your project by running:

npm install @amsterdam/asc-ui

Usage

Consult the demo site with the storybook of the components to see the available components and examples

Basic tweak of an existing style

import styled from 'styled-components'
import { themeColor, List, breakpoint, styles, ThemeProvider } from '@amsterdam/asc-ui'

const StyledList = styled(List)`
  background-color: ${themeColor('tint', 'level5')};

  @media screen and ${breakpoint('min-width', 'laptopM')} {
    background-color: ${themeColor('tint', 'level1')};
  }

  ${styles.ListItemStyle} {
    color: ${themeColor('primary')};
  }

  `

<ThemeProvider>
  <StyledList>
    <ListItem href="/">Item1</ListItem>
    <ListItem href="/">Item2</ListItem>
  </StyledList>
</ThemeProvider>

The background color of the StyledList component has the color of tint.level5 widths smaller than laptopM breakpoint and tint.level1 for widths larger than laptopM The colors and the breakpoints are defined in the default theme

Each component exposes its style that can be used a (class)selector in another component. The naming convention for the styles is: <component-name> -> styles.<component-name>Style. For example ListItem has a styles.ListStyle selector. We use the exposed selector to change the color of the LinkedListItems to the primary theme color. In this case we don't need to create a new StyledLinkedList item to override the style. This is just the way we are exposing the styles from the asc library to be used as selectors. For extending the styles use the convention const StyledLinkList = styled(LinkList) as shown in the example.

The same can be achieved by creating of a new StyledLinkedListItem:

import styled from 'styled-components'
import { themeColor, List, breakpoint, styles, ThemeProvider, svgFill } from '@amsterdam/asc-ui'

const StyledList = styled(List)`
  background-color: ${themeColor('tint', 'level5')};

  @media screen and ${breakpoint('min-width', 'laptopM')} {
    background-color: ${themeColor('tint', 'level1')};
  }
`

const StyledListItem - styled(ListItem)`
  color: ${themeColor('primary')};

  ${styles.IconStyle} {
    ${svgFill(themeColor('tint', 'level1'))};
  }

  ${styles.LinkStyle} {

    &:hover {
      ${IconStyle} {
        ${svgFill(themeColor('primary', 'main'))};
      }
    }
  }

`

<ThemeProvider>
  <StyledList>
    <StyledListItem href="/">Item1</StyledListItem>
    <StyledListItem href="/">Item2</StyledListItem>
  </StyledList>
</ThemeProvider>

In this example, we use the IconStyle selector to override the color of the chevron icon from the ListItem

版本与发布记录

@amsterdam/asc-ui 共发布 92 个版本,首次发布于 2020/09/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.38.0latest2022/11/283 年前
0.37.02022/09/294 年前
0.36.02022/06/084 年前
0.35.42022/05/234 年前
1.0.0-alpha.0beta2022/05/204 年前
0.35.32022/05/204 年前

其他发布通道:canary → 0.35.1-alpha.31,beta → 1.0.0-alpha.0。

关于 @amsterdam/asc-ui 的常见问题

@amsterdam/asc-ui 是什么?

React UI Components that developers at de Gemeente Amsterdam can reuse in multiple projects注意:该包已被作者标记为弃用——Amsterdam Styled Components is no longer supported. Use Amsterdam Design System (https://designsystem.amsterdam) instead.

如何安装 @amsterdam/asc-ui?

在项目目录运行 npm install @amsterdam/asc-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^17.0.2 || ^18.1.0)、react-dom(^17.0.2 || ^18.1.0)、styled-components(^5.3.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@amsterdam/asc-ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amsterdam/asc-ui 支持 ESM 还是 CommonJS?

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

@amsterdam/asc-ui 可以商用吗?

@amsterdam/asc-ui 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@amsterdam/asc-ui 的下载量有多少?

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

@amsterdam/asc-ui 还在维护吗?

最新版本 0.38.0 发布于 2022/11/28(3 年前);至今共发布 92 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/09/22。作者已将其标记为弃用,新项目建议寻找替代方案。