Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 8a4fe29

Browse files
Merge pull request #23 from chakra-ui/develop
feat: add badge to core
2 parents d339bfc + 7f720f1 commit 8a4fe29

File tree

21 files changed

+294
-28
lines changed

21 files changed

+294
-28
lines changed

_templates/generator/component/component.ts.ejs.t

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
to: packages/<%=h.changeCase.paramCase(name)%>/src/index.ts
2+
to: packages/<%=h.changeCase.paramCase(name)%>/src/<%=h.changeCase.paramCase(name)%>.ts
33
---
44

55
import { h, defineComponent, PropType } from 'vue'
66
import { chakra, DOMElements } from '@chakra-ui/vue-system'
77

8-
export const <%= h.changeCase.pascalCase(name) %> = defineComponent({
8+
const <%= h.changeCase.pascalCase(name) %> = defineComponent({
99
props: {
1010
as: {
1111
type: [Object, String] as PropType<DOMElements>,
@@ -16,3 +16,5 @@ export const <%= h.changeCase.pascalCase(name) %> = defineComponent({
1616
return () => h(chakra(props.as), { ...attrs }, slots)
1717
},
1818
})
19+
20+
export default <%= h.changeCase.pascalCase(name) %>

_templates/generator/component/examples.vue.ejs.t

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,3 @@ to: packages/<%=h.changeCase.paramCase(name)%>/examples/base-<%=h.changeCase.par
55
<template>
66
<<%=h.changeCase.paramCase(name)%>> HELLO <%=h.changeCase.pascalCase(name)%> </<%=h.changeCase.paramCase(name)%>>
77
</template>
8-
9-
<script lang="ts">
10-
import { <%=h.changeCase.pascalCase(name)%> } from '@chakra-ui/<%=h.changeCase.paramCase(name)%>/src'
11-
import { defineComponent } from 'vue'
12-
13-
export default defineComponent({
14-
name: 'Base<%= h.changeCase.pascalCase(name) %>Example',
15-
components: { <%= h.changeCase.pascalCase(name) %> },
16-
})
17-
</script>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/src/index.ts
3+
---
4+
5+
export { default as <%= h.changeCase.pascalCase(name) %> } from '@chakra-ui/<%=h.changeCase.paramCase(name)%>'

docs/.vitepress/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function getSetupSidebar() {
4545
text: 'Components',
4646
children: [
4747
{ text: 'Alert', link: '/components/alert' },
48+
{ text: 'Badge', link: '/components/badge' },
4849
{ text: 'Button', link: '/components/button' },
4950
{ text: 'Icon', link: '/components/icon' },
5051
{ text: 'Spinner', link: '/components/spinner' },
@@ -62,6 +63,7 @@ function getComponentsSidebar() {
6263
children: [
6364
{ text: 'Alert', link: '/components/alert' },
6465
{ text: 'Button', link: '/components/button' },
66+
{ text: 'Badge', link: '/components/badge' },
6567
{ text: 'Icon', link: '/components/icon' },
6668
{ text: 'Spinner', link: '/components/spinner' },
6769
{ text: 'CSS reset', link: '/components/css-reset' },

docs/components/badge.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Badge
2+
3+
Badges are used to highlight an item's status for quick recognition.
4+
5+
## Import
6+
7+
```bash
8+
import { CBadge } from "@chakra-ui/vue-next"
9+
```
10+
11+
## Usage
12+
```vue
13+
<c-badge color-scheme="blue">Badge</c-badge>
14+
```
15+
16+
### Badge Color
17+
18+
Pass the `colorScheme` prop to customize the color of the Badge. `colorScheme`
19+
can be any **color key** that exists in `theme.colors`.
20+
21+
TODO: Link to theming page
22+
23+
```vue
24+
<c-badge>Default</c-badge>
25+
<c-badge color-scheme="green">Success</c-badge>
26+
<c-badge color-scheme="red">Removed</c-badge>
27+
<c-badge color-scheme="purple">New</c-badge>
28+
```
29+
30+
### Badge Variants
31+
32+
Pass the `variant` prop and set it to either `subtle`, `solid`, or `outline` to
33+
get a different style.
34+
35+
```vue
36+
<c-badge variant="outline" color-scheme="green">Default</c-badge>
37+
<c-badge variant="solid" color-scheme="green">Success</c-badge>
38+
<c-badge variant="subtle" color-scheme="green">Removed</c-badge>
39+
```
40+
41+
TODO: Add composition examples
42+
43+
## Props
44+
45+
The `CBadge` component composes `CBox` component so you can pass props for `CBox`.
46+
| Name | Type | Description | Default |
47+
| :---: | :---: | :---: | :---: |
48+
|`colorScheme`|`"blue" | "cyan" | "gray" | "green" | "orange" | "pink" | "purple" | "red" | "teal" | "yellow" | "whiteAlpha" | "blackAlpha" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"`| Theme color scheme |`"gray"`|
49+
|`size` | `"sm" | "md" | "lg" | "xs"` | Sizes for Badge are not implemented in the default theme. You can extend the theme to implement them. | - |
50+
|`variant` | `"outline" | "solid" | "subtle"` | | `"subtle"` |

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"c-button": "yarn workspace @chakra-ui/c-button",
3232
"c-icon": "yarn workspace @chakra-ui/c-icon",
3333
"c-reset": "yarn workspace @chakra-ui/c-reset",
34-
"c-spinner": "yarn workspace @chakra-ui/c-spinner"
34+
"c-spinner": "yarn workspace @chakra-ui/c-spinner",
35+
"c-badge": "yarn workspace @chakra-ui/c-badge"
3536
},
3637
"license": "MIT",
3738
"private": true,

packages/c-badge/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# @chakra-ui/c-badge
2+
3+
Badges are used to highlight an item s status for quick recognition
4+
5+
## Installation
6+
7+
```sh
8+
yarn add @chakra-ui/c-badge
9+
# or
10+
npm i @chakra-ui/c-badge
11+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<c-badge> New ! </c-badge>
3+
</template>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<chakra.div>
3+
<c-badge
4+
v-for="(color, i) in colorSchemes"
5+
:key="i"
6+
:color-scheme="color"
7+
variant="outline"
8+
mr="2"
9+
>
10+
{{ color }}
11+
</c-badge>
12+
</chakra.div>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import { ref } from 'vue'
17+
18+
const colorSchemes = ref(['gray', 'green', 'red', 'orange', 'purple', 'teal'])
19+
</script>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<chakra class="div">
3+
<c-badge
4+
v-for="(color, i) in colorSchemes"
5+
:key="i"
6+
:color-scheme="color"
7+
variant="solid"
8+
mr="2"
9+
>
10+
{{ color }}
11+
</c-badge>
12+
</chakra>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import { ref } from 'vue'
17+
18+
const colorSchemes = ref(['gray', 'green', 'red', 'orange', 'purple', 'teal'])
19+
</script>

0 commit comments

Comments
 (0)