-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(localization): updated localization to more places
- Loading branch information
1 parent
7b4f6d3
commit b0d5667
Showing
5 changed files
with
154 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
--- | ||
title: 'Fluid Design Docs | 按钮插件' | ||
description: 'Fluid Design Tailwindcss按钮插件' | ||
date: '2022-11-14' | ||
author: 'Oliver Pan' | ||
tags: | ||
- 'fluid ui' | ||
- 'react' | ||
- 'framer motion' | ||
- 'headless ui' | ||
- 'tailwindcss' | ||
- 'plugin' | ||
- 'button' | ||
--- | ||
|
||
# Button 插件 | ||
|
||
一个为 Tailwindcss 提供强大按钮组件的插件。支持所有的变体、状态和视觉无障碍。 | ||
|
||
## 安装 | ||
|
||
```bash | ||
npm install @fluid-design/fluid-ui | ||
``` | ||
|
||
## 配置 | ||
|
||
```js | ||
// tailwind.config.js | ||
module.exports = { | ||
plugins: [ | ||
require('@fluid-design/fluid-ui/src/plugin/core'), | ||
require('@fluid-design/fluid-ui/src/plugin/button'), | ||
// ... | ||
], | ||
}; | ||
``` | ||
|
||
## 使用 | ||
|
||
```jsx | ||
<button className="btn-primary">Primary</button> | ||
<button className="btn-rose">Secondary</button> | ||
<button className="btn-light-amber-100">Tertiary</button> | ||
<button className="btn-outline-green-500">Outline</button> | ||
<button className="btn-clear-rgb(119,187,235)">Clear</button> | ||
``` | ||
|
||
默认情况下,插件提供以下颜色: | ||
|
||
| 颜色 | 类名 | | ||
| ------- | ----------------------------------- | | ||
| red | `*-red` \| `*-red-<50-900>` | | ||
| orange | `*-orange` \| `*-orange-<50-900>` | | ||
| amber | `*-amber` \| `*-amber-<50-900>` | | ||
| yellow | `*-yellow` \| `*-yellow-<50-900>` | | ||
| lime | `*-lime` \| `*-lime-<50-900>` | | ||
| green | `*-green` \| `*-green-<50-900>` | | ||
| emerald | `*-emerald` \| `*-emerald-<50-900>` | | ||
| teal | `*-teal` \| `*-teal-<50-900>` | | ||
| cyan | `*-cyan` \| `*-cyan-<50-900>` | | ||
| sky | `*-sky` \| `*-sky-<50-900>` | | ||
| blue | `*-blue` \| `*-blue-<50-900>` | | ||
| indigo | `*-indigo` \| `*-indigo-<50-900>` | | ||
| violet | `*-violet` \| `*-violet-<50-900>` | | ||
| purple | `*-purple` \| `*-purple-<50-900>` | | ||
| fuchsia | `*-fuchsia` \| `*-fuchsia-<50-900>` | | ||
| pink | `*-pink` \| `*-pink-<50-900>` | | ||
| rose | `*-rose` \| `*-rose-<50-900>` | | ||
| gray | `*-gray` \| `*-gray-<50-900>` | | ||
| slate | `*-slate` \| `*-slate-<50-900>` | | ||
| zinc | `*-zinc` \| `*-zinc-<50-900>` | | ||
| neutral | `*-neutral` \| `*-neutral-<50-900>` | | ||
| stone | `*-stone` \| `*-stone-<50-900>` | | ||
|
||
## 特色 | ||
|
||
### 颜色 | ||
|
||
该插件支持开箱即用的默认 tailwindcss 颜色。请参阅 <ExternalLink href="https://tailwindcss.com/docs/customizing-colors">Tailwindcss Colors</ExternalLink> 以了解更多细节。 | ||
你可以使用任何有效的颜色。例如,你可以使用 `*-red` 或 `*-red-900` 来指定颜色的深度。它还支持任意颜色值。例如,你可以使用 hex、rgb 值、hsl 值等。 | ||
|
||
### 变体 | ||
|
||
如果提供了一个有效的颜色,该插件将自动生成悬停。 | ||
焦点、激活和禁用状态。它还会为每个状态的按钮生成 | ||
为每个状态的按钮生成适当的 a11y 颜色。由于这些颜色是即时生成的,你不需要担心 | ||
运送大量的 CSS 文件。如果颜色是无效的,例如`var(--color)`,该插件将使用`filter`的 | ||
CSS 属性来生成悬停、聚焦、激活和禁用状态。该插件 | ||
使用最小化版本的 <ExternalLink href="https://www.npmjs.com/package/tinycolor2">tinycolor2</ExternalLink> 库来生成颜色。 | ||
|
||
### 黑暗模式 | ||
|
||
该插件将为上述所有状态和变体生成黑暗模式的颜色。它也可以 | ||
也可以通过为颜色提供`dark:`前缀来手动覆盖黑暗模式按钮。 | ||
|
||
### 焦点环 | ||
|
||
对于每个不同的按钮类型,该插件都会生成一个焦点环,当按钮被聚焦时,该环是可见的。 | ||
当按钮被聚焦时是可见的。焦点环是使用 | ||
tailwindcss 的`box-shadow`工具生成。这意味着你可以通过提供 "环 "的变体来定制焦点环 | ||
这意味着你可以通过为按钮提供 "环 "的变体来定制焦点环。 | ||
|
||
### 无障碍 | ||
|
||
该插件将尝试根据提供的颜色生成无障碍颜色。 | ||
简而言之,文本颜色与背景颜色的对比度将大于 4.5:1。 | ||
而在高对比度模式下,文本颜色与背景颜色的对比度将大于 7:1。 | ||
|
||
阅读更多关于无障碍色彩对比的信息 <ExternalLink href='https://www.w3.org/TR/WCAG20-TECHS/G18.html'></ExternalLink>。 | ||
|
||
## 参考资料 | ||
|
||
下面是提供的`btn-*`类的完整表格,供参考。 | ||
|
||
| 类型 | 类 | | ||
| ------- | --------------- | | ||
| default | `btn-*` | | ||
| light | `btn-light-*` | | ||
| bold | `btn-bold-*` | | ||
| outline | `btn-outline-*` | | ||
| clear | `btn-clear-*` | |
b0d5667
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
fluid-design – ./
fluid-design-jiuzhen.vercel.app
fluid-design.io
fluid-design-git-main-jiuzhen.vercel.app
www.fluid-design.io
fluid-design.vercel.app