Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YouTube mobile newsletter sign up #3761

Merged
merged 6 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
{% endfor %}
</div>
<div class="intro-button-wrapper">
<button class="btn btn-primary btn-newsletter hidden-lg-up mx-auto d-none">Join Mozilla</button>
<button class="btn btn-primary btn-newsletter hidden-md-down mx-auto d-none">Join Mozilla</button>
</div>
</div>
Expand Down
28 changes: 20 additions & 8 deletions source/js/youtube-regrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ let elements = {
rings: `#view-youtube-regrets .intro-viewport .ring`,
introText: `#view-youtube-regrets .intro-viewport .intro-text p`,
scrollHint: `#view-youtube-regrets .intro-viewport .scroll-hint`,
newsletterButton: `#view-youtube-regrets .intro-viewport .btn-newsletter`
newsletterButtons: `#view-youtube-regrets .intro-viewport .btn-newsletter`,
newsletterButtonMobile: `#view-youtube-regrets .intro-viewport .btn-newsletter.hidden-lg-up`,
newsletterButtonDesktop: `#view-youtube-regrets .intro-viewport .btn-newsletter.hidden-md-down`
};

class YouTubeRegretsTunnel {
Expand Down Expand Up @@ -63,13 +65,15 @@ class YouTubeRegretsTunnel {
* Hide it otherwise.
*/
setNewsletterButtonVisibility(positionTohide) {
let button = elements.newsletterButton[0];
let buttons = elements.newsletterButtons;

if (window.pageYOffset >= positionTohide) {
button.classList.add(`d-none`);
} else {
button.classList.remove(`d-none`);
}
buttons.forEach(button => {
if (window.pageYOffset >= positionTohide) {
button.classList.add(`d-none`);
} else {
button.classList.remove(`d-none`);
}
});
}

/**
Expand Down Expand Up @@ -227,10 +231,18 @@ class YouTubeRegretsTunnel {
return;
}

elements.newsletterButton[0].addEventListener(`click`, event =>
elements.newsletterButtonDesktop[0].addEventListener(`click`, event =>
navNewsletter.buttonDesktopClickHandler(event)
);

elements.newsletterButtonMobile[0].addEventListener(`click`, event => {
if (navNewsletter.getShownState()) {
navNewsletter.closeMobileNewsletter(event);
} else {
navNewsletter.expandMobileNewsletter(event);
}
});

this.setSceneDepth();
this.setObjectsOpacity();
this.toggleScrollHint();
Expand Down
24 changes: 11 additions & 13 deletions source/sass/views/youtube-regrets.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
);
}

#nav-newsletter-form-wrapper.faded-in {
height: 100vh;
}

.intro-viewport {
--scenePerspective: 55;
--blockZTranslate: 0;
Expand Down Expand Up @@ -167,29 +171,28 @@
bottom: 0;
display: flex;
flex-direction: column;
justify-content: center;

@media (min-width: $bp-md) {
justify-content: start;
}
justify-content: start;

.intro-text {
position: relative;
width: 100%;
max-width: 840px;
height: 55%;
height: 60%;
margin: 0 auto;
text-align: center;

@media (min-width: $bp-md) {
height: 55%;
}

p {
font-family: "Changa", sans-serif;
font-weight: 500;
color: $youtube-regrets-red;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
bottom: 10px;
display: flex;
justify-content: center;
align-items: center;
Expand All @@ -198,11 +201,6 @@
opacity: 0;

@include scaleText(30px, 38px, 50px, 56px);

@media (min-width: $bp-md) {
top: unset;
bottom: 10px;
}
}
}

Expand Down