Update example + readme
This commit is contained in:
parent
8245e276d4
commit
007bda5e51
2 changed files with 42 additions and 22 deletions
24
README.md
24
README.md
|
|
@ -16,18 +16,21 @@ Ici pour l'instant seulement un exemple pour **Laravel**.
|
|||
## Étape 1 : implémentation
|
||||
|
||||
### Ajouter le package avec npm
|
||||
- https://docs.gitlab.com/ee/user/packages/npm_registry/
|
||||
- https://lab.s-web.fr/ldc-web/projets/laravel-base-project/-/snippets/8
|
||||
- `npm i @ldc-web/cookie-notice --save-dev`
|
||||
|
||||
[Lien doc Gitlab](https://docs.gitlab.com/ee/user/packages/npm_registry/)
|
||||
|
||||
### Laravel
|
||||
- Ajouter dans le projet, les fichiers au bon endroit :
|
||||
- [`cn-cookies.blade.php`](./examples/cn-cookies.blade.php) dans le dossier `resources/view/vendor/`
|
||||
- [`standard.blade.php`](./examples/templates/standard.blade.php) dans le dossier `resources/view/vendor/cookie-notice-templates`
|
||||
- Inclure dans le layout general `@include('vendor.cn-cookies')`
|
||||
- Inclure dans le layout general `@include('vendor.cn-cookies')`.
|
||||
**Cela doit être avant le stack('scripts')**
|
||||
- **!! Ne pas oublier de modifier les configurations dans le blade `vendor.cn-cookies`**.
|
||||
|
||||
- Ensuite inclure les éléments **style** et **script**
|
||||
- SCSS
|
||||
- **SCSS**
|
||||
|
||||
@import "~@ldc-web/cookie-notice";
|
||||
// ou
|
||||
|
|
@ -36,10 +39,25 @@ Ici pour l'instant seulement un exemple pour **Laravel**.
|
|||
@import "~@ldc-web/cookie-notice/src/scss/themes/standard";
|
||||
- **TS/JS**
|
||||
|
||||
// Dans fo.ts
|
||||
@import "@ldc-web/cookie-notice"
|
||||
import CookieNotice from "@ldc-web/cookie-notice";
|
||||
window.WebCookieNotice = CookieNotice;
|
||||
|
||||
// Dans index.d.ts
|
||||
...
|
||||
import type CookieNotice from "@ldc-web/cookie-notice";
|
||||
|
||||
declare global {
|
||||
...
|
||||
|
||||
interface Window {
|
||||
CookieNotice: typeof CookieNotice;
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
### Wordpress
|
||||
**TODO: Add instructions for wordpress**
|
||||
|
||||
|
|
|
|||
|
|
@ -185,30 +185,32 @@ SCRIPT;
|
|||
|
||||
|
||||
{{-- INCLUDE TEMPLATE --}}
|
||||
@include('vendor.cookie-notice-templates/standard', compact(
|
||||
@include('vendor.cookie-notice-templates.standard', compact(
|
||||
'site_name', 'logo_picture_url', 'logo_alt_text',
|
||||
'confidentiality_page_url', 'strings'
|
||||
))
|
||||
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce ?? '' }}">
|
||||
window.WebCookieNotice = {};
|
||||
@foreach($cookies as $index_name => $cookie)
|
||||
window.WebCookieNotice['{{ $index_name }}'] = {};
|
||||
window.WebCookieNotice['{{ $index_name }}'].tmp = {};
|
||||
// SCRIPT
|
||||
window.WebCookieNotice['{{ $index_name }}'].tmp.script = {!! strip_tags($cookie['script']) !!};
|
||||
@php unset($cookie['script']); @endphp
|
||||
// FALLBACK
|
||||
@if(isset($cookie['fallback']))
|
||||
window.WebCookieNotice['{{ $index_name }}'].tmp.fallback = {!! strip_tags($cookie['fallback']) !!};
|
||||
@php unset($cookie['fallback']); @endphp
|
||||
@endif
|
||||
window.WebCookieNotice['{{ $index_name }}'].conf = @json($cookie);
|
||||
window.WebCookieNotice['{{ $index_name }}'].conf.script = window.WebCookieNotice['{{ $index_name }}'].tmp.script;
|
||||
window.WebCookieNotice['{{ $index_name }}'].conf.fallback = window.WebCookieNotice['{{ $index_name }}'].tmp.fallback;
|
||||
window.WebCookieNotice['{{ $index_name }}'] = window.WebCookieNotice['{{ $index_name }}'].conf;
|
||||
@endforeach
|
||||
window.WebCookieNotice = new WebCookieNotice(window.WebCookieNotice);
|
||||
document.addEventListner('DOMContentLoaded', function () {
|
||||
window.WebCookieNotice = {};
|
||||
@foreach($cookies as $index_name => $cookie)
|
||||
window.WebCookieNotice['{{ $index_name }}'] = {};
|
||||
window.WebCookieNotice['{{ $index_name }}'].tmp = {};
|
||||
// SCRIPT
|
||||
window.WebCookieNotice['{{ $index_name }}'].tmp.script = {!! strip_tags($cookie['script']) !!};
|
||||
@php unset($cookie['script']); @endphp
|
||||
// FALLBACK
|
||||
@if(isset($cookie['fallback']))
|
||||
window.WebCookieNotice['{{ $index_name }}'].tmp.fallback = {!! strip_tags($cookie['fallback']) !!};
|
||||
@php unset($cookie['fallback']); @endphp
|
||||
@endif
|
||||
window.WebCookieNotice['{{ $index_name }}'].conf = @json($cookie);
|
||||
window.WebCookieNotice['{{ $index_name }}'].conf.script = window.WebCookieNotice['{{ $index_name }}'].tmp.script;
|
||||
window.WebCookieNotice['{{ $index_name }}'].conf.fallback = window.WebCookieNotice['{{ $index_name }}'].tmp.fallback;
|
||||
window.WebCookieNotice['{{ $index_name }}'] = window.WebCookieNotice['{{ $index_name }}'].conf;
|
||||
@endforeach
|
||||
window.WebCookieNotice = new WebCookieNotice(window.WebCookieNotice);
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue