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 empty content icon slot in DashboardWidget #3034

Merged
merged 2 commits into from
Aug 15, 2022
Merged
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
37 changes: 17 additions & 20 deletions src/components/DashboardWidget/DashboardWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,17 @@ export default {
</docs>

<template>
<div>
<div class="dashboard-widget">
<!-- This element is shown if we have items, but want to show a general message as well.
Can be used e.g. to show "No mentions" on top of the item list. -->
<EmptyContent v-if="showHalfEmptyContentArea"
class="half-screen"
:icon="halfEmptyContentIcon">
class="half-screen">
<template #icon>
<!-- @slot The icon to show in the half empty content area. -->
<slot name="halfEmptyContentIcon">
<Check />
</slot>
</template>
<template #desc>
{{ halfEmptyContentString }}
</template>
Expand Down Expand Up @@ -172,8 +177,11 @@ export default {
</div>
<!-- @slot Slot for showing information in case of an empty item list. -->
<slot v-else-if="items.length === 0" name="empty-content">
<EmptyContent v-if="emptyContentMessage"
:icon="emptyContentIcon">
<EmptyContent v-if="emptyContentMessage">
<template #icon>
<!-- @slot The icon to show in the empty content area. -->
<slot name="emptyContentIcon" />
</template>
<template #desc>
{{ emptyContentMessage }}
</template>
Expand All @@ -195,6 +203,8 @@ import Avatar from '../Avatar/index.js'
import DashboardWidgetItem from '../DashboardWidgetItem/index.js'
import EmptyContent from '../EmptyContent/index.js'

import Check from 'vue-material-design-icons/Check.vue'

import { t } from '../../l10n.js'

export default {
Expand All @@ -203,6 +213,7 @@ export default {
Avatar,
DashboardWidgetItem,
EmptyContent,
Check,
},

props: {
Expand Down Expand Up @@ -251,27 +262,13 @@ export default {
type: Boolean,
default: false,
},
/**
* The icon to show in the empty content area.
*/
emptyContentIcon: {
type: String,
default: '',
},
/**
* The text to show in the empty content area.
*/
emptyContentMessage: {
type: String,
default: '',
},
/**
* The icon to show in the half empty content area.
*/
halfEmptyContentIcon: {
type: String,
default: 'icon-checkmark',
},
/**
* The text to show in the half empty content area.
*/
Expand Down Expand Up @@ -323,7 +320,7 @@ export default {
</script>

<style scoped lang="scss">
.empty-content {
.dashboard-widget .empty-content {
text-align: center;
margin-top: 5vh;

Expand Down