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

BREAKING CHANGE: Rename LmcCookieConsentManager to CookieConsentManager #400

Merged
merged 1 commit into from
Jan 6, 2025
Merged
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
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Load default CSS along with your styles in `<head>`:

```html
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@2/LmcCookieConsentManager.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@2/CookieConsentManager.min.css">
```

Load the script and initialize the plugin right before ending `</body>` tag:
Expand All @@ -47,7 +47,7 @@ Load the script and initialize the plugin right before ending `</body>` tag:
<script defer src="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@2/init.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function () {
initLmcCookieConsentManager('demo.example'); // use the name of your service, like jobs.cz, seduo.pl etc.
initCookieConsentManager('demo.example'); // use the name of your service, like jobs.cz, seduo.pl etc.
});
</script>
```
Expand All @@ -72,15 +72,15 @@ You can load the plugin from a CDN, as in the basic example above.
```html
<!-- Note we use version "cookie-consent-manager@2", which points to the latest version of this series (including feature and bugfix releases) -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@2/LmcCookieConsentManager.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@2/CookieConsentManager.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@2/init.js"></script>
```

Alternatively, you can also download the latest version from the [Releases page](https://github.com/lmc-eu/cookie-consent-manager/releases).

Loading the plugin from CDN or static file is recommended mostly **for static sites without their own build process**.

Once the plugin is loaded, you need to initialize it using `initLmcCookieConsentManager()` method, optionally providing
Once the plugin is loaded, you need to initialize it using `initCookieConsentManager()` method, optionally providing
[configuration parameters](#configuration).

### Via npm
Expand All @@ -99,10 +99,10 @@ via npm package [@lmc-eu/cookie-consent-manager](https://www.npmjs.com/package/@

2. Import the module in your javascript:
```js
import LmcCookieConsentManager from '@lmc-eu/cookie-consent-manager';
import CookieConsentManager from '@lmc-eu/cookie-consent-manager';

