Skip to content

Commit

Permalink
feat: add NeEmptyState (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 authored Feb 28, 2024
1 parent aa9d83e commit f1211ca
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/components/NeEmptyState.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
Copyright (C) 2024 Nethesis S.r.l.
SPDX-License-Identifier: GPL-3.0-or-later
-->

<script setup lang="ts">
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

defineProps({
title: {
type: String,
default: ''
},
description: {
type: String,
default: ''
},
icon: {
type: Object,
default: undefined
}
})
</script>

<template>
<div class="bg-gray-100 px-6 py-7 text-sm dark:bg-gray-800 sm:rounded-md sm:px-8">
<div class="flex flex-col items-center">
<FontAwesomeIcon
v-if="icon"
:icon="icon"
class="mb-5 h-14 w-14 text-gray-400 dark:text-gray-500"
/>
<div v-if="title" class="text-base font-medium text-gray-700 dark:text-gray-200">
{{ title }}
</div>
<div v-if="description" class="mt-1 text-gray-600 dark:text-gray-400">{{ description }}</div>
<div v-if="$slots.default" class="mt-5">
<slot />
</div>
</div>
</div>
</template>
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export { default as NeLink } from '@/components/NeLink.vue'
export { default as NeFormItemLabel } from '@/components/NeFormItemLabel.vue'
export { default as NeRadioSelection } from '@/components/NeRadioSelection.vue'
export { default as NePaginator } from '@/components/NePaginator.vue'
export { default as NeEmptyState } from '@/components/NeEmptyState.vue'

// types export
export type { NeComboboxOption } from '@/components/NeCombobox.vue'
Expand Down
74 changes: 74 additions & 0 deletions stories/NeEmptyState.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (C) 2024 Nethesis S.r.l.
// SPDX-License-Identifier: GPL-3.0-or-later

import type { Meta, StoryObj } from '@storybook/vue3'
import { NeEmptyState } from '../src/main'
import { NeButton } from '../src/main'
import { faUsers } from '@fortawesome/free-solid-svg-icons'
import { library } from '@fortawesome/fontawesome-svg-core'

library.add(faUsers)

const meta = {
title: 'Visual/NeEmptyState',
component: NeEmptyState,
argTypes: {},
args: {
title: 'No user',
description: 'There is no user configured on the system',
icon: undefined
} // default values
} satisfies Meta<typeof NeEmptyState>

export default meta
type Story = StoryObj<typeof meta>

const template = '<NeEmptyState v-bind="args" />'

export const Default: Story = {
render: (args) => ({
components: { NeEmptyState },
setup() {
return { args }
},
template: template
}),
args: {}
}

export const WithIcon: Story = {
render: (args) => ({
components: { NeEmptyState },
setup() {
return { args }
},
template: template
}),
args: { icon: faUsers }
}

const templateWithSlot = `<NeEmptyState v-bind="args">
<NeButton kind="primary">Create user</NeButton>
</NeEmptyState>`

export const WithSlot: Story = {
render: (args) => ({
components: { NeEmptyState, NeButton },
setup() {
return { args }
},
template: templateWithSlot
}),
args: {}
}

export const WithSlotAndIcon: Story = {
render: (args) => ({
components: { NeEmptyState, NeButton },
setup() {
return { args }
},
template: templateWithSlot
}),
args: { icon: faUsers }
}

0 comments on commit f1211ca

Please sign in to comment.