Skip to content

Commit

Permalink
feat: documentation of tast (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
iiibnuadam authored Nov 25, 2022
1 parent 047bff6 commit 234565c
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export default defineConfig({
text: 'Tabs',
link: '/components/tabs',
},
{
text: 'Toast',
link: '/components/toast',
},
{
text: 'Tooltip',
link: '/components/tooltip',
Expand Down
166 changes: 166 additions & 0 deletions docs/components/toast.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Toast

## Usage

### Basic Usage

```vue
<template>
<!-- VToast is registered globally -->
<VBtn @click="openToast">
Open Toast
</VBtn>
<VToast v-model="isOpen" message="Lorem ipsum" title="Notification">
</template>
```

<LivePreview src="components-toast--default" />

::: info
The `VToast` component is registered globally when you install with `@gits-id/ui`. So you don't need to import it manually.
:::

### Title

```vue
<template>
<VBtn @click="openToast">
Open Toast
</VBtn>
<VToast v-model="isOpen" message="Lorem ipsum" title="Notification">
</template>
```

<LivePreview src="components-toast--title" />

### Icon

```vue
<template>
<VBtn @click="openToast">
Open Toast
</VBtn>
<VToast v-model="isOpen" message="Lorem ipsum" title="Notification" type="success">
</template>
```

<LivePreview src="components-toast--icon" />

### Actions

```vue
<template>
<VBtn @click="openToast">
Open Toast
</VBtn>
<VToast v-model="isOpen" message="Lorem ipsum" title="Notification" actions confirm>
</template>
```

<LivePreview src="components-toast--actions" />

### Custom

```vue
<template>
<VBtn @click="openToast">
Open Toast
</VBtn>
<VToast
v-model="isOpen"
message="Lorem ipsum"
title="Confirmation"
type="question"
actions
confirm
confirm-color="error"
confirm-text="Delete"
close-text="Cancel"
placement="center"
hide-x-icon
overlay
@confirm="(e: any) => {
alert("Confirmed!");
e.close();
}"
/>
</template>
```

<LivePreview src="components-toast--custom" />

## Props

| Name | Type | Default |
| ------------------------------- | --------- | ----------- |
| [`modelValue`](#modelValue) | `boolean` | `'false'` |
| [`title`](#title) | `string` | `''` |
| [`color`](#color) | `string` | `'white'` |
| [`confirmColor`](#confirmColor) | `string` | `'primary'` |
| [`confirmProps`](#confirmProps) | `object` | `{}` |
| [`confirmText`](#confirmText) | `string` | `'Confirm'` |
| [`closeText`](#closeText) | `string` | `'Close'` |
| [`closeProps`](#closeProps) | `object` | `{}` |
| [`headerClass`](#headerClass) | `string` | `''` |
| [`bodyClass`](#bodyClass) | `string` | `''` |
| [`actionsClass`](#actionsClass) | `string` | `''` |
| [`placement`](#placement) | `string` | `''` |
| [`timeout`](#timeout) | `mumber` | `0` |
| [`type`](#type) | `string` | `''` |
| [`hideXIcon`](#hideXIcon) | `boolean` | `'false'` |
| [`overlay`](#overlay) | `boolean` | `false''` |
| [`loading`](#loading) | `boolean` | `'false'` |
| [`presistent`](#presistent) | `boolean` | `'false'` |

## Methods

None

## Events

| Name | Type | Default |
| ---------------------------------------- | --------- | ------- |
| [`confirm`](#confirm) | `unknown` | `-` |
| [`update:modelValue`](#updateModelValue) | `unknown` | `-` |
| [`open`](#open) | `unknown` | `-` |
| [`close`](#close) | `unknown` | `-` |

## Slots

| Name | Type | Default |
| ------------------------------- | --------- | ------- |
| [`actions`](#actions) | `unknown` | `-` |
| [`activator`](#activator) | `unknown` | `-` |
| [`media`](#media) | `unknown` | `-` |
| [`header`](#header) | `unknown` | `-` |
| [`default`](#default) | `unknown` | `-` |
| [`rightActions`](#rightActions) | `unknown` | `-` |

## CSS Variables

None

## Manual Installation

You can also install the `Toast` component individually via `@gits-id/toast` package:

```bash
yarn install @gits-id/toast
```

```vue
<script setup lang="ts">
import VToast from '@gits-id/toast';
</script>
<template>
<VBtn @click="openToast">
Open Toast
</VBtn>
<VToast v-model="isOpen" message="Lorem ipsum">
</template>
```

## Storybook

View Storybook documentation [here](https://gits-ui.web.app/?path=/story/components-toast--default).

0 comments on commit 234565c

Please sign in to comment.