smartec-consent-manager
v1.0.23
Published
A simple and lightweight Angular library for managing user consent and cookie banners.
Downloads
11
Maintainers
Readme
Smartec Consent Manager - Angular Library
A customizable consent manager for Angular applications that provides GDPR-compliant cookie consent management with a floating action button and configurable dialog.
Features
- Floating action button with configurable tooltip
- Customizable consent dialog
- Persistent consent preferences (using localStorage)
- GDPR compliant design
- Built with Angular Material
- Easy integration with Angular applications
Installation
- Install the package:
npm install smartec-consent-manager --save --legacy-peer-deps- Import the component in your application:
import { SmartecConsentManagerComponent } from 'smartec-consent-manager';- Add the component to your app template:
<smartec-consent-manager-manager [tooltipText]="'Administrar preferencias de cookies'"></smartec-consent-manager-manager>Usage
Basic Usage
<smartec-consent-manager-manager></smartec-consent-manager-manager>Customizing Tooltip
<smartec-consent-manager-manager [tooltipText]="'Administrar preferencias de cookies'"></smartec-consent-manager-manager>Or with a component property:
// In your component
consentTooltip = 'Custom tooltip text';<smartec-consent-manager-manager [tooltipText]="consentTooltip"></smartec-consent-manager-manager>Customizing Default Consent Preferences
You can customize the default consent preferences by providing your own implementation of the ConsentService:
import { Injectable } from '@angular/core';
import { ConsentService } from 'smartec-consent-manager';
@Injectable()
export class CustomConsentService extends ConsentService {
getDefaultPreferences() {
return {
necessary: true,
analytics: true, // Default to true for analytics
marketing: false,
preferences: true
};
}
}Then provide it in your module:
@NgModule({
providers: [
{ provide: ConsentService, useClass: CustomConsentService }
]
})
export class AppModule { }Styling
The floating button position can be customized by overriding these CSS variables in your global styles:
:root {
--smartec-consent-manager-fab-bottom: 20px;
--smartec-consent-manager-fab-right: 20px;
--smartec-consent-manager-fab-z-index: 1000;
}Development
Building the Library
- Navigate to the project root:
cd C:\dev\ng\smartec-consent-manager- Build the library:
ng build smartec-consent-managerPublishing the Library
- After building, navigate to the dist folder:
cd C:\dev\ng\smartec-consent-manager\projects\smartec-consent\dist- Publish to npm:
npm publishPublishing Tips
- Make sure you're logged in to npm:
npm login- Update the version in
projects/smartec-consent-manager/package.jsonbefore publishing:
npm version patch # or minor, major- If publishing to a private registry, use:
npm publish --registry http://your-registry-urlDependencies
This library requires:
- Angular (v12+ recommended)
- Angular Material
- @angular/cdk
- @angular/animations
