Skip to content

Commit

Permalink
Implement VAR for C24_WMDE_Desktop_DE_11
Browse files Browse the repository at this point in the history
  • Loading branch information
Abban committed Nov 7, 2024
1 parent c5c3837 commit 2c7ae57
Show file tree
Hide file tree
Showing 23 changed files with 671 additions and 31 deletions.
8 changes: 5 additions & 3 deletions banners/desktop/C24_WMDE_Desktop_DE_11/banner_var.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createVueApp } from '@src/createVueApp';

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

import BannerConductor from '@src/components/BannerConductor/FallbackBannerConductor.vue';
import Banner from './components/BannerCtrl.vue';
import Banner from './components/BannerVar.vue';
import FallbackBanner from './components/FallbackBanner.vue';
import { UrlRuntimeEnvironment } from '@src/utils/RuntimeEnvironment';
import { WindowResizeHandler } from '@src/utils/ResizeHandler';
Expand All @@ -21,12 +21,13 @@ import { createFallbackDonationURL } from '@src/createFallbackDonationURL';
import { LocalStorageCloseTracker } from '@src/utils/LocalCloseTracker';

// Locale-specific imports
import messages from './messages';
import messages from './messages_var';
import { LocaleFactoryDe } from '@src/utils/LocaleFactory/LocaleFactoryDe';

// Channel specific form setup
import { createFormItems } from './form_items';
import { createFormActions } from '@src/createFormActions';
import { currentCampaignTimePercentage } from '@src/components/ProgressBar/currentCampaignTimePercentage';

const date = new Date();
const localeFactory = new LocaleFactoryDe();
Expand Down Expand Up @@ -72,5 +73,6 @@ app.provide( 'currencyFormatter', currencyFormatter );
app.provide( 'formItems', createFormItems( translator, currencyFormatter.euroAmount.bind( currencyFormatter ) ) );
app.provide( 'formActions', createFormActions( page.getTracking(), impressionCount, { afo: '1', ap: '0' } ) );
app.provide( 'tracker', tracker );
app.provide( 'currentCampaignTimePercentage', currentCampaignTimePercentage( date, page.getCampaignParameters() ) );

app.mount( page.getBannerContainer() );
163 changes: 163 additions & 0 deletions banners/desktop/C24_WMDE_Desktop_DE_11/components/BannerVar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<template>
<div class="wmde-banner-wrapper" :class="contentState">
<MainBanner
@form-interaction="$emit( 'bannerContentChanged' )"
v-if="contentState === ContentStates.Main"
:bannerState="bannerState"
>
<template #close-button>
<ButtonClose @close="onCloseMain"/>
</template>

<template #banner-text>
<BannerText/>
</template>

<template #banner-slides="{ play }: any">
<KeenSlider :with-navigation="true" :play="play" :interval="10000" :delay="2000" :navigation-color="'#ffffff'">

<template #slides="{ currentSlide }: any">
<BannerSlides :currentSlide="currentSlide"/>
</template>

</KeenSlider>
</template>

<template #progress>
<ProgressBar amount-to-show-on-right="TARGET"/>
</template>

<template #donation-form="{ formInteraction }: any">
<MultiStepDonation
:step-controllers="stepControllers"
@form-interaction="formInteraction"
:submit-callback="onSubmit"
>

<template #[FormStepNames.MainDonationFormStep]="{ pageIndex, submit, isCurrent, previous }: any">
<MainDonationForm :page-index="pageIndex" @submit="submit" :is-current="isCurrent" @previous="previous"/>
</template>

<template #[FormStepNames.UpgradeToYearlyFormStep]="{ pageIndex, submit, isCurrent, previous }: any">
<UpgradeToYearlyButtonForm :page-index="pageIndex" :show-manual-upgrade-option="false" @submit="submit" :is-current="isCurrent" @previous="previous"/>
</template>

</MultiStepDonation>
</template>

<template #footer>
<FooterAlreadyDonated
@showFundsModal="isFundsModalVisible = true"
@clickedAlreadyDonatedLink="onClose( 'AlreadyDonated', CloseChoices.AlreadyDonated )"
/>
</template>

</MainBanner>

<SoftClose
v-if="contentState === ContentStates.SoftClosing"
:show-close-icon="true"
@close="() => onClose( 'SoftClose', CloseChoices.Close )"
@maybeLater="() => onClose( 'SoftClose', CloseChoices.MaybeLater )"
@timeOutClose="() => onClose( 'SoftClose', CloseChoices.TimeOut )"
@maybeLater7Days="() => onClose('SoftClose', CloseChoices.Close)"
/>

