Skip to content

Commit

Permalink
docs(Banner): update display logic
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Jan 22, 2024
1 parent 416a9a5 commit 2d70c07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/docs/src/components/app/Banner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</a>
<template #append>
<v-hover v-if="mdAndUp && banner.metadata.link">
<v-hover v-if="mdAndUp && banner.metadata.link && banner.metadata.link_text">
<template #default="{ isHovering, props }">
<v-btn
:color="banner.metadata.link_color"
Expand Down Expand Up @@ -89,7 +89,7 @@
const banners = useBannersStore()
const banner = computed(() => banners.banner)
const height = computed(() => banner.value?.metadata.subtext ? 88 : 48)
const height = computed(() => banner.value?.metadata.height || (banner.value?.metadata.subtext ? 88 : 48))
const hasPromotion = computed(() => {
return !banner.value || !user.notifications.last.banner.includes(banner.value.slug)
})
Expand Down
6 changes: 6 additions & 0 deletions packages/docs/src/store/banners.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Composables
import { useCosmic } from '@/composables/cosmic'
import { useDate } from 'vuetify'
import { useUserStore } from '@vuetify/one'

// Utilities
import { defineStore } from 'pinia'
Expand All @@ -16,6 +17,7 @@ interface Banner {
closable: boolean
color: string
label: string
height: number
text: string
subtext: string
link: string
Expand Down Expand Up @@ -96,18 +98,22 @@ export const useBannersStore = defineStore('banners', {
},
getters: {
banner (state) {
const user = useUserStore()
const name = state.router.currentRoute.value.meta.page

if (this.server) return this.server

return state.banners.find(({
slug,
metadata: {
visible,
active,
},
}) => {
if (!active) return false

if (user.notifications.last.banner.includes(slug)) return false

if (visible.key === 'both') return true
// '' is home
if (visible.key === 'home' && name === '') return true
Expand Down

0 comments on commit 2d70c07

Please sign in to comment.