Skip to content

Commit

Permalink
New features & improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
PavlosIsaris committed Jan 30, 2025
1 parent 593fb8d commit c62bdeb
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 354 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* Configuration File Changes: The configuration file format has been updated to reflect the new JSON cookie storage
method. The `cookie_prefix` is now used to store cookies in a JSON object.

## New Features

* JSON Cookie Storage: Cookies are now stored in a JSON object under a single key with the prefix specified in the
configuration file. This change improves the structure and management of cookies.
* `hide_floating_button_on_mobile` option: A new configuration option has been added to hide the floating cookies button
on mobile devices. This option allows you to control the visibility of the floating button based on the device type.
* UI/UX Improvements: The cookies consent modal has been updated with improved styling and layout for a better user
experience.

### Migration Guide

1. Update the configuration file to reflect the new JSON cookie storage method:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ return [
*/
'cookie_prefix' => '',
'display_floating_button' => true, // Set to false to display the footer link instead
'hide_floating_button_on_mobile' => false, // Set to true to hide the floating button on mobile
'use_separate_page' => false, // Set to true to use a separate page for cookies explanation
/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -184,6 +185,8 @@ page:
<a href="javascript:void(0);" onclick="toggleCookieBanner()">Cookies Preferences</a>
```
The `hide_floating_button_on_mobile` field is optional and, if set to `true`, will hide the floating button on mobile
The `use_separate_page` field is optional and, if set to `true`, will display the cookies preferences in a separate
page.
Expand Down
1 change: 1 addition & 0 deletions config/cookies_consent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
'cookie_prefix' => 'my_app_',
'display_floating_button' => true, // Set to false to display the footer link instead
'hide_floating_button_on_mobile' => false, // Set to true to hide the floating button on mobile
'use_separate_page' => false, // Set to true to use a separate page for cookies explanation
/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "laravel-cookies-consent",
"version": "3.0.0",
"version": "3.0.1",
"description": "<p align=\"center\"> <img src=\"logo.jpg\" alt=\"logo\" width=\"400\"> </p>",
"main": "index.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion public/cookies-consent.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/cookies-consent.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions resources/js/cookies-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ document.addEventListener('DOMContentLoaded', function () {
const cookieBanner = document.getElementById('cookies-consent-banner');
const cookieButton = document.getElementById('scify-cookie-consent-floating-button');
const showFloatingButton = cookieBanner.dataset.showFloatingButton === 'true' || cookieBanner.dataset.showFloatingButton === '1';
const hideFloatingButtonOnMobile = cookieBanner.dataset.hideFloatingButtonOnMobile === 'true' || cookieBanner.dataset.hideFloatingButtonOnMobile === '1';
let cookieConsent = getCookie('cookieConsent');
initialiseBanner();
setSliders();
Expand All @@ -42,8 +43,14 @@ document.addEventListener('DOMContentLoaded', function () {
function initialiseBanner() {
if (onCookiesPage()) {
cookieBanner.style.display = 'block';
if (showFloatingButton && cookieButton)
cookieButton.style.display = 'none';
if (showFloatingButton && cookieButton) {
// if on mobile, also check the hideFloatingButtonOnMobile
if (hideFloatingButtonOnMobile && window.innerWidth < 768) {
cookieButton.style.display = 'none';
} else {
cookieButton.style.display = 'block';
}
}
} else {
if (cookieConsent) {
cookieBanner.style.display = 'none';
Expand Down
Loading

0 comments on commit c62bdeb

Please sign in to comment.