<FundsModal
:content="useOfFundsContent"
:is-funds-modal-visible="isFundsModalVisible"
@hideFundsModal="isFundsModalVisible = false"
>
<template #infographic>
<WMDEFundsForwardingDE/>
</template>
</FundsModal>
</div>
</template>

<script setup lang="ts">
import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates';
import { inject, ref, watch } from 'vue';
import { UseOfFundsContent as useOfFundsContentInterface } from '@src/domain/UseOfFunds/UseOfFundsContent';
import MainBanner from './MainBanner.vue';
import FundsModal from '@src/components/UseOfFunds/FundsModal.vue';
import BannerText from '../content/BannerText.vue';
import BannerSlides from '../content/BannerSlides.vue';
import MultiStepDonation from '@src/components/DonationForm/MultiStepDonation.vue';
import MainDonationForm from '@src/components/DonationForm/Forms/MainDonationForm.vue';
import UpgradeToYearlyButtonForm from '@src/components/DonationForm/Forms/UpgradeToYearlyButtonForm.vue';
import KeenSlider from '@src/components/Slider/KeenSlider.vue';
import { useFormModel } from '@src/components/composables/useFormModel';
import {
createSubmittableMainDonationForm
} from '@src/components/DonationForm/StepControllers/SubmittableMainDonationForm';
import {
createSubmittableUpgradeToYearly
} from '@src/components/DonationForm/StepControllers/SubmittableUpgradeToYearly';
import { CloseChoices } from '@src/domain/CloseChoices';
import { CloseEvent } from '@src/tracking/events/CloseEvent';
import { TrackingFeatureName } from '@src/tracking/TrackingEvent';
import ButtonClose from '@src/components/ButtonClose/ButtonClose.vue';
import FooterAlreadyDonated from '@src/components/Footer/FooterAlreadyDonated.vue';
import WMDEFundsForwardingDE from '@src/components/UseOfFunds/Infographics/WMDEFundsForwardingDE.vue';
import ProgressBar from '@src/components/ProgressBar/DoubleProgressBar.vue';
import SoftClose from '@src/components/SoftClose/SoftClose.vue';
import { LocalCloseTracker } from '@src/utils/LocalCloseTracker';
import { BannerSubmitOnReturnEvent } from '@src/tracking/events/BannerSubmitOnReturnEvent';
import { Tracker } from '@src/tracking/Tracker';
enum ContentStates {
Main = 'wmde-banner-wrapper--main',
SoftClosing = 'wmde-banner-wrapper--soft-closing',
}
enum FormStepNames {
MainDonationFormStep = 'MainDonationForm',
UpgradeToYearlyFormStep = 'UpgradeToYearlyForm'
}
interface Props {
bannerState: BannerStates;
useOfFundsContent: useOfFundsContentInterface;
remainingImpressions: number;
localCloseTracker: LocalCloseTracker;
}
const props = defineProps<Props>();
const emit = defineEmits( [ 'bannerClosed', 'bannerContentChanged' ] );
const tracker = inject<Tracker>( 'tracker' );
const isFundsModalVisible = ref<boolean>( false );
const contentState = ref<ContentStates>( ContentStates.Main );
const formModel = useFormModel();
const stepControllers = [
createSubmittableMainDonationForm( formModel, FormStepNames.UpgradeToYearlyFormStep ),
createSubmittableUpgradeToYearly( formModel, FormStepNames.MainDonationFormStep, FormStepNames.MainDonationFormStep )
];
watch( contentState, async () => {
emit( 'bannerContentChanged' );
} );
const onSubmit = (): void => {
// special callback function: asking for previous close choices
const closeChoice = props.localCloseTracker.getItem();
if ( closeChoice !== '' ) {
tracker.trackEvent( new BannerSubmitOnReturnEvent( closeChoice ) );
}
};
function onCloseMain(): void {
if ( props.remainingImpressions > 0 ) {
contentState.value = ContentStates.SoftClosing;
} else {
onClose( 'MainBanner', CloseChoices.Close );
}
}
function onClose( feature: TrackingFeatureName, userChoice: CloseChoices ): void {
emit( 'bannerClosed', new CloseEvent( feature, userChoice ) );
}
</script>
2 changes: 0 additions & 2 deletions banners/desktop/C24_WMDE_Desktop_DE_11/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const messages: TranslationMessages = {
'upgrade-to-yearly-no': 'Nein, ich spende einmalig {{amount}}',
'upgrade-to-yearly-yes': 'Ja, ich spende {{amount}} jährlich',
'campaign-day-only-n-days': 'Heute sind es nur noch {{days}} Tage bis zum Ende unserer Spendenkampagne.',
'double-progress-close': 'Das wird knapp.',
'missing-amount': 'Uns fehlen noch',
'custom-amount-placeholder': 'Wahlbetrag'
};

