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

fix(docs): ssr rendering #250

Merged
merged 1 commit into from
May 2, 2022
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
5 changes: 2 additions & 3 deletions packages/docs/docs/components/maz-transition-expand.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
---
title: MazTransitionExpand
description: MazTransitionExpand 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
---

# MazTransitionExpand


> Before you have to import the global css files in your project, follow instructions in [Getting Started](/maz-ui-3/guide/getting-started.html)


## Basic usage

<br />
Expand All @@ -18,6 +15,7 @@ description: MazTransitionExpand is a stand-alone component replaces the standar
<br />
<br />

<ClientOnly>
<div class="flex items-start gap-05">
<MazCard class="flex-1">
<MazTransitionExpand>
Expand Down Expand Up @@ -56,6 +54,7 @@ description: MazTransitionExpand is a stand-alone component replaces the standar
</MazTransitionExpand>
</MazCard>
</div>
</ClientOnly>

```vue
<template>
Expand Down
66 changes: 37 additions & 29 deletions packages/docs/docs/helpers/idle-timeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {
<br />

<div class="flex items-start gap-05 items-center flex-wrap">
<MazBtn @click="idleTimeoutInstance.pause()" color="warning">
<MazBtn @click="idleTimeoutInstance?.pause" color="warning">
Pause
</MazBtn>
<MazBtn @click="idleTimeoutInstance.resume()">
<MazBtn @click="idleTimeoutInstance?.resume">
Resume
</MazBtn>
<MazBtn @click="idleTimeoutInstance.reset()" color="secondary">
<MazBtn @click="idleTimeoutInstance?.reset" color="secondary">
Reset
</MazBtn>
<MazBtn @click="idleTimeoutInstance.destroy()" color="danger">
<MazBtn @click="idleTimeoutInstance?.destroy" color="danger">
Destroy
</MazBtn>
</div>
Expand All @@ -55,8 +55,8 @@ const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {

<MazCard overflow-hidden style="width: 100%;">
<div style="display: flex;">
<div style="flex: 1;">isIdle: {{event.isIdle}}</div>
<div v-if="event.eventType" style="flex: 1; padding-left: 10px;">eventType: {{event.eventType}}</div>
<div style="flex: 1;">isIdle: {{event.isIdle ?? false}}</div>
<div v-if="event.eventType" style="flex: 1; padding-left: 10px;">eventType: {{event.eventType ?? '-' }}</div>
</div>
</MazCard>

Expand All @@ -66,16 +66,16 @@ const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {

```vue
<template>
<MazBtn @click="idleTimeoutInstance.pause()" color="warning">
<MazBtn @click="idleTimeoutInstance?.pause" color="warning">
Pause
</MazBtn>
<MazBtn @click="idleTimeoutInstance.resume()">
<MazBtn @click="idleTimeoutInstance?.resume">
Resume
</MazBtn>
<MazBtn @click="idleTimeoutInstance.reset()" color="secondary">
<MazBtn @click="idleTimeoutInstance?.reset" color="secondary">
Reset
</MazBtn>
<MazBtn @click="idleTimeoutInstance.destroy()" color="danger">
<MazBtn @click="idleTimeoutInstance?.destroy" color="danger">
Destroy
</MazBtn>

