diff --git a/docs/notes/theme/guide/功能/组件.md b/docs/notes/theme/guide/功能/组件.md index c1070f17..d1fb9f7e 100644 --- a/docs/notes/theme/guide/功能/组件.md +++ b/docs/notes/theme/guide/功能/组件.md @@ -21,10 +21,13 @@ VuePress 支持在 Markdown 文件中使用 组件。 ### Props -| 名称 | 类型 | 默认值 | 说明 | -| ---- | ------------------------------------------ | ------- | ---- | -| type | `'info' \| 'tip' \| 'warning' \| 'danger'` | `'tip'` | 类型 | -| text | `string` | `''` | 文本 | +| 名称 | 类型 | 默认值 | 说明 | +| ------------ | -------- | ------------------ | ------------------------------------------------------------------ | +| type | `string` | `'tip'` | 类型,内置值: `'info' \| 'tip' \| 'warning' \| 'danger'`,允许自定义 | +| text | `string` | `''` | 文本 | +| color | `string` | `''` | 文本颜色 | +| bg-color | `string` | `''` | 背景颜色 | +| border-color | `string` | `'transparent'` | 边框颜色 | **输入:** @@ -33,6 +36,7 @@ VuePress 支持在 Markdown 文件中使用 组件。 - VuePress - - VuePress - - VuePress - +- VuePress - ``` **输出:** @@ -41,6 +45,43 @@ VuePress 支持在 Markdown 文件中使用 组件。 - VuePress - - VuePress - - VuePress - +- VuePress - + +使用自定义`type`,可以实现更丰富的表现。 + +**输入:** + +1. 在主题任意样式文件中,添加预定的样式: + +```css +/* 浅色主题 */ +.vp-badge.important { + color: #cccccc; + background-color: #f40f40; + border-color: transparent; +} + +/* 深色主题 */ +[data-theme="dark"] .vp-badge.important { + color: #f40f40; + background-color: #ffffff; + border-color: transparent; +} + +/** + important 为自定义 type 类型 +*/ +``` + +2. 使用自定义`type`: + +```md :no-line-numbers +- VuePress - +``` + +**输出:** + +- VuePress - ## 图标 @@ -326,3 +367,19 @@ export default defineUserConfig({ + + diff --git a/docs/notes/theme/guide/组件/徽章.md b/docs/notes/theme/guide/组件/徽章.md index 55f06c33..345c6032 100644 --- a/docs/notes/theme/guide/组件/徽章.md +++ b/docs/notes/theme/guide/组件/徽章.md @@ -14,10 +14,13 @@ permalink: /guide/components/badge/ ## Props -| 名称 | 类型 | 默认值 | 说明 | -| ---- | ------------------------------------------ | ------- | ---- | -| type | `'info' \| 'tip' \| 'warning' \| 'danger'` | `'tip'` | 类型 | -| text | `string` | `''` | 文本 | +| 名称 | 类型 | 默认值 | 说明 | +| ------------ | -------- | ------------------ | ------------------------------------------------------------------ | +| type | `string` | `'tip'` | 类型,内置值: `'info' \| 'tip' \| 'warning' \| 'danger'`,允许自定义 | +| text | `string` | `''` | 文本 | +| color | `string` | `''` | 文本颜色 | +| bg-color | `string` | `''` | 背景颜色 | +| border-color | `string` | `'transparent'` | 边框颜色 | ## 示例 @@ -28,6 +31,7 @@ permalink: /guide/components/badge/ - VuePress - - VuePress - - VuePress - +- VuePress - ``` **输出:** @@ -36,3 +40,56 @@ permalink: /guide/components/badge/ - VuePress - - VuePress - - VuePress - +- VuePress - + +使用自定义`type`,可以实现更丰富的表现。 + +**输入:** + +1. 在主题任意样式文件中,添加预定的样式: + +```css +/* 浅色主题 */ +.vp-badge.important { + color: #cccccc; + background-color: #f40f40; + border-color: transparent; +} + +/* 深色主题 */ +[data-theme="dark"] .vp-badge.important { + color: #f40f40; + background-color: #ffffff; + border-color: transparent; +} + +/** + important 为自定义 type 类型 +*/ +``` + +2. 使用自定义`type`: + +```md :no-line-numbers +- VuePress - +``` + +**输出:** + +- VuePress - + + diff --git a/theme/src/client/components/global/VPBadge.vue b/theme/src/client/components/global/VPBadge.vue index 354a4bea..a7f7908b 100644 --- a/theme/src/client/components/global/VPBadge.vue +++ b/theme/src/client/components/global/VPBadge.vue @@ -1,16 +1,35 @@