Skip to content

Commit

Permalink
Implement VAR for C24_WMDE_Mobile_DE_13
Browse files Browse the repository at this point in the history
VAR has an auto-collapse feature

Ticket: https://phabricator.wikimedia.org/T381954
  • Loading branch information
Abban committed Dec 18, 2024
1 parent fa6e20c commit b578e82
Show file tree
Hide file tree
Showing 17 changed files with 463 additions and 21 deletions.
4 changes: 2 additions & 2 deletions banners/mobile/C24_WMDE_Mobile_DE_13/banner_var.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createVueApp } from '@src/createVueApp';

import './styles/styles.scss';
import './styles/styles_var.scss';

import BannerConductor from '@src/components/BannerConductor/BannerConductor.vue';
import Banner from './components/BannerVar.vue';
Expand All @@ -16,7 +16,7 @@ import DynamicTextPlugin from '@src/DynamicTextPlugin';
import { LocalImpressionCount } from '@src/utils/LocalImpressionCount';
import { WindowPageScroller } from '@src/utils/PageScroller/WindowPageScroller';
import { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG';
import eventMappings from './event_map';
import eventMappings from './event_map_var';
import messages from './messages';
import { LocaleFactoryDe } from '@src/utils/LocaleFactory/LocaleFactoryDe';
import { createFormItems } from './form_items';
Expand Down
54 changes: 43 additions & 11 deletions banners/mobile/C24_WMDE_Mobile_DE_13/components/BannerVar.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<template>
<div class="wmde-banner-wrapper" :class="contentState">
<MiniBanner
v-if="contentState === ContentStates.Mini"
@close="onCloseMiniBanner"
@show-full-page-banner="onshowFullPageBanner"
@show-full-page-banner-preselected="onshowFullPageBannerPreselected"
@show-full-page-banner="onShowFullPageBanner"
@show-full-page-banner-preselected="onShowFullPageBannerPreselected"
>
<template #banner-slides>
<KeenSlider :with-navigation="false" :play="slideshowShouldPlay" :interval="5000">
Expand All @@ -18,6 +19,12 @@
</template>
</MiniBanner>

<MinimisedBanner
v-if="contentState === ContentStates.Minimised"
@close="onCloseMinimisedBanner"
@show-full-page-banner="onShowFullPageBannerFromMinimised"
/>

<FullPageBanner
@showFundsModal="isFundsModalVisible = true"
@close="() => onClose( 'FullPageBanner', CloseChoices.Hide )"
Expand Down Expand Up @@ -151,9 +158,13 @@ import { FormItem } from '@src/utils/FormItemsBuilder/FormItem';
import FormItemsBuilder from '@src/utils/FormItemsBuilder/FormItemsBuilder';
import { Translator } from '@src/Translator';
import { Currency } from '@src/utils/DynamicContent/formatters/Currency';
import MinimisedBanner from '@banners/mobile/C24_WMDE_Mobile_DE_13/components/MinimisedBanner.vue';
import { MinimisedEvent } from '@src/tracking/events/MinimisedEvent';
import { useScrollMinimiser } from '@banners/mobile/C24_WMDE_Mobile_DE_13/useScrollMinimiser';
enum ContentStates {
Mini = 'wmde-banner-wrapper--mini',
Minimised = 'wmde-banner-wrapper--minimised',
FullPage = 'wmde-banner-wrapper--full-page',
SoftClosing = 'wmde-banner-wrapper--soft-closing'
}
Expand Down Expand Up @@ -193,6 +204,16 @@ const localFormItemsBuilder = new FormItemsBuilder( localTranslator, currencyFor
const amountOptionsFive = localFormItemsBuilder.setAmounts( 5, 15, 25, 50, 100 ).getItems().amounts;
const amountOptionsTen = localFormItemsBuilder.setAmounts( 10, 15, 25, 50, 100 ).getItems().amounts;
const amountOptionsForForm = ref<FormItem[]>( amountOptionsTen );
const wasMinimised = ref<boolean>( false );
useScrollMinimiser( 500, wasMinimised, () => {
if ( props.bannerState === BannerStates.Visible && contentState.value === ContentStates.Mini ) {
contentState.value = ContentStates.Minimised;
wasMinimised.value = true;
slideShowStopped.value = true;
tracker.trackEvent( new MinimisedEvent( 'MiniBanner', 'minimised' ) );
}
} );
watch( contentState, async () => {
emit( 'bannerContentChanged' );
Expand All @@ -206,6 +227,14 @@ function onCloseMiniBanner(): void {
}
}
function onCloseMinimisedBanner(): void {
if ( props.remainingImpressions > 0 ) {
contentState.value = ContentStates.SoftClosing;
} else {
onClose( 'MinimisedBanner', CloseChoices.Hide );
}
}
function onClose( feature: TrackingFeatureName, userChoice: CloseChoices ): void {
emit( 'bannerClosed', new CloseEvent( feature, userChoice ) );
emit( 'modalClosed' );
Expand All @@ -224,24 +253,27 @@ const onSubmit = (): void => {
}
};
function onshowFullPageBanner(): void {
function showFullPageBanner( fromFeature: string ): void {
slideShowStopped.value = true;
contentState.value = ContentStates.FullPage;
emit( 'modalOpened' );
tracker.trackEvent( new MobileMiniBannerExpandedEvent( fromFeature ) );
}
function onShowFullPageBanner(): void {
amountOptionsForForm.value = amountOptionsFive;
tracker.trackEvent( new MobileMiniBannerExpandedEvent() );
showFullPageBanner( '' );
}
function onshowFullPageBannerPreselected(): void {
slideShowStopped.value = true;
function onShowFullPageBannerPreselected(): void {
amountOptionsForForm.value = amountOptionsTen;
formModel.selectedAmount.value = '10';
contentState.value = ContentStates.FullPage;
tracker.trackEvent( new MobileMiniBannerExpandedEvent( 'preselected' ) );
showFullPageBanner( 'preselected' );
}
function onShowFullPageBannerFromMinimised(): void {
amountOptionsForForm.value = amountOptionsFive;
showFullPageBanner( 'minimised' );
}
const onHideFundsModal = ( payload: { source: UseOfFundsCloseSources } ): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div class="wmde-banner-minimised">
<ButtonClose @close="$emit( 'close' )">
<span class="wmde-banner-close-icon">
<CloseIconMobile/>
</span>
</ButtonClose>

<MinimisedText @show-full-page-banner="$emit( 'showFullPageBanner' )"/>
</div>
</template>

<script setup lang="ts">
import ButtonClose from '@src/components/ButtonClose/ButtonClose.vue';
import CloseIconMobile from '@src/components/Icons/CloseIconMobile.vue';
import MinimisedText from '@banners/mobile/C24_WMDE_Mobile_DE_13/content/MinimisedText.vue';
defineEmits( [ 'close', 'showFullPageBanner' ] );
</script>
10 changes: 10 additions & 0 deletions banners/mobile/C24_WMDE_Mobile_DE_13/content/MinimisedText.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<InfoIconStraight/> Hat Wikipedia Ihnen in diesem Jahr Wissen im Wert einer Tasse Kaffee geschenkt?
<a class="wmde-banner-minimised-expand" href="#" @click.prevent="$emit( 'showFullPageBanner' )">Dann geben Sie jetzt etwas zurück!&nbsp;<HeartIcon/></a>
</template>

<script setup lang="ts">
import InfoIconStraight from '@src/components/Icons/InfoIconStraight.vue';
import HeartIcon from '@src/components/Icons/HeartIcon.vue';
defineEmits( [ 'showFullPageBanner' ] );
</script>
36 changes: 36 additions & 0 deletions banners/mobile/C24_WMDE_Mobile_DE_13/event_map_var.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { TrackingEventConverterFactory } from '@src/tracking/LegacyTrackerWPORG';
import { WMDELegacyBannerEvent } from '@src/tracking/WPORG/WMDELegacyBannerEvent';
import { MobileMiniBannerExpandedEvent } from '@src/tracking/events/MobileMiniBannerExpandedEvent';
import { FormStepShownEvent } from '@src/tracking/events/FormStepShownEvent';
import { mapFormStepShownEvent } from '@src/tracking/LegacyEventTracking/mapFormStepShownEvent';
import { CloseEvent } from '@src/tracking/events/CloseEvent';
import { mapCloseEvent } from '@src/tracking/LegacyEventTracking/mapCloseEvent';
import { NotShownEvent } from '@src/tracking/events/NotShownEvent';
import { mapNotShownEvent } from '@src/tracking/LegacyEventTracking/mapNotShownEvent';
import { BannerSubmitEvent } from '@src/tracking/events/BannerSubmitEvent';
import { WMDESizeIssueEvent } from '@src/tracking/WPORG/WMDEBannerSizeIssue';
import { createViewportInfo } from '@src/tracking/LegacyEventTracking/createViewportInfo';
import { BannerSubmitOnReturnEvent } from '@src/tracking/events/BannerSubmitOnReturnEvent';
import { MinimisedEvent } from '@src/tracking/events/MinimisedEvent';

export default new Map<string, TrackingEventConverterFactory>( [
[ CloseEvent.EVENT_NAME, mapCloseEvent ],
[ MobileMiniBannerExpandedEvent.EVENT_NAME,
( e: MobileMiniBannerExpandedEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + ( e.userChoice !== '' ? `-${e.userChoice}` : '' ), 1 ) ],
[ FormStepShownEvent.EVENT_NAME, mapFormStepShownEvent ],
[ NotShownEvent.EVENT_NAME, mapNotShownEvent ],

[ BannerSubmitEvent.EVENT_NAME, ( e: BannerSubmitEvent ): WMDESizeIssueEvent => {
switch ( e.feature ) {
case 'MiniBanner':
case 'UpgradeToYearlyForm':
return new WMDESizeIssueEvent( `submit-${e.userChoice}`, createViewportInfo(), 1 );
default:
return new WMDESizeIssueEvent( `submit`, createViewportInfo(), 1 );
}
} ],
[ BannerSubmitOnReturnEvent.EVENT_NAME,
( e: BannerSubmitOnReturnEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + ( e.userChoice !== '' ? `-${e.userChoice}` : '' ), 1 ) ],
[ MinimisedEvent.EVENT_NAME,
( e: MinimisedEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + `-${ e.feature }-${ e.userChoice }`, 1 ) ]
] );
59 changes: 59 additions & 0 deletions banners/mobile/C24_WMDE_Mobile_DE_13/styles/BannerVar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@use 'src/themes/Modo/variables/globals';
@use 'src/themes/Modo/variables/fonts';

@keyframes hide-mini {
0% {
opacity: 1;
}
99% {
opacity: 0;
}
100% {
display: none;
}
}

.wmde-banner {

&-full {
visibility: hidden;
opacity: 0;
transform: scale( 1.1 );
transition: opacity 500ms globals.$banner-easing, transform 500ms globals.$banner-easing;
}

&-wrapper {
font-size: 16px;
font-family: fonts.$ui;
box-shadow: var( --mini-box-shadow );
background-color: var( --main-background );
color: var( --main-color );

&--full-page {
.wmde-banner-mini {
animation: hide-mini 500ms;
}
.wmde-banner-full {
visibility: visible;
opacity: 1;
transform: scale( 1 );
}
}

&--soft-closing {
.wmde-banner-minimised {
display: none;
}
.wmde-banner-mini {
display: none;
}
}
}

&--closed,
&--not-shown {
.wmde-banner-wrapper {
display: none;
}
}
}
58 changes: 58 additions & 0 deletions banners/mobile/C24_WMDE_Mobile_DE_13/styles/MinimisedBanner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.wmde-banner {
&-minimised {
--info-icon-background: var( --minimised-info-background );
--info-icon-color: var( --minimised-info-color );

background: var( --minimised-background );
color: var( --minimised-color );
position: relative;
padding: 5px 36px 5px 10px;
font-size: 16px;
line-height: 1.8;

.wmde-banner-close {
all: unset;
border: 0;
position: absolute;
top: 0;
right: 0;
height: 36px;
width: 36px;
cursor: pointer;
text-align: center;

&-icon {
background: var( --minimised-close-background );
display: inline-block;
height: 20px;
width: 20px;
border-radius: 50%;
}

svg {
position: relative;
display: inline-block;
width: 10px;
height: 10px;
top: -5px;
}
}

a {
color: var( --minimised-link-color );
font-weight: bold;
svg {
position: relative;
top: 2px;
path {
fill: var( --minimised-link-color );
}
}
}
}

&-info-icon {
position: relative;
top: 2px;
}
}
30 changes: 30 additions & 0 deletions banners/mobile/C24_WMDE_Mobile_DE_13/styles/styles_var.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@use 'src/themes/Modo/swatches/skin_default' with (
$minimised-banner: true,
$upgrade-to-yearly-button-form: true,
$double-progress-bar: true,
$soft-close: true,
$thank-you-box: true
);
@use 'src/components/BannerConductor/banner-transition';
@use 'src/themes/UseOfFunds/swatches/skin_default' as uof-default;
@use 'src/themes/UseOfFunds/UseOfFunds';
@use 'src/themes/Modo/defaults';
@use 'BannerVar';
@use 'MiniBanner' with (
$height: 336px,
$height-l-up: 306px
);
@use 'MinimisedBanner';
@use 'FullPageBanner';
@use 'src/themes/Modo/Footer/Footer';
@use 'src/themes/Modo/ThankYouBox/ThankYouBox';
@use 'src/themes/Modo/Footer/SelectionInput';
@use 'src/themes/Modo/DonationForm/MultiStepDonation';
@use 'src/themes/Modo/DonationForm/Forms/UpgradeToYearlyButtonForm';
@use 'src/themes/Modo/DonationForm/SubComponents/SelectGroup';
@use 'src/themes/Modo/DonationForm/SubComponents/SelectCustomAmount';
@use 'src/themes/Modo/DonationForm/SubComponents/SmsBox';
@use 'src/themes/Modo/Slider/Slider';
@use 'src/themes/Modo/SoftClose/SoftClose';
@use 'src/themes/Modo/ProgressBar/DoubleProgressBar';
@use 'src/themes/Modo/Message/Message';
21 changes: 21 additions & 0 deletions banners/mobile/C24_WMDE_Mobile_DE_13/useScrollMinimiser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { onMounted, onUnmounted, Ref, watch } from 'vue';

export function useScrollMinimiser( switchThreshold: number, hasMinimised: Ref<boolean>, onScrollBelowThreshold: () => void ): void {
const scrollHandler = (): void => {
if ( window.scrollY > switchThreshold ) {
onScrollBelowThreshold();
}
};

onMounted( () => {
window.addEventListener( 'scroll', scrollHandler );
} );

onUnmounted( () => {
window.removeEventListener( 'scroll', scrollHandler );
} );

watch( hasMinimised, () => {
window.removeEventListener( 'scroll', scrollHandler );
} );
}
17 changes: 17 additions & 0 deletions docs/2025PostCampaignCleanUp.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,20 @@ Ex. If main banner uses double progress bar and FB banner uses progress bar alte
So, somehow the progress bar on FB banner is dependant on progress bar on main banner.

Could we make them fully independent of each other?

## Fix Heart Icon & Thank You Box

This has a CSS variable setting it's fill, which doesn't work. The fill attribute should be removed from the svg element, and the path changed to `style="fill: var( --heart-icon-fill )"`. Then in the mobile banner themes it should be set up in the thank you box CSS, something like:

```css
.thank-you-container {
--heart-icon-fill: var( --thank-you-box-color );
}
```
Also the CSS that's currently in the Vue component should be moved or removed.

### Files to look at
- `src/components/Icons/HeartIcon.vue`
- `src/themes/Modo/ThankYouBox/ThankYouBox.scss`
- `src/themes/Mikings/ThankYouBox/ThankYouBox.scss`
- `src/components/ThankYouBox/ThankYouBox.vue`
2 changes: 1 addition & 1 deletion src/components/Icons/InfoIconStraight.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg class="wmde-banner-info-icon" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_2840_305)">
<circle cx="8" cy="8" r="8" style="fill: var( --info-icon-background );"/>
<path d="M8.8 5.73334V11.7173H10.2667V13.0667H5.96933V11.7173H7.33334V7.2H5.86667V5.73334H8.8ZM7.33334
Expand Down
Loading

0 comments on commit b578e82

Please sign in to comment.