Skip to content

Commit

Permalink
feat: added utils color package fns docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vtrbo committed Nov 30, 2023
1 parent 633491c commit 3685583
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/.vitepress/guides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ export const functions: DefaultTheme.NavItemChildren[] = [
},
],
},
{
text: 'utils-color',
items: [
{
text: 'hexToRgba',
link: '/functions/color/hexToRgba',
},
{
text: 'rgbaToHex',
link: '/functions/color/rgbaToHex',
},
{
text: 'darken',
link: '/functions/color/darken',
},
{
text: 'lighten',
link: '/functions/color/lighten',
},
],
},
{
text: 'utils-is',
items: [
Expand Down
9 changes: 9 additions & 0 deletions docs/examples/color/darken/hexToDarken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { darken } from '@vtrbo/utils-color'

const hex3: string = '#333'
const level3: number = 3
console.log(darken(hex3, level3))

const hex6: string = '#666666'
const level6: number = 6
console.log(darken(hex6, level6))
8 changes: 8 additions & 0 deletions docs/examples/color/darken/rgbaToDarken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { darken } from '@vtrbo/utils-color'

const rgba: string = 'rgba(123, 32, 18, 0.6)'
console.log(darken(rgba, 4))

const rgb: string = 'rgb(123, 32, 18)'
const level4: number = 4
console.log(darken(rgb, level4))
7 changes: 7 additions & 0 deletions docs/examples/color/hexToRgba/hexToRgb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { hexToRgba } from '@vtrbo/utils-color'

const hex3: string = '#333'
console.log(hexToRgba(hex3))

const hex6: string = '#666666'
console.log(hexToRgba(hex6))
7 changes: 7 additions & 0 deletions docs/examples/color/hexToRgba/hexToRgba.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { hexToRgba } from '@vtrbo/utils-color'

const hex4: string = '#3333'
console.log(hexToRgba(hex4))

const hex8: string = '#66666666'
console.log(hexToRgba(hex8))
9 changes: 9 additions & 0 deletions docs/examples/color/lighten/hexToLighten.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { lighten } from '@vtrbo/utils-color'

const hex3: string = '#333'
const level3: number = 3
console.log(lighten(hex3, level3))

const hex6: string = '#666666'
const level6: number = 6
console.log(lighten(hex6, level6))
8 changes: 8 additions & 0 deletions docs/examples/color/lighten/rgbaToLighten.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { lighten } from '@vtrbo/utils-color'

const rgba: string = 'rgba(123, 32, 18, 0.6)'
console.log(lighten(rgba, 4))

const rgb: string = 'rgb(123, 32, 18)'
const level4: number = 4
console.log(lighten(rgb, level4))
5 changes: 5 additions & 0 deletions docs/examples/color/rgbaToHex/rgbToHex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { rgbaToHex } from '@vtrbo/utils-color'

const rgba: string = 'rgb(123, 213, 35)'

console.log(rgbaToHex(rgba))
5 changes: 5 additions & 0 deletions docs/examples/color/rgbaToHex/rgbaToHex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { rgbaToHex } from '@vtrbo/utils-color'

const rgba: string = 'rgba(123, 213, 35, 0.4)'

console.log(rgbaToHex(rgba))
43 changes: 43 additions & 0 deletions docs/functions/color/darken.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: darken
lang: zh-CN
---

# darken

将颜色加深

## 安装

::: code-group

```bash [pnpm]
pnpm add @vtrbo/utils-color
```

```bash [yarn]
yarn add @vtrbo/utils-color
```

```bash [npm]
npm install @vtrbo/utils-color
```

:::

## 使用

### 3/6位`HEX`颜色加深

<demo example="color/darken/hexToDarken.ts"></demo>

### `RGB``RGBA`颜色加深

<demo example="color/darken/rgbaToDarken.ts"></demo>

## 参数

| 名称 | 描述 | 类型 | 必填 | 默认值 |
|-------|---------|----------|-----|-----|
| color | 欲加深的颜色值 | `string` | `` | - |
| level | 加深级别 | `number` | `` | 10 |
42 changes: 42 additions & 0 deletions docs/functions/color/hexToRgba.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: hexToRgba
lang: zh-CN
---

# hexToRgba

`HEX`颜色值转换为`RGB``RGBA`颜色值

## 安装

::: code-group

```bash [pnpm]
pnpm add @vtrbo/utils-color
```

```bash [yarn]
yarn add @vtrbo/utils-color
```

```bash [npm]
npm install @vtrbo/utils-color
```

:::

## 使用

### 3/6位`HEX`转换为`RGB`

<demo example="color/hexToRgba/hexToRgb.ts"></demo>

### 4/8位`HEX`转换为`RGBA`

<demo example="color/hexToRgba/hexToRgba.ts"></demo>

## 参数

| 名称 | 描述 | 类型 | 必填 | 默认值 |
|-----|---------|----------|-----|-----|
| hex | 欲转换的颜色值 | `string` | `` | - |
43 changes: 43 additions & 0 deletions docs/functions/color/lighten.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: lighten
lang: zh-CN
---

# lighten

将颜色变浅

## 安装

::: code-group

```bash [pnpm]
pnpm add @vtrbo/utils-color
```

```bash [yarn]
yarn add @vtrbo/utils-color
```

```bash [npm]
npm install @vtrbo/utils-color
```

:::

## 使用

### 3/6位`HEX`颜色变浅

<demo example="color/lighten/hexToLighten.ts"></demo>

### `RGB``RGBA`颜色变浅

<demo example="color/lighten/rgbaToLighten.ts"></demo>

## 参数

| 名称 | 描述 | 类型 | 必填 | 默认值 |
|-------|---------|----------|-----|-----|
| color | 欲变浅的颜色值 | `string` | `` | - |
| level | 变浅级别 | `number` | `` | 10 |
42 changes: 42 additions & 0 deletions docs/functions/color/rgbaToHex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: rgbaToHex
lang: zh-CN
---

# rgbaToHex

`RGB``RGBA`颜色值转换为`HEX`颜色值

## 安装

::: code-group

```bash [pnpm]
pnpm add @vtrbo/utils-color
```

```bash [yarn]
yarn add @vtrbo/utils-color
```

```bash [npm]
npm install @vtrbo/utils-color
```

:::

## 使用

### RGBA 转 HEX

<demo example="color/rgbaToHex/rgbaToHex.ts"></demo>

### RGB 转 HEX

<demo example="color/rgbaToHex/rgbToHex.ts"></demo>

## 参数

| 名称 | 描述 | 类型 | 必填 | 默认值 |
|------|---------|----------|-----|-----|
| rgba | 欲转换的颜色值 | `string` | `` | - |

0 comments on commit 3685583

Please sign in to comment.