add message to ads about signing in

This commit is contained in:
Sean Yesmunt 2020-01-24 13:31:49 -05:00
parent c1e0f08584
commit b4564c6f46
5 changed files with 63 additions and 26 deletions
lbrytv/component
ui
component/sideNavigation
scss

View file

@ -1,28 +1,61 @@
// @flow
import * as PAGES from 'constants/pages';
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { withRouter } from 'react-router';
import I18nMessage from 'component/i18nMessage';
import Button from 'component/button';
function Extra(props) { const ADS_URL = '//assets.revcontent.com/master/delivery.js';
const url = '//assets.revcontent.com/master/delivery.js';
type Props = {
location: { pathname: string },
};
function Ads(props: Props) {
const {
location: { pathname },
} = props;
useEffect(() => { useEffect(() => {
const script = document.createElement('script'); const script = document.createElement('script');
script.src = url; script.src = ADS_URL;
script.async = true; script.async = true;
// $FlowFixMe
document.body.appendChild(script); document.body.appendChild(script);
return () => { return () => {
// $FlowFixMe
document.body.removeChild(script); document.body.removeChild(script);
// if user navigates too rapidly, <style> tags can build up // if user navigates too rapidly, <style> tags can build up
// $FlowFixMe
if (document.body.getElementsByTagName('style').length) { if (document.body.getElementsByTagName('style').length) {
// $FlowFixMe
document.body.getElementsByTagName('style')[0].remove(); document.body.getElementsByTagName('style')[0].remove();
} }
}; };
}, []); }, []);
return ( return (
<> <div className="ads-wrapper">
<p>Ads</p> <p>Ads</p>
<p>
<I18nMessage
tokens={{
sign_in_to_lbrytv: (
<Button
button="link"
label={__('Sign in to lbry.tv')}
navigate={`/$/${PAGES.AUTH}?redirect=${pathname}`}
/>
),
download_the_app: <Button button="link" label={__('download the app')} href="https://lbry.com/get" />,
}}
>
Hate these? %sign_in_to_lbrytv% or %download_the_app% for an ad free experience.
</I18nMessage>
</p>
<div <div
id="rc-widget-0a74cf" id="rc-widget-0a74cf"
data-rc-widget data-rc-widget
@ -30,8 +63,8 @@ function Extra(props) {
data-endpoint="//trends.revcontent.com" data-endpoint="//trends.revcontent.com"
data-widget-id="117427" data-widget-id="117427"
/> />
</> </div>
); );
} }
export default Extra; export default withRouter(Ads);

View file

@ -8,7 +8,9 @@ import Tag from 'component/tag';
import StickyBox from 'react-sticky-box/dist/esnext'; import StickyBox from 'react-sticky-box/dist/esnext';
import Spinner from 'component/spinner'; import Spinner from 'component/spinner';
import usePersistedState from 'effects/use-persisted-state'; import usePersistedState from 'effects/use-persisted-state';
import Ad from 'lbrytv/component/ads'; // @if TARGET='web'
import Ads from 'lbrytv/component/ads';
// @endif
const SHOW_CHANNELS = 'SHOW_CHANNELS'; const SHOW_CHANNELS = 'SHOW_CHANNELS';
const SHOW_TAGS = 'SHOW_TAGS'; const SHOW_TAGS = 'SHOW_TAGS';
@ -83,13 +85,17 @@ function SideNavigation(props: Props) {
<div>{children}</div> <div>{children}</div>
); );
return obscureSideNavigation ? ( // @if TARGET='web'
<Wrapper> if (obscureSideNavigation) {
<div className="navigation--placeholder"> return (
<Ad /> <Wrapper>
</div> <Ads />
</Wrapper> </Wrapper>
) : ( );
}
// @endif
return (
<Wrapper> <Wrapper>
<nav className="navigation"> <nav className="navigation">
<ul className="navigation-links"> <ul className="navigation-links">

View file

@ -6,6 +6,7 @@
@import 'init/vars'; @import 'init/vars';
@import 'init/mixins'; @import 'init/mixins';
@import 'init/gui'; @import 'init/gui';
@import 'component/ads';
@import 'component/animation'; @import 'component/animation';
@import 'component/button'; @import 'component/button';
@import 'component/card'; @import 'component/card';

View file

@ -0,0 +1,9 @@
.ads-wrapper {
@extend .navigation;
p {
margin-left: 0.4rem; // The ads provider adds weird padding to their wrapper
font-size: var(--font-xsmall);
color: var(--color-text-subtitle);
}
}

View file

@ -13,18 +13,6 @@
margin-top: var(--spacing-large); margin-top: var(--spacing-large);
} }
.navigation--placeholder {
@extend .navigation;
border-radius: var(--card-radius);
position: relative;
margin: auto;
p {
font-size: var(--font-xsmall);
color: var(--color-text-subtitle);
}
}
.navigation-links { .navigation-links {
@extend .ul--no-style; @extend .ul--no-style;
flex-direction: column; flex-direction: column;