window.addEventListener('DOMContentLoaded', function () {
LmcCookieConsentManager('demo.example'/* , optional plugin configuration */);
CookieConsentManager('demo.example'/* , optional plugin configuration */);
});
```

Expand All @@ -112,11 +112,11 @@ via npm package [@lmc-eu/cookie-consent-manager](https://www.npmjs.com/package/@

3. Include default CSS in your HTML:
```html
<link rel="stylesheet" href="node_modules/@lmc-eu/cookie-consent-manager/LmcCookieConsentManager.min.css">
<link rel="stylesheet" href="node_modules/@lmc-eu/cookie-consent-manager/CookieConsentManager.min.css">
```
or in your Sass stylesheet:
```scss
@use "node_modules/@lmc-eu/cookie-consent-manager/LmcCookieConsentManager.css";
@use "node_modules/@lmc-eu/cookie-consent-manager/CookieConsentManager.css";
```

Please mind the `.css` extension used in the Sass example. Using the provided `.scss` stylesheet is
Expand Down Expand Up @@ -172,7 +172,7 @@ To execute custom code which depends on cookie consent use callbacks:

```js
// ...
initLmcCookieConsentManager(
initCookieConsentManager(
'demo.example',
{
onConsent: (cookieConsent) => {
Expand Down Expand Up @@ -205,7 +205,7 @@ This feature is enabled by default. If you'd like to disable it, you can do so b
`config` option:

```js
initLmcCookieConsentManager(
initCookieConsentManager(
'demo.example',
{
config: {
Expand All @@ -221,7 +221,7 @@ Optional config parameters could be provided on plugin initialization as the sec
encapsulated in the configuration object.

```js
initLmcCookieConsentManager( // when loaded as a module, these options are passed to `LmcCookieConsentManager()` instead
initCookieConsentManager( // when loaded as a module, these options are passed to `CookieConsentManager()` instead
'demo.example', // provide the name of your service, like jobs.cz, seduo.pl etc.
{
defaultLang: 'cs',
Expand Down Expand Up @@ -327,7 +327,7 @@ All you need to do is to add this plugin's SCSS to your Sass pipeline and use it

// Add this line anywhere you import other third-party CSS, possibly somewhere close
// to the end of your stylesheet as it contains CSS selectors with high specificity.
@use '@lmc-eu/cookie-consent-manager/LmcCookieConsentManager';
@use '@lmc-eu/cookie-consent-manager/CookieConsentManager';
```

<details>
Expand Down Expand Up @@ -473,8 +473,8 @@ yarn start
This will make the development server accessible http://localhost:3000/ .

* The library with init function is served on: http://localhost:3000/dist/init.js
* Javascript module: http://localhost:3000/dist/LmcCookieConsentManager.js
* CSS: http://localhost:3000/dist/LmcCookieConsentManager.css
* Javascript module: http://localhost:3000/dist/CookieConsentManager.js
* CSS: http://localhost:3000/dist/CookieConsentManager.css

### Contributing

Expand Down
2 changes: 1 addition & 1 deletion config/vite.config.init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig({
rollupOptions: {
output: [
{
name: 'LmcCookieConsentManagerInit',
name: 'CookieConsentManagerInit',
format: 'iife',
entryFileNames: '[name].js',
},
Expand Down
4 changes: 2 additions & 2 deletions config/vite.config.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
minify: true,
outDir: resolve(__dirname, '../dist'),
lib: {
entry: resolve(__dirname, '../src/LmcCookieConsentManager.ts'),
entry: resolve(__dirname, '../src/CookieConsentManager.ts'),
},
rollupOptions: {
output: [
Expand All @@ -23,7 +23,7 @@ export default defineConfig({
entryFileNames: '[name].js',
},
{
name: 'LmcCookieConsentManager',
name: 'CookieConsentManager',
format: 'iife',
entryFileNames: '[name].js',
},
Expand Down
4 changes: 2 additions & 2 deletions examples/callbacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<link rel="stylesheet" href="./assets/examples.css"><!-- This CSS is here for the purpose of this demo only, don't add it to your project -->
<script src="./assets/functions.js" defer></script>

<link rel="stylesheet" href="../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead -->
<link rel="stylesheet" href="../dist/CookieConsentManager.min.css"><!-- You will load this from CDN instead -->

<!-- This is only for purposes of this example page -->
<style>
Expand Down Expand Up @@ -147,7 +147,7 @@ <h2 class="mt-md-3 mb-3">onChange callback – dump of <code>categories</code> p
<script defer src="../dist/init.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function () {
window.ccm = initLmcCookieConsentManager( // note we store cookieConsent instance in global window.ccm variable
window.ccm = initCookieConsentManager( // note we store cookieConsent instance in global window.ccm variable
'github.example',
{
consentCollectorApiUrl: 'https://ccm.lmc.cz/local-data-acceptation-data-entries?Spot=(public,demo)', // override default URL for demo purposes; do not set custom consentCollectorApiUrl unless you have been explicitly guided to do so!
Expand Down
4 changes: 2 additions & 2 deletions examples/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link rel="stylesheet" href="./assets/examples.css"><!-- This CSS is here for the purpose of this demo only, don't add it to your project -->
<script src="./assets/functions.js" defer></script>

<link rel="stylesheet" href="../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead -->
<link rel="stylesheet" href="../dist/CookieConsentManager.min.css"><!-- You will load this from CDN instead -->
</head>
<body>
<script type="module" src="/src/init.ts"></script>
Expand Down Expand Up @@ -151,7 +151,7 @@ <h2 class="mt-md-3 mb-3">Use cookieConsent instance</h2>
<script defer src="../dist/init.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function () {
window.ccm = initLmcCookieConsentManager( // note we store cookieConsent instance in global window.ccm variable
window.ccm = initCookieConsentManager( // note we store cookieConsent instance in global window.ccm variable
'github.example',
{
autodetectLang: false, // do not detect language from the `<html lang="...">` value
Expand Down
4 changes: 2 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link rel="stylesheet" href="./assets/examples.css"><!-- This CSS is here for the purpose of this demo only, don't add it to your project -->
<script src="./assets/functions.js" defer></script>

<link rel="stylesheet" href="../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead -->
<link rel="stylesheet" href="../dist/CookieConsentManager.min.css"><!-- You will load this from CDN instead -->

<!-- Following script will be loaded only after "personalization" consent is detected -->
<script type="text/plain" data-category="personalization" src="./assets/personalization.js" defer></script>
Expand Down Expand Up @@ -159,7 +159,7 @@ <h2 class="mt-4 mt-md-5 mb-3">Content set using inline <code>&lt;script&gt;</cod
<script defer src="../dist/init.js"></script><!-- You will load this from CDN instead -->
<script>
window.addEventListener('DOMContentLoaded', function () {
initLmcCookieConsentManager(
initCookieConsentManager(
'github.example',
{
consentCollectorApiUrl: 'https://ccm.lmc.cz/local-data-acceptation-data-entries?Spot=(public,demo)', // override default URL for demo purposes; do not set custom consentCollectorApiUrl unless you have been explicitly guided to do so!
Expand Down
4 changes: 2 additions & 2 deletions examples/languages.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link rel="stylesheet" href="./assets/examples.css"><!-- This CSS is here for the purpose of this demo only, don't add it to your project -->
<script src="./assets/functions.js" defer></script>

<link rel="stylesheet" href="../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead -->
<link rel="stylesheet" href="../dist/CookieConsentManager.min.css"><!-- You will load this from CDN instead -->
</head>
<body>
<script type="module" src="/src/init.ts"></script>
Expand Down Expand Up @@ -176,7 +176,7 @@ <h2 class="mt-md-3 mb-3">Select language</h2>
<script defer src="../dist/init.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function () {
window.ccm = initLmcCookieConsentManager(
window.ccm = initCookieConsentManager(
'github.example',
{
autodetectLang: false,
Expand Down
4 changes: 2 additions & 2 deletions examples/theming.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<link rel="stylesheet" href="./assets/examples.css"><!-- This CSS is here for the purpose of this demo only, don't add it to your project -->
<script src="./assets/functions.js" defer></script>

<link rel="stylesheet" href="../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead -->
<link rel="stylesheet" href="../dist/CookieConsentManager.min.css"><!-- You will load this from CDN instead -->

<style>
.custom-theme {
Expand Down Expand Up @@ -243,7 +243,7 @@ <h2 class="mt-4 mt-md-5 mb-3">Without Spirit Design System</h2>
<script defer src="../dist/init.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function () {
initLmcCookieConsentManager(
initCookieConsentManager(
'github.example',
{
consentCollectorApiUrl: 'https://ccm.lmc.cz/local-data-acceptation-data-entries?Spot=(public,demo)', // override default URL for demo purposes; do not set custom consentCollectorApiUrl unless you have been explicitly guided to do so!
Expand Down
2 changes: 1 addition & 1 deletion examples/webpack-with-esm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap">

<link rel="stylesheet" href="../../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead -->
<link rel="stylesheet" href="../../dist/CookieConsentManager.min.css"><!-- You will load this from CDN instead -->

</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions examples/webpack-with-esm/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line import/no-unresolved
import { DisplayMode, LmcCookieConsentManager } from '@lmc-eu/cookie-consent-manager';
import { DisplayMode, CookieConsentManager } from '@lmc-eu/cookie-consent-manager';

const ccmArgs = {
displayMode: DisplayMode.SOFT,
Expand All @@ -13,5 +13,5 @@ const ccmArgs = {
};

window.addEventListener('DOMContentLoaded', () => {
LmcCookieConsentManager('example', ccmArgs);
CookieConsentManager('example', ccmArgs);
});
2 changes: 1 addition & 1 deletion examples/webpack-with-typescript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap">

<link rel="stylesheet" href="../../dist/LmcCookieConsentManager.min.css"><!-- You will load this from CDN instead -->
<link rel="stylesheet" href="../../dist/CookieConsentManager.min.css"><!-- You will load this from CDN instead -->

</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions examples/webpack-with-typescript/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line import/no-unresolved
import { LmcCookieConsentManager, DisplayMode } from '@lmc-eu/cookie-consent-manager';
import { CookieConsentManager, DisplayMode } from '@lmc-eu/cookie-consent-manager';

const ccmArgs = {
displayMode: DisplayMode.SOFT,
Expand All @@ -13,5 +13,5 @@ const ccmArgs = {
};

window.addEventListener('DOMContentLoaded', () => {
LmcCookieConsentManager('example', ccmArgs);
CookieConsentManager('example', ccmArgs);
});
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"type": "module",
"exports": {
".": {
"import": "./LmcCookieConsentManager.js",
"default": "./LmcCookieConsentManager.js"
"import": "./CookieConsentManager.js",
"default": "./CookieConsentManager.js"
}
},
"types": "./LmcCookieConsentManager.d.ts",
"types": "./CookieConsentManager.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/lmc-eu/cookie-consent-manager.git"
Expand All @@ -36,7 +36,7 @@
"scripts": {
"precss": "yarn css:lint",
"css": "npm-run-all --serial css:compile css:prefix css:minify",
"css:compile": "sass --load-path=node_modules --load-path=node_modules/@lmc-eu/spirit-design-tokens/scss src/LmcCookieConsentManager.scss dist/LmcCookieConsentManager.css",
"css:compile": "sass --load-path=node_modules --load-path=node_modules/@lmc-eu/spirit-design-tokens/scss src/CookieConsentManager.scss dist/CookieConsentManager.css",
"css:prefix": "postcss --config postcss.config.js --replace \"dist/*.css\" \"!dist/*.min.css\"",
"css:minify": "cleancss --format breaksWith=lf --source-map-inline-sources --batch --batch-suffix \".min\" \"dist/*.css\" \"!dist/*.min.css\"",
"css:lint": "stylelint --config .stylelintrc \"src/**/*.scss\" \"examples/assets/*.css\" --cache --cache-location .cache/.stylelintcache",
Expand All @@ -52,7 +52,7 @@
"lint:commit:last": "yarn commitlint --from HEAD~1 --to HEAD --verbose",
"prebuild": "npm-run-all --serial build:clean build:copy",
"build:clean": "rm -rf dist && mkdir -p dist/scss",
"build:copy": "cp package.json README.md src/LmcCookieConsentManager.scss dist/ && cp -r src/scss/* dist/scss/",
"build:copy": "cp package.json README.md src/CookieConsentManager.scss dist/ && cp -r src/scss/* dist/scss/",
"build": "npm-run-all --serial js css",
"serve": "vite --config ./config/vite.config.init.ts",
"start": "npm-run-all --parallel serve css:watch",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Alma Career Cookie Consent Manager
* Copyright 2021–2024 Alma Career Czechia s.r.o.
* Copyright 2021–2025 Alma Career Czechia s.r.o.
* Licensed under MIT (https://github.com/lmc-eu/cookie-consent-manager/blob/main/LICENSE.md)
*/

// Vanilla Cookie Consent CSS by Orest Bida.
@use 'vanilla-cookieconsent/dist/cookieconsent.css';

// Alma Career Cookie Consent Manager CSS by LMC.
// Alma Career Cookie Consent Manager CSS by Alma Career.
@use 'scss';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mergician } from 'mergician';
import submitConsent from './consentCollector';
import {
CategoriesChangeset,
CookieConsentManager,
type CookieConsentManager,
CookieConsentManagerOptions,
OnConsentCallback,
OnChangeCallback,
Expand Down Expand Up @@ -56,7 +56,7 @@ const defaultOptions: CookieConsentManagerOptions = {
* @returns {CookieConsent} Instance of the underlying CookieConsent component.
* See https://cookieconsent.orestbida.com/reference/api-reference.html
*/
const LmcCookieConsentManager: CookieConsentManager = (serviceName, args) => {
const CookieConsentManager: CookieConsentManager = (serviceName, args) => {
if (!serviceName || serviceName === '' || typeof serviceName !== 'string') {
throw new Error('serviceName is a required parameter and must be a string');
}
Expand Down Expand Up @@ -176,4 +176,4 @@ const LmcCookieConsentManager: CookieConsentManager = (serviceName, args) => {
return cookieConsent;
};

export { CookieConsentCategory, DisplayMode, CookieConsent, LmcCookieConsentManager };
export { CookieConsentCategory, DisplayMode, CookieConsent, CookieConsentManager };
4 changes: 2 additions & 2 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CookieConsentCategoryValues, VanillaCookieConsent } from './types';
import LmcCookieConsentManager from './LmcCookieConsentManager';
import CookieConsentManager from './CookieConsentManager';

declare global {
interface Window {
dataLayer: any[];
initCookieConsent: () => VanillaCookieConsent.CookieConsent<CookieConsentCategoryValues>;
initLmcCookieConsentManager: typeof LmcCookieConsentManager;
initCookieConsentManager: typeof CookieConsentManager;
}
}
8 changes: 4 additions & 4 deletions src/init.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { LmcCookieConsentManager } from './LmcCookieConsentManager';
import { CookieConsentManager } from './CookieConsentManager';

(function initialize() {
const init = 'initLmcCookieConsentManager';
const init = 'initCookieConsentManager';
/**
* Make LmcCookieConsent object accessible globally
* Make CookieConsentManager object accessible globally
*/
if (typeof window[init] !== 'function') {
/** @inheritdoc */
window[init] = LmcCookieConsentManager;
window[init] = CookieConsentManager;
}
})();
Loading