Skip to content

Commit

Permalink
va-affix stories (#3711)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman4437 authored Aug 29, 2023
1 parent 8f2c8db commit 42cee62
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 94 deletions.
90 changes: 0 additions & 90 deletions packages/ui/src/components/va-affix/VaAffix.demo.vue

This file was deleted.

47 changes: 43 additions & 4 deletions packages/ui/src/components/va-affix/VaAffix.stories.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,51 @@
import { defineComponent } from 'vue'
import VaAffix from './VaAffix.demo.vue'
import { VaAffix } from './'
import { expect } from '@storybook/jest'

export default {
title: 'VaAffix',
component: VaAffix,
}

export const Default = defineComponent({
export const FixedTop = () => ({
components: { VaAffix },
template: '<VaAffix/>',
template: `
<div class="w-1/4">
<p class="m-1">{{$vb.lorem(100)}}</p>
<VaAffix :offset-top="100">
<div class="p-3 bg-red-500">Fixed at the top: 100</div>
</VaAffix>
<p class="m-1">{{$vb.lorem(2500)}}</p>
</div>
`,
})

FixedTop.play = async ({ step }) => {
window.scrollTo({ top: document.body.scrollHeight })
const affix = document.querySelector('.va-affix--affixed') as HTMLElement

await step('100px offset top', async () => {
expect(affix.style.top).toEqual('100px')
})
}

export const FixedBottom = () => ({
components: { VaAffix },
template: `
<div class="w-1/4">
<p class="m-1">{{$vb.lorem(2500)}}</p>
<VaAffix :offset-bottom="100">
<div class="p-3 bg-red-500">Fixed at the bottom: 100</div>
</VaAffix>
<p class="m-1">{{$vb.lorem(100)}}</p>
</div>
`,
})

FixedBottom.play = async ({ step }) => {
window.scrollTo({ top: 0 })
const affix = document.querySelector('.va-affix--affixed') as HTMLElement

await step('100px offset bottom', async () => {
expect(affix.style.bottom).toEqual('100px')
})
}

0 comments on commit 42cee62

Please sign in to comment.