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

Update banner to match new designs and add analytics notification #2132

Merged
merged 29 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a729c36
Update banner styles
zackkrida May 17, 2023
9670f74
Merge branch 'main' into banner-style-refresh
zackkrida May 17, 2023
b86d849
Merge branch 'main' into banner-style-refresh
zackkrida May 17, 2023
31eac8e
Conditionally show styled banner container
zackkrida May 17, 2023
239ca36
Merge branch 'banner-style-refresh' of github.com:WordPress/openverse…
zackkrida May 17, 2023
62664c8
Reduce padding
zackkrida May 18, 2023
766427e
Fix erroneous spaces around link
dhruvkb May 18, 2023
230baa6
Add semantic colors and icons
dhruvkb May 18, 2023
4ef6655
Add missing prop-type for `VIconButton` size
dhruvkb May 18, 2023
56963b1
Revamp banner and update usages
dhruvkb May 18, 2023
3d14dde
Determine variant based on current page
dhruvkb May 18, 2023
7e1a328
Add stories and tests
dhruvkb May 18, 2023
a6c7470
Add a banner for analytics
dhruvkb May 18, 2023
365dfae
Move `.value` into the predicate
dhruvkb May 19, 2023
5db7990
Update tests
dhruvkb May 18, 2023
1a30977
Make banners black on 404 page
dhruvkb May 19, 2023
177898b
Dismiss banners before more tests
dhruvkb May 19, 2023
bd6b1b8
Give fixed header white bg behind banners
zackkrida May 19, 2023
deb84d2
Merge branch 'banner-style-refresh' into new_banner_designs
dhruvkb May 19, 2023
f6c3318
Merge branch 'main' into new_banner_designs
dhruvkb May 19, 2023
1a8b1e7
Update icons
dhruvkb May 23, 2023
d22b852
Update design tokens
dhruvkb May 23, 2023
1525a20
Slightly adjust sizes and spaces
dhruvkb May 23, 2023
fc816ce
Update snapshots
dhruvkb May 23, 2023
d8aa082
Merge branch 'main' of https://github.com/WordPress/openverse into ne…
dhruvkb May 23, 2023
480f09a
Update all-banner snapshots
dhruvkb May 23, 2023
793ecc9
Merge branch 'main' of https://github.com/WordPress/openverse into ne…
dhruvkb May 24, 2023
d9877e4
Enable analytics by default
dhruvkb May 24, 2023
50bb0f7
Flip the switch in VR snapshots
dhruvkb May 24, 2023
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
5 changes: 5 additions & 0 deletions frontend/src/assets/svg/raw/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions frontend/src/assets/svg/raw/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions frontend/src/assets/svg/raw/success.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions frontend/src/assets/svg/raw/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions frontend/src/components/VBanner/VAnalyticsNotice.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<VNotificationBanner
v-bind="$attrs"
id="analytics"
nature="info"
:close-button-label="$t('notification.analytics.close')"
@close="$emit('close')"
>
<i18n tag="span" path="notification.analytics.text">
<template #link>
<VLink :href="privacyPath" class="text-curr underline">{{
$t("notification.analytics.link")
}}</VLink>
</template>
</i18n>
</VNotificationBanner>
</template>

<script lang="ts">
import { computed, defineComponent } from "vue"
import { useContext } from "@nuxtjs/composition-api"

import VNotificationBanner from "~/components/VBanner/VNotificationBanner.vue"

export default defineComponent({
name: "VAnalyticsNotice",
components: { VNotificationBanner },
inheritAttrs: false,
setup() {
const { app } = useContext()
const privacyPath = computed(() => app.localePath("/privacy"))

return {
privacyPath,
}
},
})
</script>
32 changes: 28 additions & 4 deletions frontend/src/components/VBanner/VBanners.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
<div v-show="showBanners" class="flex flex-col gap-2 p-2 pb-0">
<VMigrationNotice
v-if="shouldShowMigrationBanner"
:variant="variant"
@close="dismissBanner('cc-referral')"
/>
<VAnalyticsNotice
v-if="shouldShowAnalyticsBanner"
:variant="variant"
@close="dismissBanner('analytics')"
/>
<VTranslationStatusBanner
v-if="shouldShowTranslationBanner"
:variant="variant"
:banner-key="translationBannerId"
@close="dismissBanner(translationBannerId)"
/>
Expand All @@ -18,14 +25,17 @@
import { computed, defineComponent } from "vue"

import { useUiStore } from "~/stores/ui"
import type { TranslationBannerId } from "~/types/banners"
import usePages from "~/composables/use-pages"

import type { TranslationBannerId, BannerId } from "~/types/banners"

