Skip to content

Commit

Permalink
revert use of custom bg image
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Aug 4, 2021
1 parent f3f05d1 commit 63a74b7
Showing 1 changed file with 35 additions and 48 deletions.
83 changes: 35 additions & 48 deletions src/PrivacyProtection/PrivacyProtection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ function canShow(domain_key) {
return cookie.load(key(domain_key)) === 'true';
}

export default ({ children, data = {}, block, background, ...rest }) => {
export default ({ children, data = {}, block, ...rest }) => {
const { dataprotection = {} } = data;
const [visible, setVisibility] = useState(false);
const defaultShow = canShow(dataprotection.privacy_cookie_key);
const defaultShow = canShow(data.privacy_cookie_key);
const [show, setShow] = useState(defaultShow);
const [remember, setRemember] = useState(defaultShow);

const bgImg = background ? background : '';

return (
<VisibilitySensor
onChange={(isVisible) => {
Expand All @@ -50,59 +48,48 @@ export default ({ children, data = {}, block, background, ...rest }) => {
{!dataprotection.enabled || show ? (
children
) : (
<div
className="privacy-protection"
style={
bgImg
? {
backgroundImage: `url(${bgImg})`,
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
}
: {}
}
{...rest}
>
<div className="overlay">
<div className="wrapped">
<div className="privacy-protection" {...rest}>
<div className="wrapped">
<Message>
<div
className="privacy-statement"
dangerouslySetInnerHTML={{
__html: dataprotection.privacy_statement,
}}
/>
<div className="privacy-button">
<Button
primary
onClick={() => {
setShow(true);
if (remember) {
saveCookie(dataprotection.privacy_cookie_key);
}
}}
>
Show external content
</Button>
</div>
</Message>

<div className="privacy-toggle">
<Checkbox
toggle
label="Remember my choice"
id={`remember-choice-${block}`}
onChange={(ev, { checked }) => {
setRemember(checked);
}}
checked={remember}
/>
</div>
<div className="privacy-button">
<Button
primary
onClick={() => {
setShow(true);
if (remember) {
saveCookie(dataprotection.privacy_cookie_key);
}
}}
>
Show external content
</Button>
</div>

<p className="discreet">
Your choice will be saved in a cookie managed by{' '}
{config.settings.ownDomain || '.eea.europa.eu'} that will
expire in {getExpDays()} days.
</p>
<div className="privacy-toggle">
<Checkbox
toggle
label="Remember my choice"
id={`remember-choice-${block}`}
onChange={(ev, { checked }) => {
setRemember(checked);
}}
checked={remember}
/>
</div>

<p className="discreet">
Your choice will be saved in a cookie managed by{' '}
{config.settings.ownDomain || '.eea.europa.eu'} that will
expire in {getExpDays()} days.
</p>
</div>
</div>
)}
Expand Down

0 comments on commit 63a74b7

Please sign in to comment.