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

Responsive banner #3466

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
73 changes: 39 additions & 34 deletions clients/fides-js/src/components/ConsentBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,44 +49,49 @@ const ConsentBanner: FunctionComponent<BannerProps> = ({

return (
<div
id="fides-banner"
id="fides-banner-container"
className={`fides-banner fides-banner-bottom ${
isShown ? "" : "fides-banner-hidden"
} `}
>
<div id="fides-banner-inner">
<div id="fides-banner-title" className="fides-banner-title">
{title}
</div>
<div id="fides-banner-description" className="fides-banner-description">
{description}
</div>
<div id="fides-banner-buttons" className="fides-banner-buttons">
<span className="fides-banner-buttons-left">
<Button
buttonType={ButtonType.TERTIARY}
label={privacyPreferencesLabel}
onClick={handleManagePreferencesClick}
/>
</span>
<span className="fides-banner-buttons-right">
<Button
buttonType={ButtonType.PRIMARY}
label={rejectButtonLabel}
onClick={() => {
onRejectAll();
setIsShown(false);
}}
/>
<Button
buttonType={ButtonType.PRIMARY}
label={acceptButtonLabel}
onClick={() => {
onAcceptAll();
setIsShown(false);
}}
/>
</span>
<div id="fides-banner">
<div id="fides-banner-inner">
<div id="fides-banner-title" className="fides-banner-title">
{title}
</div>
<div
id="fides-banner-description"
className="fides-banner-description"
>
{description}
</div>
<div id="fides-banner-buttons" className="fides-banner-buttons">
<span className="fides-banner-buttons-left">
<Button
buttonType={ButtonType.TERTIARY}
label={privacyPreferencesLabel}
onClick={handleManagePreferencesClick}
/>
</span>
<span className="fides-banner-buttons-right">
<Button
buttonType={ButtonType.PRIMARY}
label={rejectButtonLabel}
onClick={() => {
onRejectAll();
setIsShown(false);
}}
/>
<Button
buttonType={ButtonType.PRIMARY}
label={acceptButtonLabel}
onClick={() => {
onAcceptAll();
setIsShown(false);
}}
/>
</span>
</div>
</div>
</div>
</div>
Expand Down
52 changes: 36 additions & 16 deletions clients/fides-js/src/components/fides.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
--fides-overlay-padding: 1.5em;
--fides-overlay-button-border-radius: 4px;
--fides-overlay-button-padding: 0.5em 1em;
--fides-overlay-component-border-radius: 0px;
--fides-overlay-component-border-radius: 4px;
}

div#fides-overlay {
Expand All @@ -63,53 +63,73 @@ div#fides-overlay {
display: none;
}

div#fides-banner-container {
position: fixed;
z-index: 1;
width: 100%;
transform: translateY(0%);
transition: transform 1s;
display: flex;
justify-content: center;
}

div#fides-banner {
font-size: var(--fides-overlay-font-size-body-small);
background: var(--fides-overlay-background-color);
color: var(--fides-overlay-body-font-color);
box-sizing: border-box;
padding: var(--fides-overlay-padding);
border: 1px solid var(--fides-overlay-primary-color);
border-radius: var(--fides-overlay-component-border-radius);

display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
transition: transform 1s;
}

div#fides-banner-inner {
width: 100%;
}

div#fides-banner.fides-banner-bottom {
position: fixed;
z-index: 1;
width: 100%;
div#fides-banner-container.fides-banner-bottom {
bottom: 0;
left: 0;
transform: translateY(0%);
}

div#fides-banner.fides-banner-bottom.fides-banner-hidden {
div#fides-banner-container.fides-banner-bottom.fides-banner-hidden {
transform: translateY(100%);
}

div#fides-banner.fides-banner-top {
position: fixed;
z-index: 1;
width: 100%;
div#fides-banner-container.fides-banner-top {
top: 0;
left: 0;
transform: translateY(0%);
}

div#fides-banner.fides-banner-top.fides-banner-hidden {
div#fides-banner-container.fides-banner-top.fides-banner-hidden {
transform: translateY(-100%);
}

/* Responsive banner */
@media screen and (min-width: 48em) {
div#fides-banner {
width: 75%;
border-radius: var(--fides-overlay-component-border-radius);
border: 1px solid var(--fides-overlay-primary-color);
}
div#fides-banner-container.fides-banner-bottom {
bottom: 48px;
}
div#fides-banner-container.fides-banner-top {
top: 48px;
}
}

@media only screen and (min-width: 80em) {
div#fides-banner {
width: 60%;
}
}

div#fides-banner-title {
font-size: var(--fides-overlay-font-size-title);
font-weight: 600;
Expand Down
2 changes: 1 addition & 1 deletion clients/privacy-center/cypress/e2e/consent-banner.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe("Consent banner", () => {
});
});
it("should render the expected HTML banner", () => {
cy.get("div#fides-banner.fides-banner").within(() => {
cy.get("div#fides-banner").within(() => {
cy.get(
"div#fides-banner-description.fides-banner-description"
).contains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<title>fides-js script demo page</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<script src="./lib/fides.js"></script>
<script>
Expand Down
1 change: 1 addition & 0 deletions clients/privacy-center/public/fides-js-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<title>fides-js script demo page</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
eastandwestwind marked this conversation as resolved.
Show resolved Hide resolved

<script src="/fides.js"></script>

Expand Down