@atomic-layout/core

中文文档
0.14.1发布于 2020/04/24MITTypeScriptCommonJS零依赖近 30 天下载 7881

Atomic Layout core module

原始使用文档
文档目录11 节
  1. Motivation
  2. Scope
  3. Layout interface
  4. Breakpoint transformation
  5. Media Query handling
  6. Utilities
  7. Type definitions
  8. Contributing
  9. Fork the repository
  10. Follow Git workflow
  11. License

Package version

@atomic-layout/core

Atomic Layout core library.

Please note that as a user of Atomic Layout you are not supposed to use this package directly in your application. It serves as a logic abstraction for various rendering implementations (with styled-components, emotion, etc.). Use this package if you are planning to introduce a new styling implementation of Atomic Layout.

Motivation

Atomic Layout contains its core functionality in a separate module in order to reuse it for various styling implementations (styled-components, emotion, etc.). The logic distributed in this module is style-agnostic and mainly concerns calculations and transformations of data structures used by the library. It also provides common type definitions to be used by Atomic Layout, or its consumers.

Scope

Atomic Layout core operates under the following scope:

Layout interface

  • Layout instance to be exposed by each individual styling implementation of the library
  • Interface to consume layout options (defaultUnit, breakpoints, etc.)
  • Interface to store the provided options and reference them

Breakpoint transformation

  • Breakpoint parsing (getAreaRecords)
  • Breakpoint transformations (mergeBreakpoints, openBreakpoint, closeBreakpoint)
  • Breakpoint compiling (createMediaQuery)

Media Query handling

  • Normalization of media queries (normalizeMediaQuery)

Utilities

  • String utilities (i.e. toCammelCase, toLowerCaseFirst)
  • Math utilities (i.e. transformNumeric)
  • Functional utilities (i.e. compose, when, memoizeWith)

Type definitions

Refer to the complete type definition module atomic-layout/core/lib/index.d.ts.

The common use case to access the types exported by this package is to provide a proper type annotation to your custom React components that accept the same props as the library's components do (Box, Composition, Only, etc.).

Here's an example of how to annotate a custom React component that accepts all the props that the Box component does:

import * as React from 'react'
import { BoxProps } from 'atomic-layout/core'

const MyComponent: React.FC<BoxProps & MyComponentProps> = ({
  children,
  ...boxProps
}) => {
  return <Box {...boxProps}>{children}</Box>
}

Contributing

Fork the repository

Fork this repository using the "Fork" button on the top right of the repository page.

Follow Git workflow

Please follow the Git workflow described in the contribution guidelines to the original library.

License

MIT.

版本与发布记录

@atomic-layout/core 共发布 13 个版本,首次发布于 2019/12/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.14.1latest2020/04/246 年前
0.14.02020/04/226 年前
0.13.02020/04/016 年前
0.12.12020/03/306 年前
0.12.02020/02/126 年前
0.11.72020/02/106 年前

关于 @atomic-layout/core 的常见问题

@atomic-layout/core 是什么?

Atomic Layout core module

如何安装 @atomic-layout/core?

在项目目录运行 npm install @atomic-layout/core,或使用 pnpm add / yarn add / bun add。

@atomic-layout/core 支持 TypeScript 吗?

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

@atomic-layout/core 支持 ESM 还是 CommonJS?

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

@atomic-layout/core 可以商用吗?

@atomic-layout/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@atomic-layout/core 的下载量有多少?

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

@atomic-layout/core 还在维护吗?

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