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

Implement Section, Loading and emptyState #17

Merged
merged 9 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
168 changes: 84 additions & 84 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions src/assets/svg/empty-state.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/components/EmptyState/WEmptyState.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import WEmptyState from './WEmptyState.vue'

describe('WEmptyState', () => {
it('renders properly', () => {
const wrapper = mount(WEmptyState, {
props: {
text: 'Empty state'
}
})

expect(wrapper.element).toMatchSnapshot()
})
})
40 changes: 40 additions & 0 deletions src/components/EmptyState/WEmptyState.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Meta, StoryObj } from '@storybook/vue3'
// import { fn } from '@storybook/test';
import WEmptyState from './WEmptyState.vue'

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
const meta: any = {
title: 'Example/WEmptyState',
component: WEmptyState,
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
argTypes: {
// type: { control: 'select', options: ['primary', 'secondary', 'arrow', 'dark'] }
},
args: {
// type: 'primary'
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
// onClick: fn(),
}
} satisfies Meta<typeof WEmptyState>

export default meta
type Story = StoryObj<typeof meta>
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/api/csf
* to learn how to use render functions.
*/

export const Section: Story = {
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
render: (args: any) => ({
components: { WEmptyState },
setup() {
return { args }
},
template: `<WEmptyState v-bind="args" />`
}),
args: {
text: 'Empty state text'
}
}
16 changes: 16 additions & 0 deletions src/components/EmptyState/WEmptyState.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div class="grid gap-md justify-center align-middle">
<EmptyStateLogo class="w-max" />
<p>{{ text }}</p>
</div>
</template>

<script setup>
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
import EmptyStateLogo from '@/assets/svg/empty-state.svg?component'
defineProps({
text: {
type: String,
required: true
}
})
</script>
164 changes: 164 additions & 0 deletions src/components/EmptyState/__snapshots__/WEmptyState.spec.ts.snap

Large diffs are not rendered by default.

36 changes: 17 additions & 19 deletions src/components/Footer/WFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,23 @@
<WitOracleIcon class="w-[140px] h-auto white" name="witnet_dark" />
<div class="h-max self-center">
<p class="copyright max-w-100 footer-text">
© <span>2018-{{ new Date().getFullYear() }}</span
>
<slot name="custom-contributors">
<span>
by <a :href=WITNET_FOUNDATION_URL target="_blank">
Witnet Foundation
</a> and individual contributors.
</span>
</slot>
© <span>2018-{{ new Date().getFullYear() }}</span>
<slot name="custom-contributors">
<span>
by <a :href="WITNET_FOUNDATION_URL" target="_blank"> Witnet Foundation </a> and
individual contributors.
</span>
</slot>
</p>
<p class="copyright max-w-100 footer-text">
<slot name="custom-license">
<span>
Content available under a
<a :href="CREATIVE_COMMONS_URL" target="_blank"> Creative Commons License </a>
.
</span>
</slot>
</p>
<p class="copyright max-w-100 footer-text"><slot name="custom-license">
<span>
Content available under a
<a :href=CREATIVE_COMMONS_URL target="_blank">
Creative Commons License
</a>
.
</span>
</slot></p>
</div>
<!-- <client-only>
<LanguageSwitcher class="justify-self-end self-center" />
Expand Down Expand Up @@ -92,6 +90,6 @@ defineProps({
adoDescription: {
type: String,
default: `Witnet is part of the Alliance of Decentralized Oracles (ADO), a joint effort by leading decentralized oracle solutions to make the life of smart contract developers easier by creating oracle standards. Learn more about the ADO at`
},
}
})
</script>
17 changes: 17 additions & 0 deletions src/components/LoadingPlaceholder/WLoadingPlaceholder.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import WLoadingPlaceholder from './WLoadingPlaceholder.vue'

describe('WLoadingPlaceholder', () => {
it('renders properly', () => {
const wrapper = mount(WLoadingPlaceholder, {
props: {
height: '100px',
width: '150px',
borderRadius: '8%'
}
})

expect(wrapper.element).toMatchSnapshot()
})
})
42 changes: 42 additions & 0 deletions src/components/LoadingPlaceholder/WLoadingPlaceholder.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Meta, StoryObj } from '@storybook/vue3'
// import { fn } from '@storybook/test';
import WLoadingPlaceholder from './WLoadingPlaceholder.vue'

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
const meta: any = {
title: 'Example/WLoadingPlaceholder',
component: WLoadingPlaceholder,
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
argTypes: {
// type: { control: 'select', options: ['primary', 'secondary', 'arrow', 'dark'] }
},
args: {
// type: 'primary'
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
// onClick: fn(),
}
} satisfies Meta<typeof WLoadingPlaceholder>

export default meta
type Story = StoryObj<typeof meta>
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/api/csf
* to learn how to use render functions.
*/

