11# biscuitman.js 🍪 Lightweight Consent Manager
22
3- ![ screenshot of main UI] ( media/readmebanner .webp )
3+ ![ screenshot of main UI] ( media/ui .webp )
44
55#### [ View demo] ( https://replete.github.io/biscuitman )
66
1212 - Cookies/localstorage items removed on rejection/invalidation, if cookie details added
1313- Fully customizable strings so you can serve localized strings if you want
1414- Overridable localStorage key, consent global
15+ - Basic color theming via CSS variables
1516- Simple flat configuration object
1617- Injects scripts when granular consent is granted (` <script data-consent="analytics" type="text/plain" src="..."></script> ` )
1718- Injects embedded 'after' ` <script> ` from script tags with ` src ` properties on onload (= less markup)
3233 - allows easier event setting with `.on('revoke', (sec) => { if (sec === 'analytics') window.reload() )})`
3334 - `import biscuitman from '/dist/esm/biscuitman.withcss.mjs'; let bm = biscuitman.create(options);`
3435 - experimental stage, only worth maintaining if the codebase remains pretty much the same, consider this another packaging option
35- - see [ESM Module version demo](https://replete.github.io/biscuitman/index-esm.htmls) to see how to use it
36+ - see [ESM version demo](https://replete.github.io/biscuitman/index-esm.htmls) to see how to use it
3637- preliminary e2e tests ![ tests] ( https://github.com/replete/biscuitman/actions/workflows/node.js.yml/badge.svg )
3738
38- ![ screenshot of main UI] ( media/ui.webp )
39-
4039## How to use
4140[ View demo] ( https://replete.github.io/biscuitman ) for a more detailed example
4241
@@ -131,9 +130,31 @@ While you have the option to enable or disable some or all of these cookies, not
131130<link rel =" stylesheet" href =" biscuitman.min.css" />
132131```
133132
133+ ## Theme CSS
134+
135+ ```
136+ /* hacker mode */
137+ .biscuitman {
138+ --c: limegreen;
139+ --bg: #000;
140+ --tx: #fff;
141+ --ui: 255,255,255;
142+ font-family: monospace;
143+ }
144+ /* Dark mode */
145+ @media (prefers-color-scheme: dark) {
146+ .biscuitman {
147+ --c: #1586c6;
148+ --bg: #000;
149+ --tx: #fff;
150+ --ui: 255,255,255;
151+ }
152+ }
153+ ```
154+
134155If you want to make sure website content obscured underneath the banner, add these styles to your website CSS:
135156``` css
136- html :not (:has ( .bm-hide ) )::after {
157+ html :not (.bm-hide )::after {
137158 content :' ' ;
138159 min-height :300px ;
139160 display :block ;
@@ -142,8 +163,8 @@ html:not(:has(.bm-hide))::after {
142163```
143164
144165## Globals
145- - ` biscuitman ` – configuration object, must be ` window.biscuitman `
146- - ` Consent ` – object for accessing consents (override: ` global ` in ` window.biscuitman ` )
166+ - ` biscuitman ` – configuration object, must be ` window.biscuitman ` ( ` biscuitman.create(options) ` for ESM version)
167+ - ` Consent ` – object for accessing consents (override: ` global ` in config )
147168 ```
148169 {
149170 "consentTime": 1717846660979,
@@ -161,8 +182,8 @@ html:not(:has(.bm-hide))::after {
161182
162183## CSS Classes
163184
164- - ` biscuitman ` , ` bm-hide ` on UI container
165- - ` bm-{sectionName} ` , ` bm-no-{sectionName} ` on ` <html> ` for consent state
185+ - ` biscuitman ` on UI container
186+ - ` bm-{sectionName} ` , ` bm-no-{sectionName} ` , ` bm-hide ` on ` <html> `
166187
167188## Events
168189
@@ -208,6 +229,7 @@ Visiting `https://localhost:3000` should now work without warnings.
208229Jest is set up with puppeteer to run some integration tests. We're using ` @swc/jest ` 's rust implementation of jest to speed things up. This is only chromium for now, but at some point it would be good to implement browserStack selenium tests to automate browser compatibility checks.
209230
210231` npm run test ` - Launches pupeeter integration tests in a browser (in http mode only)
232+
211233` npm run coverage ` - run jest tests with coverage saved to ` /coverage/ `
212234
213235
0 commit comments