Skip to content

Commit

Permalink
Implement VAR for C24_WMDE_Mobile_DE_14
Browse files Browse the repository at this point in the history
- add button for UOF to minibanner

- use new 2024 UOF component

- add tests

https://phabricator.wikimedia.org/T382481
  • Loading branch information
moiikana committed Dec 20, 2024
1 parent c7f117b commit 20bda4c
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 61 deletions.
2 changes: 1 addition & 1 deletion banners/mobile/C24_WMDE_Mobile_DE_14/banner_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { WindowPageScroller } from '@src/utils/PageScroller/WindowPageScroller';
import { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG';
import eventMappings from './event_map';
import messages from './messages';
import { LocaleFactoryDe } from '@src/utils/LocaleFactory/LocaleFactoryDe';
import { LocaleFactoryDe } from '@src/utils/LocaleFactory2024/LocaleFactoryDe';
import { createFormItems } from './form_items';
import { createFormActions } from '@src/createFormActions';
import { LocalStorageCloseTracker } from '@src/utils/LocalCloseTracker';
Expand Down
4 changes: 2 additions & 2 deletions banners/mobile/C24_WMDE_Mobile_DE_14/banner_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ 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 { LocaleFactoryDe } from '@src/utils/LocaleFactory2024/LocaleFactoryDe';
import { createFormItems } from './form_items';
import { createFormActions } from '@src/createFormActions';
import { LocalStorageCloseTracker } from '@src/utils/LocalCloseTracker';
Expand Down
23 changes: 13 additions & 10 deletions banners/mobile/C24_WMDE_Mobile_DE_14/components/BannerCtrl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@

<FundsModal
:content="useOfFundsContent"
:is-funds-modal-visible="isFundsModalVisible"
@hideFundsModal="onHideFundsModal"
:visible="isFundsModalVisible"
@hide="onHideFundsModal"
@callToAction="onFundsModalCallToAction"
>
<template #infographic>
<WMDEFundsForwardingDE/>
Expand All @@ -117,9 +118,8 @@ import { BannerStates } from '@src/components/BannerConductor/StateMachine/Banne
import { computed, inject, ref, watch } from 'vue';
import FullPageBanner from './FullPageBanner.vue';
import MiniBanner from './MiniBanner.vue';
import FundsModal from '@src/components/UseOfFunds/FundsModal.vue';
import { UseOfFundsContent as useOfFundsContentInterface } from '@src/domain/UseOfFunds/UseOfFundsContent';
import { UseOfFundsCloseSources } from '@src/components/UseOfFunds/UseOfFundsCloseSources';
import FundsModal from '@src/components/UseOfFunds2024/UseOfFundsModal.vue';
import { UseOfFundsContent as useOfFundsContentInterface } from '@src/domain/UseOfFunds2024/UseOfFundsContent';
import { PageScroller } from '@src/utils/PageScroller/PageScroller';
import MainDonationFormAdaptiveAmounts from '@src/components/DonationForm/Forms/MainDonationFormAdaptiveAmounts.vue';
import MultiStepDonation from '@src/components/DonationForm/MultiStepDonation.vue';
Expand Down Expand Up @@ -244,12 +244,15 @@ function onshowFullPageBannerPreselected(): void {
tracker.trackEvent( new MobileMiniBannerExpandedEvent( 'preselected' ) );
}
const onHideFundsModal = ( payload: { source: UseOfFundsCloseSources } ): void => {
props.pageScroller.scrollIntoView( payload.source === UseOfFundsCloseSources.callToAction ?
'.wmde-banner-form' :
'.wmde-banner-full-small-print .wmde-banner-footer-usage-link'
);
const onHideFundsModal = (): void => {
props.pageScroller.scrollIntoView( '.wmde-banner-form' );
isFundsModalVisible.value = false;
};
const onFundsModalCallToAction = (): void => {
props.pageScroller.scrollIntoView( '.wmde-banner-form' );
isFundsModalVisible.value = false;
onshowFullPageBanner();
};
</script>
32 changes: 21 additions & 11 deletions banners/mobile/C24_WMDE_Mobile_DE_14/components/BannerVar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@close="onCloseMiniBanner"
@show-full-page-banner="onshowFullPageBanner"
@show-full-page-banner-preselected="onshowFullPageBannerPreselected"
@showFundsModal="onShowFundsModal( 'MiniBanner' )"
>
<template #banner-slides>
<KeenSlider :with-navigation="false" :play="slideshowShouldPlay" :interval="5000">
Expand All @@ -19,7 +20,7 @@
</MiniBanner>

<FullPageBanner
@showFundsModal="isFundsModalVisible = true"
@showFundsModal="onShowFundsModal( 'FullPageBanner' )"
@close="() => onClose( 'FullPageBanner', CloseChoices.Hide )"
>
<template #banner-text>
Expand Down Expand Up @@ -102,8 +103,9 @@

<FundsModal
:content="useOfFundsContent"
:is-funds-modal-visible="isFundsModalVisible"
@hideFundsModal="onHideFundsModal"
:visible="isFundsModalVisible"
@hide="onHideFundsModal"
@callToAction="onFundsModalCallToAction"
>
<template #infographic>
<WMDEFundsForwardingDE/>
Expand All @@ -117,9 +119,8 @@ import { BannerStates } from '@src/components/BannerConductor/StateMachine/Banne
import { computed, inject, ref, watch } from 'vue';
import FullPageBanner from './FullPageBanner.vue';
import MiniBanner from './MiniBanner_var.vue';
import FundsModal from '@src/components/UseOfFunds/FundsModal.vue';
import { UseOfFundsContent as useOfFundsContentInterface } from '@src/domain/UseOfFunds/UseOfFundsContent';
import { UseOfFundsCloseSources } from '@src/components/UseOfFunds/UseOfFundsCloseSources';
import FundsModal from '@src/components/UseOfFunds2024/UseOfFundsModal.vue';
import { UseOfFundsContent as useOfFundsContentInterface } from '@src/domain/UseOfFunds2024/UseOfFundsContent';
import { PageScroller } from '@src/utils/PageScroller/PageScroller';
import MainDonationFormAdaptiveAmounts from '@src/components/DonationForm/Forms/MainDonationFormAdaptiveAmounts.vue';
import MultiStepDonation from '@src/components/DonationForm/MultiStepDonation.vue';
Expand Down Expand Up @@ -151,6 +152,7 @@ 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 { UseOfFundsShownEvent } from '@src/tracking/events/UseOfFundsShownEvent';
enum ContentStates {
Mini = 'wmde-banner-wrapper--mini',
Expand Down Expand Up @@ -244,12 +246,20 @@ function onshowFullPageBannerPreselected(): void {
tracker.trackEvent( new MobileMiniBannerExpandedEvent( 'preselected' ) );
}
const onHideFundsModal = ( payload: { source: UseOfFundsCloseSources } ): void => {
props.pageScroller.scrollIntoView( payload.source === UseOfFundsCloseSources.callToAction ?
'.wmde-banner-form' :
'.wmde-banner-full-small-print .wmde-banner-footer-usage-link'
);
const onHideFundsModal = (): void => {
props.pageScroller.scrollIntoView( '.wmde-banner-form' );
isFundsModalVisible.value = false;
};
const onShowFundsModal = ( feature: TrackingFeatureName ): void => {
tracker.trackEvent( new UseOfFundsShownEvent( feature ) );
isFundsModalVisible.value = true;
};
const onFundsModalCallToAction = (): void => {
props.pageScroller.scrollIntoView( '.wmde-banner-form' );
isFundsModalVisible.value = false;
onshowFullPageBanner();
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<div class="wmde-banner-mini-slideshow">
<slot name="banner-slides"/>
</div>

<button
class="wmde-banner-mini-uof-link"
@click.prevent="$emit( 'showFundsModal' )"
:title="$translate( 'use-of-funds-link-description' )"
>
<InfoIconStraight/> Warum Spenden?
</button>
</div>
<div class="wmde-banner-mini-button-group">
<button class="wmde-banner-mini-button-preselect" @click="$emit( 'showFullPageBannerPreselected' )">
Expand All @@ -30,7 +38,8 @@
<script setup lang="ts">
import CloseIconMobile from '@src/components/Icons/CloseIconMobile.vue';
import InfoIconStraight from '@src/components/Icons/InfoIconStraight.vue';
defineEmits( [ 'showFullPageBanner', 'showFullPageBannerPreselected', 'close' ] );
defineEmits( [ 'showFullPageBanner', 'showFullPageBannerPreselected', 'close', 'showFundsModal' ] );
</script>
46 changes: 46 additions & 0 deletions banners/mobile/C24_WMDE_Mobile_DE_14/event_map_var.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 { UseOfFundsShownEvent } from '@src/tracking/events/UseOfFundsShownEvent';

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
)
],
[ UseOfFundsShownEvent.EVENT_NAME,
( e: UseOfFundsShownEvent ): WMDELegacyBannerEvent =>
new WMDELegacyBannerEvent(
e.eventName + ( e.userChoice !== '' ? `-${e.userChoice}` : '' ),
1
)
]
] );
25 changes: 23 additions & 2 deletions banners/mobile/C24_WMDE_Mobile_DE_14/styles/MiniBanner_var.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,43 @@ $height-l-up: 288px !default;
padding: 12px;
}