export const Section: Story = {
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
render: (args: any) => ({
components: { WLoadingPlaceholder },
setup() {
return { args }
},
template: `<WLoadingPlaceholder v-bind="args" />`
}),
args: {
height: '100px',
width: '150px',
borderRadius: '8%'
}
}
40 changes: 40 additions & 0 deletions src/components/LoadingPlaceholder/WLoadingPlaceholder.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<div
class="placeholder bg-gray-50 bg-opacity-60 bg-gradient-to-r from-gray-50 shadow-sm shadow-gray-100 bg-[length:200%_200%]"
>
&nbsp;
</div>
<span class="sr-only">Loading...</span>
</template>
<script setup>
defineProps({
height: {
type: String,
required: true
},
width: {
type: String,
required: true
},
borderRadius: {
type: String,
required: true
}
})
</script>
<style scoped lang="scss">
@keyframes bgAnimate {
0% {
background-position: 50% 0;
}
100% {
background-position: -150% 0;
}
}
.placeholder {
height: v-bind(height);
width: v-bind(width);
border-radius: v-bind(borderRadius);
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
animation: bgAnimate 1.2s linear infinite;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`WLoadingPlaceholder > renders properly 1`] = `
<div
data-v-app=""
>

<div
class="placeholder bg-gray-50 bg-opacity-60 bg-gradient-to-r from-gray-50 shadow-sm shadow-gray-100 bg-[length:200%_200%]"
data-v-bd9b9d04=""
>

</div>
<span
class="sr-only"
data-v-bd9b9d04=""
>
Loading...
</span>

</div>
`;
20 changes: 20 additions & 0 deletions src/components/Section/WSection.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, it, expect } from 'vitest'
import { h } from 'vue'
import { mount } from '@vue/test-utils'
import WSection from './WSection.vue'

describe('WSection', () => {
it('renders properly', () => {
const wrapper = mount(WSection, {
props: {
frameClasses: 'bg-black-950',
contentClasses: 'grid justify-items-center'
},
slots: {
content: h('p', 'Section content')
}
})

expect(wrapper.element).toMatchSnapshot()
})
})
45 changes: 45 additions & 0 deletions src/components/Section/WSection.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { Meta, StoryObj } from '@storybook/vue3'
// import { fn } from '@storybook/test';
import WSection from './WSection.vue'

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
const meta: any = {
title: 'Example/WSection',
component: WSection,
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
argTypes: {
// type: { control: 'select', options: ['primary', 'secondary', 'arrow', 'dark'] }
},
args: {
// type: 'primary'
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
// onClick: fn(),
}
} satisfies Meta<typeof WSection>

export default meta
type Story = StoryObj<typeof meta>
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/api/csf
* to learn how to use render functions.
*/

export const Section: Story = {
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
render: (args: any) => ({
components: { WSection },
setup() {
return { args }
},
template: `<WSection v-bind="args">
<template #content>
<p class="text-white-50">Section content<p>
</template>
</WSection>`
}),
args: {
frameClasses: 'bg-black-950',
contentClasses: 'grid justify-items-center'
}
}
17 changes: 17 additions & 0 deletions src/components/Section/__snapshots__/WSection.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`WSection > renders properly 1`] = `
<div
class="w-full h-full bg-black-950"
>
<div
class="content p-[100px] m-[0_auto] max-w-[1100px] w-full sm:p-[70px_32px] xs:p-[70px_16px] z-50 grid justify-items-center"
>

<p>
Section content
</p>

</div>
</div>
`;
11 changes: 11 additions & 0 deletions src/components/Spinner/WSpinner.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import WSpinner from './WSpinner.vue'

describe('WSpinner', () => {
it('renders properly', () => {
const wrapper = mount(WSpinner)

expect(wrapper.element).toMatchSnapshot()
})
})
25 changes: 25 additions & 0 deletions src/components/Spinner/WSpinner.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Meta, StoryObj } from '@storybook/vue3'
import WSpinner from './WSpinner.vue'

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
const meta: any = {
title: 'Example/WSpinner',
component: WSpinner,
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
argTypes: {},
args: {}
} satisfies Meta<typeof WSpinner>

export default meta
type Story = StoryObj<typeof meta>

export const Section: Story = {
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
render: (args: any) => ({
components: { WSpinner },
setup() {
return { args }
},
template: `<WSpinner />`
})
}
22 changes: 22 additions & 0 deletions src/components/Spinner/WSpinner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<div role="status">
<svg
gabaldon marked this conversation as resolved.
Show resolved Hide resolved
aria-hidden="true"
class="w-8 h-8 text-gray-100 animate-spin fill-wit-blue-500"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span class="sr-only">Loading...</span>
</div>
</template>
<script lang="ts" setup></script>
Loading