-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from wmde/C23_WPDE_Desktop_02
C23_WPDE_Desktop_02
- Loading branch information
Showing
40 changed files
with
1,105 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { createVueApp } from '@src/createVueApp'; | ||
|
||
import './styles/styles.scss'; | ||
|
||
import BannerConductor from '@src/components/BannerConductor/BannerConductor.vue'; | ||
import Banner from './components/BannerCtrl.vue'; | ||
import { UrlRuntimeEnvironment } from '@src/utils/RuntimeEnvironment'; | ||
import { WindowResizeHandler } from '@src/utils/ResizeHandler'; | ||
import PageWPDE from '@src/page/PageWPDE'; | ||
import TranslationPlugin from '@src/TranslationPlugin'; | ||
import { TrackerWPDE } from '@src/tracking/TrackerWPDE'; | ||
import eventMap from './event_map'; | ||
import { Translator } from '@src/Translator'; | ||
import DynamicTextPlugin from '@src/DynamicTextPlugin'; | ||
import { LocalImpressionCount } from '@src/utils/LocalImpressionCount'; | ||
|
||
// Channel specific form setup | ||
import { createFormItems } from './form_items'; | ||
import { createFormActions } from '@src/createFormActions'; | ||
|
||
// Content | ||
import messages from './messages'; | ||
import { LocaleFactoryWpDe } from '@src/utils/LocaleFactory/LocaleFactoryWpDe'; | ||
|
||
const localeFactory = new LocaleFactoryWpDe(); | ||
const translator = new Translator( messages ); | ||
|
||
// Tracking placeholders will be replaced by webpack string-replace-loader | ||
// using the campaign configuration ( campaign_info.toml ) for the correct values | ||
const tracking = { | ||
campaign: '!insert-campaign-here!', | ||
keyword: '!insert-keyword-here!' | ||
}; | ||
|
||
// This is channel specific and must be changed for wp.org banners | ||
const page = new PageWPDE( tracking ); | ||
const runtimeEnvironment = new UrlRuntimeEnvironment( window.location ); | ||
const impressionCount = new LocalImpressionCount( page.getTracking().keyword, runtimeEnvironment ); | ||
const tracker = new TrackerWPDE( 'FundraisingTracker', page.getTracking().keyword, eventMap, runtimeEnvironment ); | ||
|
||
const app = createVueApp( BannerConductor, { | ||
page, | ||
bannerConfig: { | ||
delay: runtimeEnvironment.getBannerDelay( 0 ), | ||
transitionDuration: 1000 | ||
}, | ||
bannerProps: { | ||
useOfFundsContent: localeFactory.getUseOfFundsLoader().getContent(), | ||
remainingImpressions: impressionCount.getRemainingImpressions( page.getMaxBannerImpressions() ) | ||
}, | ||
resizeHandler: new WindowResizeHandler(), | ||
banner: Banner, | ||
impressionCount | ||
} ); | ||
|
||
app.use( TranslationPlugin, translator ); | ||
app.use( DynamicTextPlugin, { | ||
campaignParameters: page.getCampaignParameters(), | ||
date: new Date(), | ||
formatters: localeFactory.getFormatters(), | ||
impressionCount, | ||
translator | ||
} ); | ||
|
||
const currencyFormatter = localeFactory.getCurrencyFormatter(); | ||
app.provide( 'currencyFormatter', currencyFormatter ); | ||
app.provide( 'formItems', createFormItems( translator, currencyFormatter.euroAmount.bind( currencyFormatter ) ) ); | ||
app.provide( 'formActions', createFormActions( page.getTracking(), impressionCount ) ); | ||
app.provide( 'tracker', tracker ); | ||
|
||
app.mount( page.getBannerContainer() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { createVueApp } from '@src/createVueApp'; | ||
|
||
import './styles/styles.scss'; | ||
|
||
import BannerConductor from '@src/components/BannerConductor/BannerConductor.vue'; | ||
import Banner from './components/BannerVar.vue'; | ||
import { UrlRuntimeEnvironment } from '@src/utils/RuntimeEnvironment'; | ||
import { WindowResizeHandler } from '@src/utils/ResizeHandler'; | ||
import PageWPDE from '@src/page/PageWPDE'; | ||
import TranslationPlugin from '@src/TranslationPlugin'; | ||
import { TrackerWPDE } from '@src/tracking/TrackerWPDE'; | ||
import eventMap from './event_map'; | ||
import { Translator } from '@src/Translator'; | ||
import DynamicTextPlugin from '@src/DynamicTextPlugin'; | ||
import { LocalImpressionCount } from '@src/utils/LocalImpressionCount'; | ||
|
||
// Channel specific form setup | ||
import { createFormItems } from './form_items'; | ||
import { createFormActions } from '@src/createFormActions'; | ||
|
||
// Content | ||
import messages from './messages'; | ||
import { LocaleFactoryWpDe } from '@src/utils/LocaleFactory/LocaleFactoryWpDe'; | ||
|
||
const localeFactory = new LocaleFactoryWpDe(); | ||
const translator = new Translator( messages ); | ||
|
||
// Tracking placeholders will be replaced by webpack string-replace-loader | ||
// using the campaign configuration ( campaign_info.toml ) for the correct values | ||
const tracking = { | ||
campaign: '!insert-campaign-here!', | ||
keyword: '!insert-keyword-here!' | ||
}; | ||
|
||
// This is channel specific and must be changed for wp.org banners | ||
const page = new PageWPDE( tracking ); | ||
const runtimeEnvironment = new UrlRuntimeEnvironment( window.location ); | ||
const impressionCount = new LocalImpressionCount( page.getTracking().keyword, runtimeEnvironment ); | ||
const tracker = new TrackerWPDE( 'FundraisingTracker', page.getTracking().keyword, eventMap, runtimeEnvironment ); | ||
|
||
const app = createVueApp( BannerConductor, { | ||
page, | ||
bannerConfig: { | ||
delay: runtimeEnvironment.getBannerDelay( 0 ), | ||
transitionDuration: 1000 | ||
}, | ||
bannerProps: { | ||
useOfFundsContent: localeFactory.getUseOfFundsLoader().getContent(), | ||
remainingImpressions: impressionCount.getRemainingImpressions( page.getMaxBannerImpressions() ) | ||
}, | ||
resizeHandler: new WindowResizeHandler(), | ||
banner: Banner, | ||
impressionCount | ||
} ); | ||
|
||
app.use( TranslationPlugin, translator ); | ||
app.use( DynamicTextPlugin, { | ||
campaignParameters: page.getCampaignParameters(), | ||
date: new Date(), | ||
formatters: localeFactory.getFormatters(), | ||
impressionCount, | ||
translator | ||
} ); | ||
|
||
const currencyFormatter = localeFactory.getCurrencyFormatter(); | ||
app.provide( 'currencyFormatter', currencyFormatter ); | ||
app.provide( 'formItems', createFormItems( translator, currencyFormatter.euroAmount.bind( currencyFormatter ) ) ); | ||
app.provide( 'formActions', createFormActions( page.getTracking(), impressionCount ) ); | ||
app.provide( 'tracker', tracker ); | ||
|
||
app.mount( page.getBannerContainer() ); |
154 changes: 154 additions & 0 deletions
154
archive/wpde_desktop/C23_WPDE_Desktop_01/components/BannerCtrl.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<template> | ||
<div class="wmde-banner-wrapper" :class="contentState"> | ||
<SetCookieImage v-if="showSetCookieImage"/> | ||
<MainBanner | ||
@close="onCloseMain" | ||
@form-interaction="$emit( 'bannerContentChanged' )" | ||
:bannerState="bannerState" | ||
v-if="contentState === ContentStates.Main" | ||
> | ||
<template #banner-text> | ||
<BannerText/> | ||
</template> | ||
|
||
<template #banner-slides="{ play }: any"> | ||
<KeenSlider :with-navigation="true" :play="play" :interval="5000"> | ||
|
||
<template #slides="{ currentSlide }: any"> | ||
<BannerSlides :currentSlide="currentSlide"/> | ||
</template> | ||
|
||
<template #left-icon> | ||
<ChevronLeftIcon :fill="'#990a00'"/> | ||
</template> | ||
|
||
<template #right-icon> | ||
<ChevronRightIcon :fill="'#990a00'"/> | ||
</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"> | ||
|
||
<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"> | ||
<UpgradeToYearlyForm :page-index="pageIndex" @submit="submit" :is-current="isCurrent" @previous="previous"/> | ||
</template> | ||
|
||
<template #[FormStepNames.CustomAmountFormStep]="{ pageIndex, submit, isCurrent, previous }: any"> | ||
<CustomAmountForm :page-index="pageIndex" @submit="submit" :is-current="isCurrent" @previous="previous"/> | ||
</template> | ||
|
||
</MultiStepDonation> | ||
</template> | ||
|
||
<template #footer> | ||
<BannerFooter @showFundsModal="isFundsModalVisible = true" /> | ||
</template> | ||
</MainBanner> | ||
|
||
<FundsModal | ||
:content="useOfFundsContent" | ||
:is-funds-modal-visible="isFundsModalVisible" | ||
@hideFundsModal="isFundsModalVisible = false" | ||
/> | ||
|
||
<SoftClose | ||
v-if="contentState === ContentStates.SoftClosing" | ||
@close="() => onClose( 'SoftClose', CloseChoices.Close )" | ||
@maybe-later="() => onClose( 'SoftClose', CloseChoices.MaybeLater )" | ||
@time-out-close="() => onClose( 'SoftClose', CloseChoices.TimeOut )" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates'; | ||
import { 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 ProgressBar from '@src/components/ProgressBar/ProgressBar.vue'; | ||
import MultiStepDonation from '@src/components/DonationForm/MultiStepDonation.vue'; | ||
import BannerFooter from '@src/components/Footer/BannerFooter.vue'; | ||
import MainDonationForm from '@src/components/DonationForm/Forms/MainDonationForm.vue'; | ||
import UpgradeToYearlyForm from '@src/components/DonationForm/Forms/UpgradeToYearlyForm.vue'; | ||
import CustomAmountForm from '@src/components/DonationForm/Forms/CustomAmountForm.vue'; | ||
import KeenSlider from '@src/components/Slider/KeenSlider.vue'; | ||
import ChevronLeftIcon from '@src/components/Icons/ChevronLeftIcon.vue'; | ||
import ChevronRightIcon from '@src/components/Icons/ChevronRightIcon.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 { createSubmittableCustomAmount } from '@src/components/DonationForm/StepControllers/SubmittableCustomAmount'; | ||
import { CloseChoices } from '@src/domain/CloseChoices'; | ||
import { CloseEvent } from '@src/tracking/events/CloseEvent'; | ||
import { TrackingFeatureName } from '@src/tracking/TrackingEvent'; | ||
import SoftClose from '@src/components/SoftClose/SoftClose.vue'; | ||
import SetCookieImage from '@src/components/SetWPDECookieImage/SetCookieImage.vue'; | ||
enum ContentStates { | ||
Main = 'wmde-banner-wrapper--main', | ||
SoftClosing = 'wmde-banner-wrapper--soft-closing' | ||
} | ||
enum FormStepNames { | ||
CustomAmountFormStep = 'CustomAmountForm', | ||
MainDonationFormStep = 'MainDonationForm', | ||
UpgradeToYearlyFormStep = 'UpgradeToYearlyForm' | ||
} | ||
interface Props { | ||
bannerState: BannerStates; | ||
useOfFundsContent: useOfFundsContentInterface; | ||
remainingImpressions: number; | ||
} | ||
const props = defineProps<Props>(); | ||
const emit = defineEmits( [ 'bannerClosed', 'bannerContentChanged' ] ); | ||
const isFundsModalVisible = ref<boolean>( false ); | ||
const showSetCookieImage = ref<boolean>( false ); | ||
const contentState = ref<ContentStates>( ContentStates.Main ); | ||
const formModel = useFormModel(); | ||
const stepControllers = [ | ||
createSubmittableMainDonationForm( formModel, FormStepNames.UpgradeToYearlyFormStep ), | ||
createSubmittableUpgradeToYearly( formModel, FormStepNames.CustomAmountFormStep, FormStepNames.MainDonationFormStep ), | ||
createSubmittableCustomAmount( formModel, FormStepNames.UpgradeToYearlyFormStep ) | ||
]; | ||
watch( contentState, async () => { | ||
emit( 'bannerContentChanged' ); | ||
} ); | ||
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 ) ); | ||
if ( userChoice !== CloseChoices.MaybeLater ) { | ||
showSetCookieImage.value = true; | ||
} | ||
} | ||
</script> |
Oops, something went wrong.