Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badge Component #42

Merged
merged 3 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/content/examples/badge/BaseBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<CBadge>Default</CBadge>
</template>
9 changes: 9 additions & 0 deletions components/content/examples/badge/ColorBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<CStack direction='row'>
<CBadge>Default</CBadge>
<CBadge color-scheme='green'>Success</CBadge>
<CBadge color-scheme='red'>Removed</CBadge>
<CBadge color-scheme='purple'>New</CBadge>
</CStack>
</template>

14 changes: 14 additions & 0 deletions components/content/examples/badge/CompositionBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<CFlex>
<CAvatar src="https://bit.ly/chakra-jonathan-bakebwa" />
<CBox ml="3">
<CText font-weight="bold">
Jonathan Bakebwa
<CBadge ml="1" color-scheme="green">
New
</CBadge>
</CText>
<CText font-size="sm">UI Engineer</CText>
</CBox>
</CFlex>
</template>
8 changes: 8 additions & 0 deletions components/content/examples/badge/CompositionBadgeTwo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<CText font-weight="bold">
Jonathan Bakebwa
<CBadge ml="1" font-size="1em" color-scheme="green">
New
</CBadge>
</CText>
</template>
8 changes: 8 additions & 0 deletions components/content/examples/badge/VariantBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<CStack direction='row'>
<CBadge mx="2" variant="subtle" color-scheme="green">Subtle</CBadge>
<CBadge mx="2" variant="solid" color-scheme="green">Solid</CBadge>
<CBadge mx="2" variant="outline" color-scheme="green">Outline</CBadge>
</CStack>
</template>

118 changes: 118 additions & 0 deletions content/4.components/badge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
title: Badge
description: Badge Component
version: 2.0+
---

# Badge

The `CBadge` component is used to highlight an item's status for quick recognition.

## Import

```js
import { CBadge } from '@chakra-ui/vue-next';
```

## Usage

::showcase
::base-badge
::
::

```html
<CBadge>Default</CBadge>
```

### Badge Color

Pass the `color-scheme` prop to customize the color of the `CBadge`. `variant-color` can be any color key that exists in the `$chakra.theme.colors`. Here `$chakra.theme` is your theme object.
<!-- once styled system theming is up: Learn more about theming -->

::showcase
::wrap{align="center"}
::color-badge
::

```html
<CStack direction='row'>
<CBadge>Default</CBadge>
<CBadge color-scheme='green'>Success</CBadge>
<CBadge color-scheme='red'>Removed</CBadge>
<CBadge color-scheme='purple'>New</CBadge>
</CStack>
```

### Badge Variants

Pass the `variant` prop and set it to either `subtle`, `solid`, or `outline` to get a different style.

::showcase
::variant-badge
::
::

```html
<CStack direction='row'>
<CBadge mx="2" variant="subtle" color-scheme="green">Subtle</CBadge>
<CBadge mx="2" variant="solid" color-scheme="green">Solid</CBadge>
<CBadge mx="2" variant="outline" color-scheme="green">Outline</CBadge>
</CStack>
```

## Compositon


::showcase
::composition-badge
::
::

```html
<CFlex>
<CAvatar src="https://bit.ly/chakra-jonathan-bakebwa" />
<CBox ml="3">
<CText font-weight="bold">
Jonathan Bakebwa
<CBadge ml="1" color-scheme="green">
New
</CBadge>
</CText>
<CText font-size="sm">UI Engineer</CText>
</CBox>
</CFlex>
```

You can also change the size of the badge by passing `font-size` prop.

::showcase
::composition-badge-two
::
::

```html
<CText font-weight="bold">
Jonathan Bakebwa
<CBadge ml="1" font-size="1em" variant-color="green">
New
</CBadge>
</CText>
```

## Props

> The `CBadge` component composes `CBox` component so you can pass props for `Box`.

| Name | Type | Default | Description |
|-----------------|------------------------------|----------|--------------------------------------------------------------------------------|
| `variant` | `solid`, `subtle`, `outline` | `subtle` | The style variant of the badge |
| `variant-color` | `string` | `gray` | The color scheme to use for the badge. Must be a key in `$chakra.theme.colors` |


## Slots

| Name | Description |
|---------|----------------------------|
| default | Text rendered inside badge |