Skip to content

Commit

Permalink
Add Giving Tuesday fundraising banner (Fixes mozilla#15527) (mozilla#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson authored Nov 27, 2024
1 parent d80b758 commit d080de3
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 3 deletions.
86 changes: 86 additions & 0 deletions bedrock/base/templates/includes/banners/fundraiser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{#
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
#}

{% extends 'includes/banners/basic.html' %}

{% block banner_id %}fundraising-banner{% endblock %}

{% block banner_class %}c-banner-fundraising{% endblock %}

{% if LANG =="de" %}
{% set banner_title = 'Giving Tuesday: Spende jetzt an Mozilla' %}
{% set banner_tagline = 'Gemeinsam können wir das Internet von Tech-Riesen zurückerobern. Jetzt spenden.' %}
{% set banner_button_a = 'Spenden' %}
{% set banner_button_b = 'Jetzt spenden' %}
{% set banner_button_c = 'Beitragen' %}
{% elif LANG == "fr" %}
{% set banner_title = 'Soutenez Mozilla pour le Giving Tuesday' %}
{% set banner_tagline = 'Ensemble, nous pouvons empêcher les géants de la tech de s’accaparer Internet.' %}
{% set banner_button_a = 'Je fais un don' %}
{% set banner_button_b = 'Je fais un geste' %}
{% set banner_button_c = 'Je fais une contribution' %}
{% else %}
{% set banner_title = 'Donate to Mozilla for Giving Tuesday' %}
{% set banner_tagline = 'Together we can reclaim the internet from Big Tech. Donate now.' %}
{% set banner_button_a = 'Donate' %}
{% set banner_button_b = 'Give now' %}
{% set banner_button_c = 'Contribute' %}
{% endif %}

{% if variant == "a" %}
{% set banner_link = 'https://foundation.mozilla.org/?form=gt-banner-a' %}
{% set banner_button = banner_button_a %}
{% set banner_ga_label = 'Donate' %}
{% elif variant == "b" %}
{% set banner_link = 'https://foundation.mozilla.org/?form=gt-banner-b' %}
{% set banner_button = banner_button_b %}
{% set banner_ga_label = 'Give now' %}
{% elif variant == "c" %}
{% set banner_link = 'https://foundation.mozilla.org/?form=gt-banner-c' %}
{% set banner_button = banner_button_c %}
{% set banner_ga_label = 'Contribute' %}
{% else %}
{% set banner_button = banner_button_a %}
{% set banner_ga_label = 'Donate' %}
{% set banner_link = 'https://foundation.mozilla.org/?form=gt-banner-d' %}
{% endif %}

{% block banner_content %}
<div class="mzp-l-content mzp-t-content-xl">
<div class="c-banner-inner">
<div class="c-banner-copy">
<h2 class="c-banner-title">{{ banner_title }}</h2>
<p class="c-banner-tagline">{{ banner_tagline }}</p>
<a class="c-banner-button mzp-c-button mzp-t-lg" href="{{ banner_link }}" data-cta-text="{{ banner_ga_label }}">
{{ banner_button }}
</a>
</div>
{{ picture(
url='img/banners/fundraiser/eoy-2024-photo-200.png',
sources=[
{
'media': '(min-width: 688px)',
'srcset': {
'img/banners/fundraiser/eoy-2024-photo-200.png': '200w',
'img/banners/fundraiser/eoy-2024-photo-200.png': '400w',
}
},
{
'media': '(max-width: 687px)',
'srcset': {
'img/placeholder.png': 'default'
}
}
],
optional_attributes={
'height': '200',
'width': '200',
'class': 'c-banner-media'
}
) }}
</div>
</div>
{% endblock %}
19 changes: 16 additions & 3 deletions bedrock/mozorg/templates/mozorg/home/home-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@

{% block page_desc %}{{ ftl('home-did-you-know-mozilla-the-maker') }}{% endblock %}

{% set show_fundraising_banner = switch('fundraising-banner-giving2024') and LANG in ['en-US', 'en-GB', 'en-CA', 'de', 'fr'] %}
{% set show_firefox_app_store_banner = switch('firefox-app-store-banner') %}

{% block experiments %}
{% if switch('fundraising-banner-giving2024') %}
{{ js_bundle('fundraising-banner-experiment') }}
{% endif %}
{% endblock %}

{% block page_css %}
{{ css_bundle('protocol-split') }}
{{ css_bundle('protocol-picto') }}
Expand All @@ -38,13 +45,17 @@
{{ css_bundle('ctd-promo') }}
{% endif %}

{% if show_firefox_app_store_banner %}
{% if show_fundraising_banner %}
{{ css_bundle('fundraising-banner') }}
{% elif show_firefox_app_store_banner %}
{{ css_bundle('firefox-app-store-banner') }}
{% endif %}
{% endblock %}

{% block page_banner %}
{% if show_firefox_app_store_banner %}
{% if show_fundraising_banner %}
{% include 'includes/banners/fundraiser.html' %}
{% elif show_firefox_app_store_banner %}
{% include 'includes/banners/mobile/firefox-app-store.html' %}
{% endif %}
{% endblock %}
Expand Down Expand Up @@ -316,7 +327,9 @@ <h2>{{ ftl('newsletter-form-join-the-community', fallback='newsletter-form-get-f
{% block js %}
{{ js_bundle('newsletter') }}

{% if show_firefox_app_store_banner %}
{% if show_fundraising_banner %}
{{ js_bundle('fundraising-banner') }}
{% elif show_firefox_app_store_banner %}
{{ js_bundle('firefox-app-store-banner') }}
{% endif %}
{% endblock %}
10 changes: 10 additions & 0 deletions bedrock/mozorg/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,19 @@ class HomeView(L10nTemplateView):

ftl_files_map = {old_template_name: ["mozorg/home"], template_name: ["mozorg/home-new"]}

# place expected ?v= values in this list
variations = ["a", "b", "c"]

def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx.update({"is_homepage": True})
variant = self.request.GET.get("v", None)

# ensure variant matches pre-defined value
if variant not in self.variations:
variant = None

ctx["variant"] = variant
return ctx

def get_template_names(self):
Expand Down
90 changes: 90 additions & 0 deletions media/css/base/banners/fundraiser.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

$font-path: '/media/protocol/fonts';
$image-path: '/media/protocol/img';

@import '~@mozilla-protocol/core/protocol/css/includes/lib';
@import 'includes/basic';

.c-banner-fundraising {
background: $color-green-20;
color: $color-black;

.mzp-l-content {
padding-top: $spacing-md;
padding-bottom: $spacing-md;
}

.c-banner-title {
color: $color-black;
display: block;
width: auto;
margin-bottom: $spacing-sm;
@include text-display-md;
}

.c-banner-tagline {
margin-bottom: $spacing-md;
@include text-body-md;
}

.c-banner-media {
display: none;
}

.c-banner-button {
background-color: $color-green-80;
border-color: $color-green-80;
margin: 0;
width: 100%;
@include text-body-lg;

&::after {
@include bidi(((content, '', ''),));
}

&:hover,
&:focus {
background-color: $color-green-90;
border-color: $color-green-90;
color: $color-white;
}
}

.c-banner-close {
background-image: url('#{$image-path}/icons/close.svg');
}

@media #{$mq-md} {
.c-banner-inner {
align-items: center;
display: flex;
flex-flow: row nowrap;
gap: 48px;
justify-content: space-between;
}

.c-banner-copy {
flex: 1 1 auto;
}

.c-banner-tagline {
@include text-body-lg;
}

picture {
display: block;
flex: 0 0 200px;
}

.c-banner-media {
display: block;
}

.c-banner-button {
width: auto;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions media/js/base/banners/fundraiser-experiment.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import TrafficCop from '@mozmeao/trafficcop';
import { isApprovedToRun } from '../experiment-utils.es6';

const href = window.location.href;

if (typeof window.dataLayer === 'undefined') {
window.dataLayer = [];
}

const init = () => {
if (href.indexOf('v=a') !== -1) {
window.dataLayer.push({
event: 'experiment_view',
id: 'home-fundraiser-giving-tues-2024',
variant: 'home-fundraiser-giving-tues-2024-va'
});
} else if (href.indexOf('v=b') !== -1) {
window.dataLayer.push({
event: 'experiment_view',
id: 'home-fundraiser-giving-tues-2024',
variant: 'home-fundraiser-giving-tues-2024-vb'
});
} else if (href.indexOf('v=c') !== -1) {
window.dataLayer.push({
event: 'experiment_view',
id: 'home-fundraiser-giving-tues-2024',
variant: 'home-fundraiser-giving-tues-2024-vc'
});
} else if (TrafficCop) {
if (isApprovedToRun()) {
const cop = new TrafficCop({
variations: {
'v=a': 33,
'v=b': 33,
'v=c': 33
}
});
cop.init();
}
}
};

init();
13 changes: 13 additions & 0 deletions media/js/base/banners/fundraiser.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import MozBanner from './mozilla-banner.es6';

function onLoad() {
MozBanner.init('fundraising-banner', true);
}

window.Mozilla.run(onLoad);
18 changes: 18 additions & 0 deletions media/static-bundles.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@
],
"name": "home-new"
},
{
"files": [
"css/base/banners/fundraiser.scss"
],
"name": "fundraising-banner"
},
{
"files": [
"css/mozorg/home/includes/monitor-banner.scss"
Expand Down Expand Up @@ -1855,6 +1861,18 @@
"js/firefox/share-page.es6.js"
],
"name": "firefox_share"
},
{
"files": [
"js/base/banners/fundraiser.es6.js"
],
"name": "fundraising-banner"
},
{
"files": [
"js/base/banners/fundraiser-experiment.es6.js"
],
"name": "fundraising-banner-experiment"
}
]
}

0 comments on commit d080de3

Please sign in to comment.