Expand Down
35 changes: 35 additions & 0 deletions banners/desktop/C24_WMDE_Desktop_DE_11/messages_var.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import CustomAmountFormDe from '@src/components/DonationForm/Forms/messages/CustomAmountForm.de';
import DynamicCampaignTextDe from '@src/utils/DynamicContent/messages/DynamicCampaignText.de';
import { TranslationMessages } from '@src/Translator';
import UpgradeToYearlyDe from '@src/components/DonationForm/Forms/messages/UpgradeToYearly.de';
import AddressFormDe from '@src/components/DonationForm/Forms/messages/AddressForm.de';
import FooterDe from '@src/components/Footer/messages/Footer.de';
import MainDonationFormDe from '@src/components/DonationForm/Forms/messages/MainDonationForm.de';
import FallbackBanner from '@src/components/FallbackBanner/messages/FallbackBanner.de';
import AlreadyDonatedModal from '@src/components/AlreadyDonatedModal/translations/AlreadyDonatedModal.de';
import SoftCloseDe from '@src/components/SoftClose/messages/SoftClose.de';
import DoubleProgressBar from '@src/components/ProgressBar/messages/DoubleProgressBar.de';

const messages: TranslationMessages = {
...CustomAmountFormDe,
...DynamicCampaignTextDe,
...UpgradeToYearlyDe,
...AddressFormDe,
...FooterDe,
...MainDonationFormDe,
...AlreadyDonatedModal,
...FallbackBanner,
...SoftCloseDe,
...DoubleProgressBar,
'already-donated-go-away-button': 'Im Moment nicht',
'soft-close-prompt': 'Dürfen wir später nochmal fragen?',
'upgrade-to-yearly-copy': `<p>Jedes Jahr sind wir auf Menschen wie Sie angewiesen. Jährliche Spenden helfen uns besonders und ermöglichen langfristige Weiterentwicklungen.</p>
<p>Sie gehen kein Risiko ein: Jederzeit formlos zu sofort kündbar.</p>`,
'upgrade-to-yearly-no': 'Nein, ich spende einmalig {{amount}}',
'upgrade-to-yearly-yes': 'Ja, ich spende {{amount}} jährlich',
'campaign-day-only-n-days': 'Heute sind es nur noch {{days}} Tage bis zum Ende unserer Spendenkampagne.',
'custom-amount-placeholder': 'Wahlbetrag',
'prefix-days-left': 'Noch'
};

export default messages;
53 changes: 53 additions & 0 deletions banners/desktop/C24_WMDE_Desktop_DE_11/styles/MainBannerVar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
$banner-height: 357px !default;
$form-width: 300px !default;

.wmde-banner {

.previous {
--slider-chevron: var( --previous-button-fill );
}

&-main {
min-height: $banner-height;
display: flex;
flex-direction: column;
padding: 12px 24px 0;
}

&-content {
display: flex;
flex-direction: row;
flex-grow: 1;
}

&-message {
padding: 3px 15px;
color: var( --message-color );
background-color: var( --message-background );
border: none;
border-radius: 9px;
margin-bottom: 5px;
}

&-column-left {
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
flex: 1 1 auto;
margin-bottom: 0;
overflow-y: hidden;
margin-right: 30px;
padding: 0;
border: none;
}

&-column-right {
order: 2;
flex: 0 0 $form-width;
display: flex;
flex-direction: column;
width: $form-width;
padding: 10px 0 0;
}
}
56 changes: 56 additions & 0 deletions banners/desktop/C24_WMDE_Desktop_DE_11/styles/styles_var.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// This is the file where we import the theme-specific component styles
@use '../../../../src/themes/Svingle/swatches/skin_default' with (
$slider: true,
$select-group: true,
$upgrade-to-yearly: true,
$fallback-banner: true,
$double-progress-bar: true,
$soft-close: true,
);
@use 'src/components/BannerConductor/banner-transition';
@use 'src/themes/UseOfFunds/swatches/skin_default' as uof-default;
@use 'Banner';
@use 'src/themes/UseOfFunds/UseOfFunds';
@use 'MainBannerVar' with (
$banner-height: 357px,
$form-width: 300px
);
@use 'src/themes/Svingle/defaults';
@use 'src/themes/Svingle/ButtonClose/ButtonClose';
@use 'src/themes/Svingle/ProgressBar/DoubleProgressBar';
@use 'src/themes/Svingle/DonationForm/DonationForm';
@use 'src/themes/Svingle/DonationForm/MultiStepDonation';
@use 'src/themes/Svingle/DonationForm/SubComponents/SelectGroup';
@use 'src/themes/Svingle/DonationForm/SubComponents/SelectGroupRadios' with (
$font-size: 14px
);
@use 'src/themes/Svingle/DonationForm/SubComponents/SelectCustomAmountRadio' with (
$font-size: 14px
);
@use 'src/themes/Svingle/DonationForm/SubComponents/SmsBox';
@use 'src/themes/Svingle/DonationForm/Forms/MainDonationForm';
@use 'src/themes/Svingle/DonationForm/Forms/UpgradeToYearlyButtonForm' with (
$font-size: 14px
);
@use 'src/themes/Svingle/DonationForm/Forms/CustomAmountForm';
@use 'src/themes/Svingle/Footer/FooterAlreadyDonated';
@use 'src/themes/Svingle/Footer/SelectionInput';
@use 'src/themes/Svingle/Message/Message';
@use 'src/themes/Svingle/SoftClose/SoftClose';
@use 'src/themes/Svingle/Slider/KeenSlider' with (
$margin-bottom: 5px
);

