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

feat: add NeEmptyState #29

Merged
merged 1 commit into from
Feb 28, 2024
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
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 }
}