Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDFLSBP-651 - Implement cookie blocking placeholder #650

Merged
merged 11 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
@import "./src/stories/Library/article-header/article-header";
@import "./src/stories/Library/content-list/content-list";
@import "./src/stories/Library/content-list-item/content-list-item";
@import "./src/stories/Library/cookie-placeholder/cookie-placeholder";
@import "./src/stories/Library/image-credited/image-credited";
@import "./src/stories/Library/event-description/event-description";
@import "./src/stories/Library/link-with-icon/link-with-icon";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { CookiePlaceholder } from "./CookiePlaceholder";
import VideoEmbed from "../video-embed/VideoEmbed";

Check warning on line 3 in src/stories/Library/cookie-placeholder/CookiePLaceholder.stories.tsx

View workflow job for this annotation

GitHub Actions / JS Linter

'VideoEmbed' is defined but never used

export default {
title: "Library / Cookie Placeholder",
component: CookiePlaceholder,
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/design/Zx9GrkFA3l4ISvyZD2q0Qi/Designsystem?node-id=16042-22933&t=kwXRJW0pZzoQmJHm-1",
Dresse marked this conversation as resolved.
Show resolved Hide resolved
},
layout: "fullscreen",
},
argTypes: {
buttonText: {
defaultValue: "Manage consent",
type: "string",
},
acceptCookies: {
control: "boolean",
defaultValue: false,
},
info: {
defaultValue:
"To view this content, we need your consent to use cookies.",
type: "string",
},
src: {
defaultValue: "https://www.youtube.com/embed/CmzKQ3PSrow",
type: "string",
},
},
} as ComponentMeta<typeof CookiePlaceholder>;

const Template: ComponentStory<typeof CookiePlaceholder> = (props) => (
<CookiePlaceholder {...props} />
);

export const CookiesBlocked = Template.bind({});
66 changes: 66 additions & 0 deletions src/stories/Library/cookie-placeholder/CookiePlaceholder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { useState, useEffect } from "react";
import { Button } from "../Buttons/button/Button";

type CookiePlaceholderProps = {
info: string;
buttonText: string;
src: string;
acceptCookies: boolean;
};

export const CookiePlaceholder = ({
info,
buttonText,
src,
acceptCookies: acceptCookiesProp,
}: CookiePlaceholderProps) => {
const [acceptCookies, setAcceptCookies] = useState(acceptCookiesProp);

useEffect(() => {
setAcceptCookies(acceptCookiesProp);
}, [acceptCookiesProp]);

const handleButtonClick = () => {
setAcceptCookies(!acceptCookies);
};

return (
<section className="video-embed">
<div className="video-embed__wrapper">
<iframe
className={`${acceptCookies ? "" : "cookie-placeholder__hide"}`}
src={src}
title="VideoEmbed"
width="auto"
height="auto"
allowFullScreen
/>
<div
className={`consent-placeholder cookie-placeholder ${
acceptCookies ? "cookie-placeholder__hide" : ""
}`}
data-category="cookie_cat_marketing"
>
<div className="pagefold-triangle--medium pagefold-inherit-parent" />
<div className="cookie-placeholder__wrapper">
<div className="cookie-placeholder__description">
<div id="dpl-react-apps-cookie-placeholder">{info}</div>
</div>
<Button
classNames="cookie-placeholder__manage-consent-button"
size="xlarge"
label={buttonText}
buttonType="none"
variant="outline"
collapsible={false}
disabled={false}
onClick={handleButtonClick}
/>
</div>
</div>
</div>
</section>
);
};

export default CookiePlaceholder;
33 changes: 33 additions & 0 deletions src/stories/Library/cookie-placeholder/cookie-placeholder.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.cookie-placeholder {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #eee9e5;
width: 100%;
height: 100%;
clip-path: polygon(24px 0, 0 24px, 0 100%, 100% 100%, 100% 0);
-webkit-clip-path: polygon(24px 0, 0 24px, 0 100%, 100% 100%, 100% 0);
}

.cookie-placeholder__wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: $s-lg;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.cookie-placeholder__description {
Dresse marked this conversation as resolved.
Show resolved Hide resolved
font-family: $font__body;
font-weight: $font__weight--normal;
margin-bottom: $s-lg;
}

.cookie-placeholder__hide{
display: none;
}
Loading