&-uof-link {
background: none;
border: none;
color: var( --info-color );
font-size: 11px;
cursor: pointer;

position: absolute;
bottom: 8px;
left: 8px;

--info-icon-background: var( --info-color );
--info-icon-color: var( --mini-info-background );
svg {
width: 10px;
height: 10px;
top: -5px;
}
}

&-info {
background: var( --mini-info-background );
border-radius: 16px;
margin-bottom: 6px;
display: flex;
flex-direction: column;
flex: 1 1 auto;
position: relative;

@include breakpoints.phone-l-up {
margin-bottom: 12px;
}
}

&-close {
top: -3px;
right: -3px;
top: -9px;
right: -9px;
position: absolute;
height: 36px;
width: 36px;
Expand Down
4 changes: 2 additions & 2 deletions banners/mobile/C24_WMDE_Mobile_DE_14/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
$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/components/UseOfFunds2024/styles/swatches/skin_default' as uof-default;
@use 'src/components/UseOfFunds2024/styles/styles';
@use 'src/themes/Modo/defaults';
@use 'Banner';
@use 'MiniBanner' with (
Expand Down
4 changes: 2 additions & 2 deletions banners/mobile/C24_WMDE_Mobile_DE_14/styles/styles_var.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
$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/components/UseOfFunds2024/styles/swatches/skin_default' as uof-default;
@use 'src/components/UseOfFunds2024/styles/styles';
@use 'src/themes/Modo/defaults';
@use 'Banner';
@use 'MiniBanner_var' with (
Expand Down
21 changes: 0 additions & 21 deletions banners/mobile/C24_WMDE_Mobile_DE_14/useScrollMinimiser.ts

This file was deleted.

2 changes: 1 addition & 1 deletion campaign_info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ preview_link_darkmode = "/mobile/wiki/Wikipedia:Hauptseite?devbanner={{banner}}&
preview_link_offline = ""
preview_url = 'https://de.m.wikipedia.org/wiki/Wikipedia:Hauptseite?banner={{banner}}&useskin=minerva&devMode'
wrapper_template = "wikipedia_org"
use_of_funds_source = "MediaWiki:WMDE_Fundraising/UseOfFunds_2024_DE"
use_of_funds_source = "MediaWiki:WMDE_Fundraising/UseOfFunds_2025_DE"

# Banners of the campaign, key after "banners" can be anything
[mobile.banners.ctrl]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { afterEach, beforeEach, describe, test, vi } from 'vitest';
import { afterEach, beforeEach, describe, Mock, test, vi } from 'vitest';
import { mount, VueWrapper } from '@vue/test-utils';
import Banner from '@banners/mobile/C24_WMDE_Mobile_DE_14/components/BannerCtrl.vue';
import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates';
import { PageScroller } from '@src/utils/PageScroller/PageScroller';
import { useOfFundsContent } from '@test/banners/useOfFundsContent';
import { useOfFundsContent } from '@test/banners/useOfFundsContent2024';
import { newDynamicContent } from '@test/banners/dynamicCampaignContent';
import { CurrencyDe } from '@src/utils/DynamicContent/formatters/CurrencyDe';
import { formItems } from '@test/banners/formItems';
import { softCloseFeatures } from '@test/features/SoftCloseMobile';
import { useOfFundsFeatures, useOfFundsScrollFeatures } from '@test/features/UseOfFunds';
import { useOfFundsFeatures, useOfFundsScrollFeatures } from '@test/features/UseOfFunds2024';
import { miniBannerFeatures } from '@test/features/MiniBanner';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton_changesAmountOptions';
import { useFormModel } from '@src/components/composables/useFormModel';
Expand All @@ -27,6 +27,8 @@ let tracker: Tracker;
const formModel = useFormModel();
const translator = ( key: string ): string => key;
describe( 'BannerCtrl.vue', () => {
let showCallback: Mock;
let closeCallback: Mock;

let wrapper: VueWrapper<any>;
beforeEach( () => {
Expand All @@ -40,6 +42,12 @@ describe( 'BannerCtrl.vue', () => {
tracker = {
trackEvent: vi.fn()
};

// for use of funds dialogue
showCallback = vi.fn();
closeCallback = vi.fn();
HTMLDialogElement.prototype.showModal = showCallback;
HTMLDialogElement.prototype.close = closeCallback;
} );

afterEach( () => {
Expand Down Expand Up @@ -155,7 +163,7 @@ describe( 'BannerCtrl.vue', () => {

test.each( [
[ 'expectScrollsToFormWhenCallToActionIsClicked' ],
[ 'expectScrollsToLinkWhenCloseIsClicked' ]
[ 'expectScrollsToFormWhenCloseIsClicked' ]
] )( '%s', async ( testName: string ) => {
await useOfFundsScrollFeatures[ testName ]( getWrapper(), pageScroller );
} );
Expand Down
Loading

0 comments on commit 20bda4c

Please sign in to comment.