Skip to content

Commit

Permalink
Duplicate mobile trigger button behavior in featured experiment (mozi…
Browse files Browse the repository at this point in the history
…lla#3681)

* Duplicate mobile trigger button behavior in featured experiment

- fixes mozilla#3670

* css tweak for jgruen
  • Loading branch information
Dave Justice authored Jul 5, 2018
1 parent 55558d2 commit 3d05f23
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 25 deletions.
45 changes: 29 additions & 16 deletions frontend/src/app/components/FeaturedExperiment/FeaturedButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import React from "react";
import { Link } from "react-router-dom";
import { Localized } from "fluent-react/compat";
import LocalizedHtml from "../LocalizedHtml";
import { buildSurveyURL, experimentL10nId } from "../../lib/utils";
import { buildSurveyURL, experimentL10nId, isMobile } from "../../lib/utils";

import Modal from "../Modal";
import MeasurementSection from "../Measurements";
import MainInstallButton from "../MainInstallButton";
import MobileDialog from "../MobileDialog";
import LayoutWrapper from "../LayoutWrapper";

import iconMobileWhite from "../../../images/mobile-white.svg";
import {
MobileTriggerButton,
MobileStoreButton
} from "../../containers/ExperimentPage/ExperimentButtons";

import type { InstalledExperiments } from "../../reducers/addon";

Expand All @@ -26,6 +29,7 @@ type FeaturedButtonProps = {
hasAddon: any,
installed: InstalledExperiments,
sendToGA: Function,
userAgent: string
}

type FeaturedButtonState = {
Expand Down Expand Up @@ -136,11 +140,29 @@ export default class FeaturedButton extends React.Component {

render() {
const { experiment, installed, clientUUID,
hasAddon, enabled } = this.props;
const { slug, survey_url, title, platforms } = experiment;
hasAddon, enabled, userAgent } = this.props;
const { slug, survey_url, title, platforms, ios_url, android_url } = experiment;

const { showMobileDialog } = this.state;

const mobileControls = () => {
if (!isMobile(userAgent)) {
return (
<React.Fragment>
<div className="main-install__spacer"></div>
<MobileTriggerButton optionalClass={"main-install__button"} doShowMobileAppDialog={this.doShowMobileAppDialog} color={"default"} />
{ this.renderLegalLink() }
</React.Fragment>
);
}
return (
<React.Fragment>
{platforms.includes("ios") && <MobileStoreButton {...{ url: ios_url, platform: "ios" }} />}
{platforms.includes("android") && <MobileStoreButton {...{ url: android_url, platform: "android" }} />}
</React.Fragment>
);
};

let Buttons;

if (platforms.includes("ios") || platforms.includes("android")) {
Expand All @@ -152,18 +174,9 @@ export default class FeaturedButton extends React.Component {
/>}
<LayoutWrapper flexModifier={"column-center-start-breaking"}
helperClass="main-install">
<div className="main-install__spacer"></div>
<a
className="button primary icon-button main-install__button"
onClick={this.doShowMobileAppDialog}>
<img src={iconMobileWhite} />
<Localized id="mobileDialogTitle">
<span>Get the App</span>
</Localized>
</a>
{ this.renderLegalLink() }
{ mobileControls() }
</LayoutWrapper>
{this.renderLegalModal()}
{ this.renderLegalModal() }
</div>
);
} else if (enabled && hasAddon) {
Expand Down Expand Up @@ -198,7 +211,7 @@ export default class FeaturedButton extends React.Component {
experimentLegalLink={this.renderLegalLink()}
eventCategory="HomePage Interactions"
eventLabel="Install the Add-on" />
{this.renderLegalModal()}
{ this.renderLegalModal() }
</div>);
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/FeaturedExperiment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ type FeaturedExperimentProps = {
isExperimentEnabled: Function,
isMinFirefox: boolean,
installed: InstalledExperiments,
sendToGA: Function
sendToGA: Function,
userAgent: string
}

export default class FeaturedExperiment extends React.Component {
Expand Down
22 changes: 19 additions & 3 deletions frontend/src/app/components/FeaturedExperiment/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~photon-colors/colors.scss';
@import '~photon-colors/colors.scss';
@import '../../../styles/_utils';

.featured-experiment {
Expand All @@ -24,11 +24,11 @@
}

.featured-experiment__actions {
order: 5;
order: 6;
}

.featured-experiment__details {
order: 6;
order: 5;
}
}

Expand Down Expand Up @@ -258,6 +258,22 @@
}
}

.featured-experiment__actions {
.button.mobile {
@include respond-to('small') {
margin: 20px auto 0;
}

border: 0;
margin: 0;

img {
height: 60px;
width: auto;
}
}
}

.featured-experiment__video {
@include flex-container(column, flex-start, stretch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ export const FeedbackButton = ({
};

export const MobileTriggerButton = ({
doShowMobileAppDialog
doShowMobileAppDialog, optionalClass
}: MobileTriggerButtonType) => {
return (
<a
className="button mobile-trigger default icon-button"
className={`button mobile-trigger default icon-button ${optionalClass}`}
onClick={doShowMobileAppDialog}
>
<img src={iconExperimentTypeMobileWhite} />
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/containers/ExperimentPage/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export type FeedbackButtonType = {
};

export type MobileTriggerButtonType = {
doShowMobileAppDialog: Function
doShowMobileAppDialog: Function,
optionalClass?: string
};

export type GraduatedButtonType = {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/containers/HomePage/HomePageNoAddon.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type HomePageNoAddonProps = {
isFirefox: boolean,
isMinFirefox: boolean,
installed: InstalledExperiments,
sendToGA: Function
sendToGA: Function,
userAgent: string
}

export default class HomePageNoAddon extends React.Component {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/containers/HomePage/HomePageWithAddon.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type HomePageWithAddonProps = {
removeCookie: Function,
sendToGA: Function,
setCookie: Function,
uninstallAddon: Function
uninstallAddon: Function,
userAgent: string
}

type HomePageWithAddonState = {
Expand Down

0 comments on commit 3d05f23

Please sign in to comment.