Skip to content

Commit

Permalink
feat(lib): add wait plugin to manage loading state (#214)
Browse files Browse the repository at this point in the history
* feat(lib): add wait plugin to manage loading state

* refactor(lib): MazIcon - use transformSource method

* chore(release): bump version to 3.0.0-next.12
  • Loading branch information
LouisMazel authored Mar 10, 2022
1 parent b803ce6 commit a6a1931
Show file tree
Hide file tree
Showing 36 changed files with 434 additions and 137 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [3.0.0-next.12](https://github.com/LouisMazel/maz-ui/compare/v2.3.13...3.0.0-next.12) (2022-03-10)

### Features

- **lib:** add maz-picker component ([#197](https://github.com/LouisMazel/maz-ui/issues/197)) ([877515e](https://github.com/LouisMazel/maz-ui/commit/877515e585d1aa9a3febd83e222c12346e7401b5))
- **lib:** add wait plugin to manage loading state ([e61d354](https://github.com/LouisMazel/maz-ui/commit/e61d3547dcd4247171c9469a8aa3d6d2659f2d25))
- **lib:** adding maz-input-number ([#195](https://github.com/LouisMazel/maz-ui/issues/195)) ([dfb835d](https://github.com/LouisMazel/maz-ui/commit/dfb835d796682955b53dfb82455aefc763895c86))
- **lib:** export tailwind config ([#201](https://github.com/LouisMazel/maz-ui/issues/201)) ([94fddb9](https://github.com/LouisMazel/maz-ui/commit/94fddb9d35e91a6f649bcb18ae7105048d048584))
- **lib:** MazInput - adding style color for autofill ([#208](https://github.com/LouisMazel/maz-ui/issues/208)) ([b3ae969](https://github.com/LouisMazel/maz-ui/commit/b3ae969584bda0e690179c1b6c9defdc1bbf0425))

# [3.0.0-next.11](https://github.com/LouisMazel/maz-ui/compare/v2.3.13...3.0.0-next.11) (2022-03-10)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": ["packages/*"],
"loglevel": "verbose",
"version": "3.0.0-next.11",
"version": "3.0.0-next.12",
"npmClientArgs": ["--production=false", "--no-progress"],
"yes": true,
"granularPathspec": false,
Expand Down
14 changes: 14 additions & 0 deletions packages/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [3.0.0-next.12](https://github.com/LouisMazel/maz-ui/compare/v2.3.13...3.0.0-next.12) (2022-03-10)


### Features

* **lib:** add maz-picker component ([#197](https://github.com/LouisMazel/maz-ui/issues/197)) ([877515e](https://github.com/LouisMazel/maz-ui/commit/877515e585d1aa9a3febd83e222c12346e7401b5))
* **lib:** add wait plugin to manage loading state ([e61d354](https://github.com/LouisMazel/maz-ui/commit/e61d3547dcd4247171c9469a8aa3d6d2659f2d25))
* **lib:** adding maz-input-number ([#195](https://github.com/LouisMazel/maz-ui/issues/195)) ([dfb835d](https://github.com/LouisMazel/maz-ui/commit/dfb835d796682955b53dfb82455aefc763895c86))
* **lib:** export tailwind config ([#201](https://github.com/LouisMazel/maz-ui/issues/201)) ([94fddb9](https://github.com/LouisMazel/maz-ui/commit/94fddb9d35e91a6f649bcb18ae7105048d048584))





# [3.0.0-next.11](https://github.com/LouisMazel/maz-ui/compare/v2.3.13...3.0.0-next.11) (2022-03-10)


Expand Down
3 changes: 2 additions & 1 deletion packages/docs/docs/.vuepress/clientAppEnhance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mazIconPath = process.env.NODE_ENV === 'production'
? '/maz-ui-3/icons'
: '/icons'

import { ToasterOptions, installToaster } from 'maz-ui'
import { ToasterOptions, installToaster, installWait } from 'maz-ui'
import components from 'maz-ui/components'

export default defineClientAppEnhance(async ({ app }) => {
Expand All @@ -22,4 +22,5 @@ export default defineClientAppEnhance(async ({ app }) => {
}

app.use(installToaster, toasterOptions)
app.use(installWait)
})
18 changes: 9 additions & 9 deletions packages/docs/docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ export default defineUserConfig<DefaultThemeOptions>({
],
[
'meta',
{ name: 'og:title', content: 'Maz-UI - Vue.JS & Nuxt.JS library' },
{ property: 'og:title', content: 'Maz-UI - Vue.JS & Nuxt.JS library' },
],
[
'meta',
{ name: 'og:description', content: 'Library of standalone components and tools for Vue & Nuxt' },
{ property: 'og:description', content: 'Library of standalone components and tools for Vue & Nuxt' },
],
[
'meta',
{ property: 'og:type', content: 'website' },
],
[
'meta',
Expand All @@ -76,6 +80,8 @@ export default defineUserConfig<DefaultThemeOptions>({
'meta',
{ name: 'twitter:description', content: 'Library of standalone components and tools for Vue & Nuxt' },
],
['meta', { property: 'og:image', content: getAssetBaseUrl('/img/maz-ui-preview.jpg') }],
['meta', { name: 'twitter:image', content: getAssetBaseUrl('/img/maz-ui-preview.jpg') }],
[
'link',
{ rel: 'apple-touch-icon', href: getAssetBaseUrl('/img/icons/apple-touch-icon.png') },
Expand All @@ -84,10 +90,6 @@ export default defineUserConfig<DefaultThemeOptions>({
'link',
{ property: 'og:site_name', content: 'Maz UI' },
],
[
'link',
{ property: 'og:type', content: 'website' },
],
[
'link',
{
Expand All @@ -99,8 +101,6 @@ export default defineUserConfig<DefaultThemeOptions>({
['meta', { name: 'msapplication-TileColor', content: '#2d89ef' }],
['meta', { name: 'theme-color', content: '#ffffff' }],
['meta', { name: 'msapplication-TileImage', content: getAssetBaseUrl('/img/maz-ui-preview.jpg') }],
['meta', { property: 'og:image', content: getAssetBaseUrl('/img/maz-ui-preview.jpg') }],
['meta', { name: 'twitter:image', content: getAssetBaseUrl('/img/maz-ui-preview.jpg') }]
],

// theme and its config
Expand Down Expand Up @@ -130,7 +130,7 @@ export default defineUserConfig<DefaultThemeOptions>({
'@vuepress/plugin-google-analytics',
{
// we have multiple deployments, which would use different id
id: 'G-EM35TM23Z',
id: 'G-EM35TM23ZC',
},
],
],
Expand Down
1 change: 1 addition & 0 deletions packages/docs/docs/.vuepress/configs/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export const plugins = {
text: 'Plugins',
children: [
'/plugins/toaster.md',
'/plugins/wait.md',
]
}
9 changes: 2 additions & 7 deletions packages/docs/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ features:
details: This library is writing in typescript, so all types and declarations are directly availables
- title: Dark and Light Theme
details: All components supports the Dark and Light themes.
- title: Tools
details: Maz-ui provide some modules - plugins, directives, filters and helpers
footer: Made by LouisMazel with ❤️

head:
- - meta
- name: description
content: Build your amazing interfaces with Maz UI and its stand-alone components - Stand-alone components library for Vue.JS & Nuxt.JS
- name: twitter:description
content: Build your amazing interfaces with Maz UI and its stand-alone components - Stand-alone components library for Vue.JS & Nuxt.JS
---

<!-- markdownlint-disable -->
Expand Down
10 changes: 10 additions & 0 deletions packages/docs/docs/components/maz-avatar.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
---
title: MazAvatar
description: MazAvatar is a stand-alone component replaces the standard html button with a beautiful design system. Many options like colors, sizes, disabled state, loading state, includes icons. Support of router-link and nuxt-link
head:
- - meta
- name: twitter:title
content: MazAvatar | Maz-UI
- name: twitter:description
content: MazAvatar is a stand-alone component replaces the standard html button with a beautiful design system. Many options like colors, sizes, disabled state, loading state, includes icons. Support of router-link and nuxt-link
- property: og:title
content: MazAvatar | Maz-UI
- property: og:description
content: MazAvatar is a stand-alone component replaces the standard html button with a beautiful design system. Many options like colors, sizes, disabled state, loading state, includes icons. Support of router-link and nuxt-link
---

# MazAvatar
Expand Down
52 changes: 27 additions & 25 deletions packages/docs/docs/plugins/toaster.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
title: Toaster
description: Display messages to your users in flexible toasts
---

# Toaster
# toaster

> Display messages to your users in flexible toasts
> Display messages to your users in flexibles toasts
## Basic usage

Expand Down Expand Up @@ -51,6 +50,7 @@ description: Display messages to your users in flexible toasts
<script lang="ts" setup>
import { inject } from 'vue'
import { ToasterHandler } from 'maz-ui'
const toast = inject<ToasterHandler>('toast')
Expand Down Expand Up @@ -85,6 +85,8 @@ description: Display messages to your users in flexible toasts
<script lang="ts" setup>
import { inject } from 'vue'

import { ToasterHandler } from 'maz-ui'

const toast = inject<ToasterHandler>('toast')

function showInfo () {
Expand Down Expand Up @@ -114,6 +116,28 @@ description: Display messages to your users in flexible toasts
}
</script>

## Install

`main.ts` or `main.js`

```ts
import { createApp } from 'vue'
import { installToaster, ToasterOptions } from 'maz-ui'

const app = createApp(App)

// DEFAULT OPTIONS
const toasterOptions: ToasterOptions = {
position: 'bottom-right',
timeout: 10_000,
persistent: false,
}

app.use(installToaster, toasterOptions)

app.mount('#app')
```

## Options

### Positions
Expand All @@ -139,25 +163,3 @@ const persistent: boolean = false
```ts
const timeout: number = 10000 // in ms
```

## Install

`main.ts` or `main.js`

```ts
import { createApp } from 'vue'
import { installToaster, ToasterOptions } from 'maz-ui'

const app = createApp(App)

// DEFAULT OPTIONS
const toasterOptions: ToasterOptions = {
position: 'bottom-right',
timeout: 10_000,
persistent: false,
}

app.use(installToaster, toasterOptions)

app.mount('#app')
```
96 changes: 96 additions & 0 deletions packages/docs/docs/plugins/wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
description: Plugins to manage your loading states
---

# wait

> Loading state handling
## Basic usage

<br />


<MazBtn @click="submitData" :loading="wait.isLoading('DATA_SUBMITTING')">
Submit Data
</MazBtn>
<br />
<br />
<div v-if="submitted" style="padding: 20px; background-color: var(--maz-color-bg-light); border-radius: 10px;">
Data Submitted
</div>

```vue
<template>
<MazBtn @click="submitData" :loading="wait.isLoading('DATA_SUBMITTING')">
Submit Data
</MazBtn>
<div v-if="submitted" style="padding: 20px; background-color: var(--maz-color-bg-light); border-radius: 10px;">
Data Submitted
</div>
</template>
<script lang="ts" setup>
import { inject, ref } from 'vue'
import { WaitHandler } from 'maz-ui'
const wait = inject<WaitHandler>('wait')
const submitted = ref(false)
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const submitData = async () => {
try {
submitted.value = false
wait.start('DATA_SUBMITTING')
await sleep(2000)
submitted.value = true
} finally {
wait.stop('DATA_SUBMITTING')
}
}
</script>
```

<script lang="ts" setup>
import { inject, ref } from 'vue'
import { WaitHandler } from 'maz-ui'

const wait = inject<WaitHandler>('wait')

const submitted = ref(false)

function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

const submitData = async () => {
try {
submitted.value = false
wait.start('DATA_SUBMITTING')
await sleep(2000)
submitted.value = true
} finally {
wait.stop('DATA_SUBMITTING')
}
}
</script>

## Install

`main.ts` or `main.js`

```ts
import { createApp } from 'vue'
import { installWait } from 'maz-ui'

const app = createApp(App)

app.use(installWait)

app.mount('#app')
```
Loading

0 comments on commit a6a1931

Please sign in to comment.