export default defineComponent({
name: "VBanners",
components: {
VMigrationNotice: () => import("~/components/VBanner/VMigrationNotice.vue"),
VTranslationStatusBanner: () =>
import("~/components/VBanner/VTranslationStatusBanner.vue"),
VAnalyticsNotice: () => import("~/components/VBanner/VAnalyticsNotice.vue"),
},
setup() {
const uiStore = useUiStore()
Expand All @@ -35,25 +45,39 @@ export default defineComponent({
const shouldShowTranslationBanner = computed(
() => uiStore.shouldShowTranslationBanner
)
const shouldShowAnalyticsBanner = computed(
() => uiStore.shouldShowAnalyticsBanner
)

const translationBannerId = computed<TranslationBannerId>(
() => uiStore.translationBannerId
)

const dismissBanner = (bannerKey: TranslationBannerId) => {
const { current: currentPage } = usePages()
const variant = computed(() =>
["", "index"].includes(currentPage.value) ? "dark" : "regular"
)

const dismissBanner = (bannerKey: BannerId) => {
uiStore.dismissBanner(bannerKey)
}

const showBanners = computed(
() => shouldShowMigrationBanner.value || shouldShowTranslationBanner.value
const showBanners = computed(() =>
[
shouldShowMigrationBanner,
shouldShowTranslationBanner,
shouldShowAnalyticsBanner,
].some((item) => item.value)
)

return {
translationBannerId,
shouldShowMigrationBanner,
shouldShowTranslationBanner,
shouldShowAnalyticsBanner,
showBanners,
dismissBanner,
variant,
}
},
})
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/VBanner/VMigrationNotice.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<VNotificationBanner
v-bind="$attrs"
id="cc-referral"
variant="announcement"
nature="info"
:close-button-label="$t('migration-notice.close')"
@close="$emit('close')"
>
Expand All @@ -15,11 +16,10 @@
<i18n tag="span" path="migration-notice.more">
<template #read-more>
<VLink
class="font-bold text-white underline"
class="text-curr underline"
href="https://wordpress.org/news/2021/05/welcome-to-openverse/"
>{{ $t("migration-notice.read") }}</VLink
>
{{ $t("migration-notice.read") }}
</VLink>
</template>
</i18n>
</VNotificationBanner>
Expand All @@ -34,5 +34,6 @@ import VLink from "~/components/VLink.vue"
export default defineComponent({
name: "VMigrationNotice",
components: { VLink, VNotificationBanner },
inheritAttrs: false,
})
</script>
91 changes: 68 additions & 23 deletions frontend/src/components/VBanner/VNotificationBanner.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<template>
<section
class="flex items-center justify-between gap-x-2 rounded-sm px-4 py-2 md:px-7"
:class="$style[variant]"
class="flex flex-row items-center gap-2 rounded-sm p-2 lg:px-3 lg:py-4"
:class="classNames"
:data-testid="`banner-${id}`"
>
<p class="caption-regular md:description-regular text-left">
<slot name="default" />
<slot name="start">
<VIcon :name="nature" :class="iconClassNames" />
</slot>

<p class="caption-regular lg:paragraph-small flex-grow">
<slot />
</p>
<slot name="buttons">

<slot name="end">
<VCloseButton
variant="filled-transparent"
icon-size="large"
class="flex-grow-0"
variant="plain--avoid"
size="tiny"
icon-size="small"
:label="closeButtonLabel || $t('modal.close-banner')"
@close="$emit('close')"
/>
Expand All @@ -19,49 +26,87 @@
</template>

<script lang="ts">
import { defineComponent, PropType } from "vue"
import { defineComponent, PropType, computed } from "vue"

import { defineEvent } from "~/types/emits"

import type { BannerId } from "~/types/banners"

import VIcon from "~/components/VIcon/VIcon.vue"
import VCloseButton from "~/components/VCloseButton.vue"

import type { TranslateResult } from "vue-i18n"

/**
* Display a banner that can indicate one of four semantics in one of two color
* variants.
*/
export default defineComponent({
name: "VNotificationBanner",
components: {
VIcon,
VCloseButton,
},
props: {
/**
* the semantic meaning of the banner; This can carry a positive, neutral
* or negative connotation.
*/
nature: {
type: String as PropType<"info" | "warning" | "success" | "error">,
default: "info",
},
/**
* the color variant of the banner; The dark variant is intended for use on
* yellow pages.
*/
variant: {
type: String as PropType<"announcement" | "informational">,
required: true,
type: String as PropType<"regular" | "dark">,
default: "regular",
},
/**
* the unique ID of the banner
*/
id: {
type: String as PropType<BannerId>,
required: true,
},
/**
* the label to apply to the close button
*/
closeButtonLabel: {
type: [String, Object] as PropType<string | TranslateResult>,
},
},
emits: {
close: defineEvent(),
},
setup(props) {
const classNames = computed(() =>
props.variant === "dark"
? "bg-dark-charcoal text-white"
: {
info: "bg-info-soft",
warning: "bg-warning-soft",
success: "bg-success-soft",
error: "bg-error-soft",
}[props.nature]
)
const iconClassNames = computed(() =>
props.variant === "dark"
? ""
: {
info: "text-info",
warning: "text-warning",
success: "text-success",
error: "text-error",
}[props.nature]
)

return {
classNames,
iconClassNames,
}
},
})
</script>

<style module>
/* Styles from learn.wordpress.org */
.informational {
background-color: #fff8e5;
border-left: 0.25rem solid #ffb900;
}

.announcement {
@apply bg-trans-blue text-white;
border-left: 0.25rem solid transparent;
}
</style>
10 changes: 4 additions & 6 deletions frontend/src/components/VBanner/VTranslationStatusBanner.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<template>
<VNotificationBanner
v-bind="$attrs"
:id="bannerKey"
variant="informational"
nature="warning"
data-testid="banner-translation"
:close-button-label="$t('notification.translation.close')"
@close="$emit('close')"
>
{{
// eslint-disable-next-line @intlify/vue-i18n/no-raw-text
"⚠️"
}}
<i18n path="notification.translation.text">
<template #link>
<VLink :href="currentLocale.link" class="underline">{{
<VLink :href="currentLocale.link" class="text-curr underline">{{
$t("notification.translation.link")
}}</VLink>
</template>
Expand Down Expand Up @@ -41,6 +38,7 @@ export default defineComponent({
VLink,
VNotificationBanner,
},
inheritAttrs: false,
props: {
bannerKey: {
type: String as PropType<BannerId>,
Expand Down
Loading