Expand All @@ -101,16 +101,9 @@ const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {
// for typescript users
import type { IdleTimeoutOptions, IdleTimeoutCallback } from 'maz-ui'

const event = ref<{ isIdle: boolean, eventType?: string }>()
const event = ref<{ isIdle: boolean, eventType?: string }>({})

const idleTimeoutOptions: IdleTimeoutOptions = {
immediate: false,
element: document.body,
once: false,
timeout: 3000,
}

const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {
const idleTimeoutCallback: IdleTimeoutCallback = (payload) => {
console.log({ isIdle, eventType })

event.value = {
Expand All @@ -119,7 +112,18 @@ const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {
}
}

const idleTimeoutInstance = new IdleTimeout(idleTimeoutCallback, idleTimeoutOptions)
const idleTimeoutInstance = ref<IdleTimeout>()

onMounted(() => {
const idleTimeoutOptions: IdleTimeoutOptions = {
element: document.body,
timeout: 3000,
immediate: true,
once: false,
}

idleTimeoutInstance.value = new IdleTimeout(idleTimeoutCallback, idleTimeoutOptions)
})
</script>
```

Expand All @@ -133,14 +137,7 @@ const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {
// for typescript users
import type { IdleTimeoutOptions, IdleTimeoutCallback } from 'maz-ui'

const event = ref<{ isIdle: boolean, eventType?: string }>()

const idleTimeoutOptions: IdleTimeoutOptions = {
element: document.body,
timeout: 3000,
immediate: true,
once: false,
}
const event = ref<{ isIdle: boolean, eventType?: string }>({})

const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {
console.log({ isIdle, eventType })
Expand All @@ -151,7 +148,18 @@ const idleTimeoutCallback: IdleTimeoutCallback = ({ isIdle, eventType }) => {
}
}

const idleTimeoutInstance = new IdleTimeout(idleTimeoutCallback, idleTimeoutOptions)
const idleTimeoutInstance = ref<IdleTimeout>()

onMounted(() => {
const idleTimeoutOptions: IdleTimeoutOptions = {
element: document.body,
timeout: 3000,
immediate: true,
once: false,
}

idleTimeoutInstance.value = new IdleTimeout(idleTimeoutCallback, idleTimeoutOptions)
})
</script>

## Options
Expand Down
16 changes: 12 additions & 4 deletions packages/docs/docs/helpers/user-visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const userVisibilyCallback: UserVisibilyCallback = ({ isVisible }) => {

<br />

<MazBtn @click="userVisibilityInstance.destroy()" color="danger">
<MazBtn @click="userVisibilityInstance?.destroy" color="danger">
Destroy
</MazBtn>

Expand All @@ -50,7 +50,7 @@ const userVisibilyCallback: UserVisibilyCallback = ({ isVisible }) => {

```vue
<template>
<MazBtn @click="userVisibilityInstance.destroy()" color="danger">
<MazBtn @click="userVisibilityInstance?.destroy" color="danger">
Destroy
</MazBtn>

Expand Down Expand Up @@ -84,7 +84,11 @@ const userVisibilyCallback: UserVisibilyCallback = ({ isVisible }) => {
timeout: 1000,
}

const userVisibilityInstance = new UserVisibility(userVisibilyCallback, userVisibilyOptions)
const userVisibilityInstance = ref<UserVisibility>()

onMounted(() => {
userVisibilityInstance.value = new UserVisibility(userVisibilyCallback, userVisibilyOptions)
})
</script>
```

Expand All @@ -111,7 +115,11 @@ const userVisibilyCallback: UserVisibilyCallback = ({ isVisible }) => {
timeout: 1000,
}

const userVisibilityInstance = new UserVisibility(userVisibilyCallback, userVisibilyOptions)
const userVisibilityInstance = ref<UserVisibility>()

onMounted(() => {
userVisibilityInstance.value = new UserVisibility(userVisibilyCallback, userVisibilyOptions)
})
</script>

## Options
Expand Down
3 changes: 3 additions & 0 deletions packages/lib/package/components/MazTransitionExpand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
AFTER_ENTERING = 'entering',
LEAVING = 'entering',
}

const state = ref<States>(States.NONE)

const enter = (element: HTMLElement) => {
Expand Down Expand Up @@ -57,13 +58,15 @@
element.style.height = height
})
}

const afterEnter = (element: HTMLElement) => {
if (state.value !== States.NONE) {
return
}

element.style.height = 'auto'
}

const leave = (element: HTMLElement) => {
if (state.value !== States.NONE) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class IdleTimeout {

this.resetTimeout()

this.callback({ isIdle: this.isIdle })
this.callback({ isIdle: this.isIdle, eventType: event.type })
} catch (error) {
throw new Error(`[IdleTimeout](handleEvent) ${error}`)
}
Expand Down
9 changes: 7 additions & 2 deletions packages/lib/tests/unit/specs/helpers/idle-timeout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ describe('@/plugins/idle-timeout/idle-timeout-handler.ts', () => {
it('Then user is new not idle callback called and idle equal "false"', async () => {
await sleep(DEFAULT_TIMEOUT)
expect(instance?.idle).toBeTruthy()
expect(callback).toHaveBeenCalledWith({ isIdle: true })
expect(callback).toHaveBeenCalledWith({
isIdle: true,
})

/* eslint-disable */
// @ts-ignore
Expand All @@ -57,7 +59,10 @@ describe('@/plugins/idle-timeout/idle-timeout-handler.ts', () => {
/* eslint-enable */

// expect(instance?.idle).toBeFalsy()
expect(callback).toHaveBeenCalledWith({ isIdle: false })
expect(callback).toHaveBeenCalledWith({
isIdle: false,
eventType: 'mousemove',
})
})

it('Then idle is "true" and callback called after time', async () => {
Expand Down