-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TW-1599 Add layout for 'Rewards' page * TW-1599 Implement fetching rewards * TW-1599 Remove an unused property * TW-1599 Refactoring according to comments * TW-1599 Implement star animation as a webm video * TW-1599 Fix star animation for Chrome
- Loading branch information
1 parent
73a0de2
commit 7298c6e
Showing
52 changed files
with
1,199 additions
and
186 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import { ChangeEvent } from 'react'; | ||
|
||
import { useDispatch } from 'react-redux'; | ||
|
||
import { togglePartnersPromotionAction } from 'app/store/partners-promotion/actions'; | ||
import { useShouldShowPartnersPromoSelector } from 'app/store/partners-promotion/selectors'; | ||
import { t } from 'lib/i18n'; | ||
import { useConfirm } from 'lib/ui/dialog'; | ||
|
||
export const usePartnersPromotionSettings = () => { | ||
const dispatch = useDispatch(); | ||
const confirm = useConfirm(); | ||
|
||
const isEnabled = useShouldShowPartnersPromoSelector(); | ||
|
||
const handleHidePromotion = async () => { | ||
const confirmed = await confirm({ | ||
title: t('closePartnersPromotion'), | ||
children: t('closePartnersPromoConfirm'), | ||
comfirmButtonText: t('disable') | ||
}); | ||
|
||
if (confirmed) { | ||
dispatch(togglePartnersPromotionAction(false)); | ||
} | ||
}; | ||
|
||
const handleShowPromotion = async () => { | ||
const confirmed = await confirm({ | ||
title: t('enablePartnersPromotionConfirm'), | ||
children: t('enablePartnersPromotionDescriptionConfirm'), | ||
comfirmButtonText: t('enable') | ||
}); | ||
|
||
if (confirmed) { | ||
dispatch(togglePartnersPromotionAction(true)); | ||
} | ||
}; | ||
|
||
const setEnabled = (toChecked: boolean, event?: ChangeEvent<HTMLInputElement>) => { | ||
event?.preventDefault(); | ||
|
||
return toChecked ? handleShowPromotion() : handleHidePromotion(); | ||
}; | ||
|
||
return { isEnabled, setEnabled }; | ||
}; |
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,67 @@ | ||
import React, { ChangeEvent, useCallback } from 'react'; | ||
|
||
import { useDispatch } from 'react-redux'; | ||
|
||
import { setAcceptedTermsVersionAction, setReferralLinksEnabledAction } from 'app/store/settings/actions'; | ||
import { useAcceptedTermsVersionSelector, useReferralLinksEnabledSelector } from 'app/store/settings/selectors'; | ||
import { | ||
PRIVACY_POLICY_URL, | ||
RECENT_TERMS_VERSION, | ||
TERMS_OF_USE_URL, | ||
TERMS_WITH_REFERRALS_VERSION | ||
} from 'lib/constants'; | ||
import { t, T } from 'lib/i18n'; | ||
import { useConfirm } from 'lib/ui/dialog'; | ||
|
||
export const useReferralLinksSettings = () => { | ||
const dispatch = useDispatch(); | ||
const enabled = useReferralLinksEnabledSelector(); | ||
const acceptedTermsVersion = useAcceptedTermsVersionSelector(); | ||
const confirm = useConfirm(); | ||
|
||
const setEnabled = useCallback( | ||
async (toChecked: boolean, event?: ChangeEvent<HTMLInputElement>) => { | ||
event?.preventDefault(); | ||
|
||
if (toChecked && acceptedTermsVersion < TERMS_WITH_REFERRALS_VERSION) { | ||
const confirmed = await confirm({ | ||
title: <T id="confirmEnableReferralLinksTitle" />, | ||
description: ( | ||
<T | ||
id="confirmEnableReferralLinksDescription" | ||
substitutions={[ | ||
<a | ||
href={TERMS_OF_USE_URL} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="underline text-secondary" | ||
> | ||
<T id="termsOfUsage" key="termsLink" /> | ||
</a>, | ||
<a | ||
href={PRIVACY_POLICY_URL} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="underline text-secondary" | ||
> | ||
<T id="privacyPolicy" key="privacyPolicyLink" /> | ||
</a> | ||
]} | ||
/> | ||
), | ||
comfirmButtonText: t('agreeAndContinue') | ||
}); | ||
|
||
if (!confirmed) { | ||
return; | ||
} | ||
} | ||
|
||
dispatch(setAcceptedTermsVersionAction(RECENT_TERMS_VERSION)); | ||
dispatch(setReferralLinksEnabledAction(toChecked)); | ||
}, | ||
[acceptedTermsVersion, confirm, dispatch] | ||
); | ||
|
||
return { isEnabled: enabled, setEnabled }; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export enum PageLayoutSelectors { | ||
backButton = 'Page Layout/Back Button', | ||
skipButton = 'Page Layout/Skip Button' | ||
skipButton = 'Page Layout/Skip Button', | ||
rewardsButton = 'Page Layout/Rewards Button' | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/app/layouts/PageLayout/RewardsButton/firefox-star-animation.tsx
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,39 @@ | ||
import React, { memo, useEffect, useRef } from 'react'; | ||
|
||
const starAnimationVideo = require('./star_animation.webm'); | ||
const starAnimationPoster = require('./star_animation_poster.gif'); | ||
|
||
interface Props { | ||
loop: boolean; | ||
} | ||
|
||
export const FirefoxStarAnimation = memo<Props>(({ loop }) => { | ||
const videoRef = useRef<HTMLVideoElement>(null); | ||
const prevLoopRef = useRef(loop); | ||
|
||
useEffect(() => { | ||
if (loop && !prevLoopRef.current) { | ||
videoRef.current!.play(); | ||
} else if (!loop && prevLoopRef.current) { | ||
videoRef.current!.currentTime = 0; | ||
videoRef.current!.pause(); | ||
} | ||
prevLoopRef.current = loop; | ||
}, [loop]); | ||
|
||
return ( | ||
<video | ||
className="w-4 h-4" | ||
src={starAnimationVideo} | ||
autoPlay | ||
muted | ||
loop={loop} | ||
ref={videoRef} | ||
poster={starAnimationPoster} | ||
controls={false} | ||
playsInline | ||
disablePictureInPicture | ||
disableRemotePlayback | ||
/> | ||
); | ||
}); |
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,34 @@ | ||
import React, { memo, useCallback, useState } from 'react'; | ||
|
||
import { TestIDProps } from 'lib/analytics'; | ||
import { T } from 'lib/i18n'; | ||
import { Link } from 'lib/woozie'; | ||
|
||
import { FirefoxStarAnimation } from './firefox-star-animation'; | ||
import { StarAnimation } from './star-animation'; | ||
|
||
export const RewardsButton = memo<TestIDProps>(props => { | ||
const [isHovered, setIsHovered] = useState(false); | ||
|
||
const handleHover = useCallback(() => setIsHovered(true), []); | ||
const handleUnhover = useCallback(() => setIsHovered(false), []); | ||
|
||
return ( | ||
<Link | ||
to="/rewards" | ||
className="bg-blue-150 text-blue-650 rounded-lg px-2 py-1 text-sm font-semibold leading-tight capitalize" | ||
onMouseEnter={handleHover} | ||
onMouseLeave={handleUnhover} | ||
{...props} | ||
> | ||
<div className="flex items-center gap-1 relative"> | ||
{process.env.TARGET_BROWSER === 'firefox' ? ( | ||
<FirefoxStarAnimation loop={isHovered} /> | ||
) : ( | ||
<StarAnimation loop={isHovered} /> | ||
)} | ||
<T id="rewards" /> | ||
</div> | ||
</Link> | ||
); | ||
}); |
Oops, something went wrong.