Skip to content

Commit 5e96725

Browse files
committed
Added blade directives, views & assets
1 parent da1c914 commit 5e96725

File tree

10 files changed

+439
-6
lines changed

10 files changed

+439
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/vendor
2+
/node_modules
23
.idea
34
.DS_Store
45
Thumbs.db
56
composer.lock
7+
package-lock.json
8+
yarn.lock
69
.phpunit.result.cache
710
.php-cs-fixer.cache
811
.swp

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ This package will auto-register its service provider.
3030

3131
## Usage
3232

33-
First, we'll have to register the cookies used by your application. A good place to do so is in the `App\Providers\AppServiceProvider`'s `boot` method:
33+
First, let's publish the package's files:
34+
35+
1. Publish the assets: `php artisan vendor:publish --tag=laravel-cookie-consent-assets`
36+
2. Publish the views: `php artisan vendor:publish --tag=laravel-cookie-consent-views`
37+
38+
More on view customization below.
39+
40+
Now, we'll have to register and configure the used cookies. A good place to do so is in the `App\Providers\AppServiceProvider`'s `boot` method, but feel free to create your own `CookiesServiceProvider`.
3441

3542
```php
3643
use Whitecube\LaravelCookieConsent\Facades\Cookies;
@@ -52,19 +59,19 @@ More details on the available cookie registration methods below.
5259

5360
We can now add the consent scripts and modals to the application's layouts or views using the following blade directives:
5461

55-
- `@cookie-consent-scripts`: used to add the package's default JavaScript and any third-party script you need to get the end-user's consent for.
56-
- `@cookie-consent-alert`: used to render the alert or pop-up view.
62+
- `@cookieconsentscripts`: used to add the package's default JavaScript and any third-party script you need to get the end-user's consent for.
63+
- `@cookieconsentview`: used to render the alert or pop-up view.
5764

5865
```blade
5966
<!DOCTYPE html>
6067
<html lang="en">
6168
<head>
6269
<!-- ... -->
63-
@cookie-consent-scripts
70+
@cookieconsentscripts
6471
</head>
6572
<body>
6673
<!-- ... -->
67-
@cookie-consent-alert
74+
@cookieconsentview
6875
</body>
6976
</html>
7077
```
@@ -73,6 +80,10 @@ We can now add the consent scripts and modals to the application's layouts or vi
7380

7481
TBD.
7582

83+
### Views customization
84+
85+
TBD.
86+
7687
## 🔥 Sponsorships
7788

7889
If you are reliant on this package in your production applications, consider [sponsoring us](https://github.com/sponsors/whitecube)! It is the best way to help us keep doing what we love to do: making great open source software.

dist/mix-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"/script.js": "/script.js?id=ef89fd8d1f963cc1826f689ee93a1172"
3+
}

dist/script.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "laravel-cookie-consent",
3+
"scripts": {
4+
"test": "echo \"Error: no test specified\" && exit 1"
5+
},
6+
"devDependencies": {
7+
"laravel-mix": "^6.0.49"
8+
}
9+
}

resources/js/script.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class LaravelCookieConsent {
2+
3+
constructor() {
4+
console.log('LaravelCookieConsent script loaded');
5+
}
6+
7+
}
8+
9+
window.addEventListener('load', () => {
10+
window.LaravelCookieConsent = new LaravelCookieConsent();
11+
});

0 commit comments

Comments
 (0)