Skip to content

Commit 211ede2

Browse files
authored
Merge pull request #1397 from inplayer-org/improvement/asset-previews/geo-restricted-asset
Keep consistency of asset previews in case of restricted asset & FooterText component refactored
2 parents e8bae63 + ec5aaa4 commit 211ede2

17 files changed

+225
-227
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
# [2.5.21] - 24.01.2022
6+
7+
## Change
8+
9+
- Styling changes in preview templates for restricted asset
10+
- FooterText component refactored
11+
512
# [2.5.20] - 21.01.2022
613

714
## Fixes

src/paywall-previews/Preview1/Preview1.tsx

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import React from 'react';
22

33
// Colors
4-
import { AnalyticsComponent, AnalyticsEvents, AnalyticsComponentType } from '../../analytics';
54
import colors from '../../theme/colors';
65

76
// Types
87
import Branding from '../types/branding';
98

109
// Components
10+
import { AnalyticsComponent, AnalyticsEvents, AnalyticsComponentType } from '../../analytics';
1111
import FooterText from '../shared/FooterText';
12+
import PreviewText from '../shared/PreviewText';
1213
import {
1314
OverlayLabel,
14-
RestrictedAssetContainer,
1515
RestrictedAssetIcon,
16+
StyledRestrictedAssetContainer,
1617
} from '../shared/PreviewComponents';
17-
import PreviewText from '../shared/PreviewText';
1818
import {
1919
InPlayerPreviewBox,
2020
LockIcon,
2121
ImageHolder,
2222
PaywallExplain,
2323
InplayerWhiteLogo,
24+
InplayerPremiumLabel,
2425
ItemDetails,
2526
BuyButtonWrapper,
2627
BuyButton,
@@ -38,10 +39,10 @@ type Props = {
3839
premiumContentLabel?: string;
3940
isRestrictedAsset?: boolean;
4041
isAuthenticated?: boolean;
42+
restrictedMessage?: string;
4143
};
4244

4345
const previewImg = 'https://assets.inplayer.com/images/preview-premium.jpg';
44-
const restrictedAssetImg = 'https://assets.inplayer.com/images/restricted-asset.png';
4546

4647
const Preview1 = ({
4748
branding: {
@@ -61,25 +62,27 @@ const Preview1 = ({
6162
premiumContentLabel = 'Premium content',
6263
isRestrictedAsset = false,
6364
isAuthenticated = false,
65+
restrictedMessage = 'This content is not available.',
6466
}: Props) => (
6567
<AnalyticsComponent>
6668
{({ pages, tracker, merchantId, ip }) => (
6769
<InPlayerPreviewBox className="inplayer-preview-box">
6870
{previewUnavailable && <OverlayLabel variant="h5">Preview not available yet</OverlayLabel>}
6971
<ImageHolder className="inplayer-imageholder" onClick={handleOpenModal}>
72+
{isRestrictedAsset && (
73+
// Call handleOpenModal here because this div element will be
74+
// on the top of all image elements in case of restricted asset
75+
<StyledRestrictedAssetContainer onClick={handleOpenModal}>
76+
<RestrictedAssetIcon />
77+
{restrictedMessage}
78+
</StyledRestrictedAssetContainer>
79+
)}
7080
<PreviewImage
7181
alt="coverPhoto"
7282
src={imageUrl}
7383
role="presentation"
7484
className="inplayer-paywall"
75-
isRestrictedAsset={isRestrictedAsset}
7685
/>
77-
{isRestrictedAsset && (
78-
<RestrictedAssetContainer>
79-
<RestrictedAssetIcon />
80-
{premiumContentLabel}
81-
</RestrictedAssetContainer>
82-
)}
8386
<PaywallExplain
8487
hasProtectedByLabel={hasProtectedByLabel}
8588
className="inplayer-paywallexplain"
@@ -102,8 +105,10 @@ const Preview1 = ({
102105
InPlayer Paywall
103106
</a>
104107
</InplayerWhiteLogo>
105-
<LockIcon className="inplayer-lock" />
106-
<span>{!isRestrictedAsset && premiumContentLabel}</span>
108+
<InplayerPremiumLabel>
109+
<LockIcon className="inplayer-lock" />
110+
<div>{premiumContentLabel}</div>
111+
</InplayerPremiumLabel>
107112
</PaywallExplain>
108113
</ImageHolder>
109114
<ItemDetails className="inplayer-itemdetails">

src/paywall-previews/Preview1/styled.ts

+14-26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ifProp } from 'styled-tools';
33
import { transparentize } from 'polished';
44
import { FaLock } from 'react-icons/fa';
55
import colors from '../../theme/colors';
6+
import { RestrictedAssetContainer } from '../shared/PreviewComponents';
67

78
export const InPlayerPreviewBox = styled.div`
89
background: ${({ theme }) => theme.palette.background.main};
@@ -46,32 +47,25 @@ export const PaywallExplain = styled.div<PaywallExplainProps>`
4647
box-sizing: border-box;
4748
padding: 2vh 3%;
4849
color: ${colors.white};
49-
display: ${ifProp('hasProtectedByLabel', 'block', 'none')};
50+
display: ${ifProp('hasProtectedByLabel', 'flex', 'none')};
5051
position: absolute;
5152
bottom: 0;
5253
width: 100%;
5354
font-size: 13px;
5455
line-height: 15px;
5556
text-align: left;
56-
57-
span {
58-
vertical-align: middle;
59-
max-width: calc(100% - 150px);
60-
display: inline-block;
61-
text-align: left;
62-
margin: 0;
63-
position: relative;
64-
font-size: 13px;
65-
padding: 0;
66-
line-height: 15px;
67-
}
57+
${ifProp(
58+
'hasProtectedByLabel',
59+
css`
60+
align-items: center;
61+
`
62+
)}
6863
`;
6964

7065
export const InplayerWhiteLogo = styled.div`
7166
position: absolute;
7267
right: 3%;
7368
display: block;
74-
margin: -4px 0 0;
7569
padding: 0;
7670
line-height: 15px;
7771
@@ -87,7 +81,7 @@ export const InplayerWhiteLogo = styled.div`
8781
line-height: 15px;
8882
8983
@media screen and (max-width: 600px) {
90-
max-width: 73px;
84+
max-width: 80px;
9185
}
9286
}
9387
@@ -104,10 +98,11 @@ export const InplayerWhiteLogo = styled.div`
10498
margin-bottom: 2px;
10599
line-height: 15px;
106100
}
101+
`;
107102

108-
@media screen and (max-width: 476px) {
109-
margin: 0px 0 0 0;
110-
}
103+
export const InplayerPremiumLabel = styled.div`
104+
display: flex;
105+
align-items: center;
111106
`;
112107

113108
export const ItemDetails = styled.div`
@@ -206,18 +201,11 @@ export const InplayerFooter = styled.div`
206201
}
207202
`;
208203

209-
export const PreviewImage = styled.img<{ isRestrictedAsset?: boolean }>`
204+
export const PreviewImage = styled.img`
210205
width: 100%;
211206
object-fit: cover;
212207
object-position: 50% 50%;
213208
cursor: pointer;
214-
215-
${({ isRestrictedAsset }) =>
216-
isRestrictedAsset &&
217-
css`
218-
filter: brightness(0.3);
219-
position: absolute;
220-
`}
221209
`;
222210

223211
export const LockIcon = styled(FaLock)`

src/paywall-previews/Preview2/Preview2.tsx

+19-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
import React from 'react';
2-
import { AnalyticsComponent, AnalyticsEvents, AnalyticsComponentType } from '../../analytics';
32

43
// Colors
5-
import {
6-
StyledPreviewBox,
7-
StyledImageHolder,
8-
AssetDetails,
9-
PaywallDescriptionSpan,
10-
BuyButtonWrapper,
11-
StyledIcon,
12-
Footer,
13-
StyledRestrictedAssetContainer,
14-
} from './styled';
154
import colors from '../../theme/colors';
165

176
// Types
187
import Branding from '../types/branding';
198

209
// Components
10+
import { AnalyticsComponent } from '../../analytics';
2111
import FooterText from '../shared/FooterText';
2212
import PreviewText from '../shared/PreviewText';
2313
import {
@@ -26,6 +16,16 @@ import {
2616
FooterLink,
2717
RestrictedAssetIcon,
2818
} from '../shared/PreviewComponents';
19+
import {
20+
StyledPreviewBox,
21+
StyledImageHolder,
22+
AssetDetails,
23+
PaywallDescriptionSpan,
24+
BuyButtonWrapper,
25+
StyledIcon,
26+
Footer,
27+
StyledRestrictedAssetContainer,
28+
} from './styled';
2929

3030
type Props = {
3131
branding?: Branding;
@@ -38,10 +38,10 @@ type Props = {
3838
handleOpenModal?: (e: any) => any;
3939
premiumContentLabel?: string;
4040
isAuthenticated?: boolean;
41+
restrictedMessage?: string;
4142
};
4243

4344
const previewImg = 'https://assets.inplayer.com/images/preview-premium.jpg';
44-
const restrictedAssetImg = 'https://assets.inplayer.com/images/restricted-asset.png';
4545

4646
const Preview2 = ({
4747
branding: {
@@ -62,9 +62,10 @@ const Preview2 = ({
6262
loginFooterLabel = 'Already have access? Login with your InPlayer account',
6363
premiumContentLabel = 'Premium content',
6464
isAuthenticated = false,
65+
restrictedMessage = 'This content is not available.',
6566
}: Props) => (
6667
<AnalyticsComponent>
67-
{({ pages, tracker, merchantId, ip }) => (
68+
{() => (
6869
<StyledPreviewBox
6970
id="preview-container"
7071
minHeight={minHeight}
@@ -78,16 +79,18 @@ const Preview2 = ({
7879
onClick={handleOpenModal}
7980
/>
8081
{isRestrictedAsset && (
81-
<StyledRestrictedAssetContainer>
82+
// Call handleOpenModal here because this div element will be
83+
// on the top of image container in case of restricted asset
84+
<StyledRestrictedAssetContainer onClick={handleOpenModal}>
8285
<RestrictedAssetIcon />
83-
This content is not available in your country
86+
{restrictedMessage}
8487
</StyledRestrictedAssetContainer>
8588
)}
8689
<AssetDetails>
8790
<StyledPaywallDescription color={buttonBgColor} hasProtectedByLabel={hasProtectedByLabel}>
8891
<PaywallDescriptionSpan>
8992
<StyledIcon name="star" />
90-
{!isRestrictedAsset && premiumContentLabel}
93+
{premiumContentLabel}
9194
</PaywallDescriptionSpan>
9295
</StyledPaywallDescription>
9396
<PreviewText value={previewTitle} padding="0 0 0.5rem 0" />

src/paywall-previews/Preview2/styled.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const AssetDetails = styled.div`
6565
`;
6666

6767
export const PaywallDescriptionSpan = styled(DescriptionSpan)`
68-
padding-bottom: 20px;
68+
padding: 20px 0;
6969
`;
7070

7171
export const BuyButtonWrapper = styled.div`
@@ -93,12 +93,20 @@ export const Footer = styled(PreviewFooter)`
9393
margin-top: 1.6em;
9494
text-align: left;
9595
padding-top: 0.5em;
96+
@media screen and (max-width: 768px) {
97+
text-align: center;
98+
}
9699
`;
97100

98101
export const StyledRestrictedAssetContainer = styled(RestrictedAssetContainer)`
102+
width: 50%;
99103
left: 25%;
100104
@media screen and (max-width: 768px) {
105+
width: 100%;
101106
left: 50%;
102-
top: 30%;
107+
top: 25%;
108+
}
109+
@media screen and (max-width: 480px) {
110+
top: 20%;
103111
}
104112
`;

0 commit comments

Comments
 (0)