/**
* Fallback banner with "Fijitiv" theme
* All selectors in Fijitiv theme are prefixed with the ".wmde-banner-fallback" class selector,
so they override the "default" styles with the same selector
*/
@use 'FallbackBanner';
@use 'src/themes/Fijitiv/FallbackBanner/FallbackButton';
@use 'src/themes/Fijitiv/FallbackBanner/LargeFooter';
@use 'src/themes/Fijitiv/FallbackBanner/SmallFooter';
@use 'src/themes/Fijitiv/ProgressBar/ProgressBar' as FallbackProgressBar with (
$progress-bar-margin: 0 15px
);
@use 'src/themes/Fijitiv/Slider/KeenSlider' as FallbackSlider;
19 changes: 13 additions & 6 deletions src/components/ProgressBar/DoubleProgressBar.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
<template>
<div class="wmde-banner-double-progress" :style="{
<div class="wmde-banner-double-progress" :class="{ 'is-late-progress' : progressBarContent.isLateProgress }" :style="{
'--wmde-banner-progress-bar-width': progressBarContent.percentageTowardsTarget + '%',
'--wmde-banner-progress-bar-time-width': currentCampaignTimePercentage + '%'
}">
<div class="wmde-banner-double-progress-amount">
<div class="wmde-banner-double-progress-amount-fill">
<div>{{ progressBarContent.amountNeeded }}</div>
<div>{{ progressBarContent.amountDonated }}</div>
<div v-if="progressBarContent.isLateProgress" class="amount-needed text-fade">{{ progressBarContent.amountNeeded }}</div>
<div class="text-fade">{{ progressBarContent.amountDonated }}</div>
</div>
<div class="wmde-banner-double-progress-amount-difference">!</div>
<div class="wmde-banner-double-progress-right-text text-fade" v-if="!progressBarContent.isLateProgress">{{ progressBarContent.amountNeeded }}</div>
</div>
<div class="wmde-banner-double-progress-time">
<div class="wmde-banner-double-progress-time-fill">
<div>{{ $translate( 'double-progress-close' ) }}</div>
<div>{{ daysLeftSentence }}</div>
<template v-if="progressBarContent.isLateProgress">
<div class="close-text text-fade">{{ $translate( 'double-progress-close' ) }}</div>
<div class="days-left text-fade">{{ daysLeftSentence }}</div>
</template>
<template v-else>
<div class="text-fade">{{ daysPassedSentence }}</div>
</template>
</div>
<div class="wmde-banner-double-progress-right-text text-fade" v-if="!progressBarContent.isLateProgress">{{ daysLeftSentence }}</div>
</div>
</div>
</template>
Expand All @@ -24,7 +31,7 @@
import { inject } from 'vue';
import { DynamicContent } from '@src/utils/DynamicContent/DynamicContent';
const { progressBarContent, daysLeftSentence } = inject<DynamicContent>( 'dynamicCampaignText' );
const { progressBarContent, daysLeftSentence, daysPassedSentence } = inject<DynamicContent>( 'dynamicCampaignText' );
const currentCampaignTimePercentage = inject<number>( 'currentCampaignTimePercentage' );
</script>
Loading

0 comments on commit 2c7ae57

Please sign in to comment.