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

Add "center" position #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ Now there are certain parameters that you can change to customize your banner.
| Parameter | Type | Values |
| --------------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| `border` | String | (`"border"` or `"none"`) Default: `"border"` |
| `position` | String | (`"left"` or `"right"`) Default: `"left"` |
| `position` | String | (`"left"`, `"center"` or `"right"`) Default: `"left"` |
| `managePosition` | String | (`"left"` or `"right"`) Default: `"left"` |
| `bannerDescription` | String | Example: `"We use our own and third-party cookies to personalize content and to analyze web traffic."` |
| `bannerLinkText` | String | Example: `"Read more about cookies"` |
| `bannerBackground` | String | Example: `"#FAFAFA"` Example: `"lightblue"` |
Expand Down
139 changes: 85 additions & 54 deletions src/glowCookies.css
Original file line number Diff line number Diff line change
@@ -1,37 +1,59 @@
/* CUSTOM CLASSES */
.glowCookies__border {
border: 1px solid #e6e6e6 !important;
.glowCookies__container {
display: flex;
position: fixed;
left: 0;
right: 0;
bottom: 0;
top: 0;
opacity: 0;
visibility: hidden;
pointer-events: none;
z-index: 999;
padding: 15px;
}

.glowCookies__left {
left: 15px;
.glowCookies__container.glowCookies__center {
align-items: center;
justify-content: center;
}

.glowCookies__right {
right: 15px;
.glowCookies__container.glowCookies__left {
align-items: flex-end;
justify-content: flex-start;
}

.glowCookies__show {
opacity: 1 !important;
visibility: visible !important;
transform: scale(1) !important;
.glowCookies__container.glowCookies__right {
align-items: flex-end;
justify-content: flex-end;
}

.glowCookies__container.glowCookies__show {
opacity: 1;
visibility: visible;
pointer-events: all;
transition: opacity 0.2s ease;
}

.glowCookies__border {
border: 1px solid #e6e6e6 !important;
}

/* COMMON STYLES */
/* ========================= */
.glowCookies__banner {
opacity: 0;
visibility: hidden;
transform: scale(0.9);
font-family: inherit;
position: fixed;
width: auto;
max-width: 375px;
z-index: 999;
-webkit-box-shadow: 0 .625em 1.875em rgba(2,2,3,.2);
-moz-box-shadow: 0 .625em 1.875em rgba(2,2,3,.2);
box-shadow: 0 .625em 1.875em rgba(2,2,3,.2);
transition: transform .2s ease, opacity .2s ease !important;
-webkit-box-shadow: 0 0.625em 1.875em rgba(2, 2, 3, 0.2);
-moz-box-shadow: 0 0.625em 1.875em rgba(2, 2, 3, 0.2);
box-shadow: 0 0.625em 1.875em rgba(2, 2, 3, 0.2);
transition: transform 0.2s ease, opacity 0.2s ease !important;
}

.glowCookies__show .glowCookies__banner {
transform: scale(1);
}

.glowCookies__banner .accept__btn__styles {
Expand Down Expand Up @@ -77,7 +99,7 @@
}

.btn__section .btn__settings {
width: 100%;
width: 100%;
}
}

Expand Down Expand Up @@ -124,21 +146,20 @@

@media (max-width: 455px) {
.glowCookies__banner__1 {
bottom: 0px;
left: 0px;
right: 0px;
margin: 7px;
bottom: 0px;
left: 0px;
right: 0px;
margin: 7px;
}

.glowCookies__banner__1 .btn__section {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
margin-top: 20px;
}
}


/* BANNER STYLE 2 */
/* ========================= */
.glowCookies__banner__2 {
Expand Down Expand Up @@ -182,19 +203,19 @@

@media (max-width: 455px) {
.glowCookies__banner__2 {
bottom: 0px;
left: 0px;
right: 0px;
border-radius: 0px;
border: 0px;
max-width: 550px;
bottom: 0px;
left: 0px;
right: 0px;
border-radius: 0px;
border: 0px;
max-width: 550px;
}

.glowCookies__banner__2 .btn__section {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
margin-top: 20px;
}
}

Expand Down Expand Up @@ -241,19 +262,19 @@

@media (max-width: 455px) {
.glowCookies__banner__3 {
bottom: 0px;
left: 0px;
right: 0px;
border-radius: 0px;
border: 0px;
max-width: 550px;
bottom: 0px;
left: 0px;
right: 0px;
border-radius: 0px;
border: 0px;
max-width: 550px;
}

.glowCookies__banner__3 .btn__section {
display: flex;
flex-direction: column;
justify-content: space-between;
margin-top: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
margin-top: 20px;
}
}

Expand All @@ -263,6 +284,9 @@
position: fixed;
bottom: 15px;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
min-height: 50px;
min-width: 125px;
cursor: pointer;
Expand All @@ -274,9 +298,17 @@
padding: 12px 18px;
text-decoration: none;
user-select: none;
-webkit-box-shadow: 0 .625em 1.875em rgba(2,2,3,.1);
-moz-box-shadow: 0 .625em 1.875em rgba(2,2,3,.1);
box-shadow: 0 .625em 1.875em rgba(2,2,3,.1);
-webkit-box-shadow: 0 0.625em 1.875em rgba(2, 2, 3, 0.1);
-moz-box-shadow: 0 0.625em 1.875em rgba(2, 2, 3, 0.1);
box-shadow: 0 0.625em 1.875em rgba(2, 2, 3, 0.1);
}

.prebanner.glowCookies__left {
left: 15px;
}

.prebanner.glowCookies__right {
right: 15px;
}

.prebanner__border__1 {
Expand All @@ -292,14 +324,13 @@
}

.animation {
transition: .2s;
transition: 0.2s;
}

.animation:hover {
transform: scale(.97);
transform: scale(0.97);
}

.prebanner:hover {
text-decoration: none;
}

10 changes: 6 additions & 4 deletions src/glowCookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GlowCookies {
createDOMElements() {
// COOKIES BUTTON
this.PreBanner = document.createElement("div");
this.PreBanner.innerHTML = `<button type="button" id="prebannerBtn" class="prebanner prebanner__border__${this.config.bannerStyle} glowCookies__${this.config.position} glowCookies__${this.config.border} animation" style="color: ${this.banner.manageCookies.color}; background-color: ${this.banner.manageCookies.background};">
this.PreBanner.innerHTML = `<button type="button" id="prebannerBtn" class="prebanner prebanner__border__${this.config.bannerStyle} glowCookies__${this.config.managePosition} glowCookies__${this.config.border} animation" style="color: ${this.banner.manageCookies.color}; background-color: ${this.banner.manageCookies.background};">
<svg fill="currentColor" style="margin-right: 7px; margin-top: 2px; vertical-align: text-top;" height="15px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M510.52 255.82c-69.97-.85-126.47-57.69-126.47-127.86-70.17 0-127-56.49-127.86-126.45-27.26-4.14-55.13.3-79.72 12.82l-69.13 35.22a132.221 132.221 0 0 0-57.79 57.81l-35.1 68.88a132.645 132.645 0 0 0-12.82 80.95l12.08 76.27a132.521 132.521 0 0 0 37.16 72.96l54.77 54.76a132.036 132.036 0 0 0 72.71 37.06l76.71 12.15c27.51 4.36 55.7-.11 80.53-12.76l69.13-35.21a132.273 132.273 0 0 0 57.79-57.81l35.1-68.88c12.56-24.64 17.01-52.58 12.91-79.91zM176 368c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm32-160c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm160 128c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32z"/>
</svg>${this.banner.manageCookies.text}</button>`;
Expand All @@ -43,9 +43,11 @@ class GlowCookies {

// COOKIES BANNER
this.Cookies = document.createElement("div");
this.Cookies.className = `glowCookies__container glowCookies__${this.config.position}`;
this.Cookies.id = 'glowCookies-container';
this.Cookies.innerHTML = `<div
id="glowCookies-banner"
class="glowCookies__banner glowCookies__banner__${this.config.bannerStyle} glowCookies__${this.config.border} glowCookies__${this.config.position}"
class="glowCookies__banner glowCookies__banner__${this.config.bannerStyle} glowCookies__${this.config.border}"
style="background-color: ${this.banner.background};"
>
<h3 style="color: ${this.banner.color};">${this.banner.heading}</h3>
Expand Down Expand Up @@ -97,12 +99,12 @@ class GlowCookies {

openManageCookies() {
this.PreBanner.style.display = this.config.hideAfterClick ? "none" : "block"
this.DOMbanner.classList.remove('glowCookies__show')
this.Cookies.classList.remove('glowCookies__show')
}

openSelector() {
this.PreBanner.style.display = "none";
this.DOMbanner.classList.add('glowCookies__show')
this.Cookies.classList.add('glowCookies__show')
}

acceptCookies() {
Expand Down