![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@tilde-nlp/ngx-cookie-consent
Advanced tools
Library is created so there would be single component for accepting cookies across multiple Tilde projects which use angular.
Library is created so there would be single component for accepting cookies across multiple Tilde projects which use angular.
npm i ngx-cookie-consent
.import {CookieConsentModule} from 'ngx-cookie-consent';
.....
@NgModule({
imports: [
....
CookieConsentModule.forRoot({show: true})
]
}
forRoot method adds provider for cookie consent settings and makes them injectable.
There might be cases when multiple projects are built from same repo and for one project cookie consent should be enabled, but for other it should be disabled. For such cases, you do not need to call forRoot method when importing module, but you need to create provider for CookieSettings configuration. Use specified token in app to create this provider. It is possible to change factory deps and use your own config provider.
import {CookieConsentModule, COOKIE_CONSENT_SETTINGS_TOKEN} from 'ngx-cookie-consent';
import { ConfigService } from '@ngx-config/core';
export function CookieConsentSettingsFactory(config: ConfigService): CookieConsentSettings{
const settings = config.getSettings<CookieConsentSettings>("cookieConsent");
return settings ?? {};
}
.....
@NgModule({
imports: [
....
CookieConsentModule,
....
],
providers:[
{
provide: COOKIE_CONSENT_SETTINGS_TOKEN,
useFactory: CookieConsentSettingsFactory,
deps: [ConfigService]
}
]
}
@use 'ngx-cookie-consent/src/lib/mixins/cookie-consent-theme.mixin.scss' as cookie-consent;
...
// Theme param is to make border-top in primary color and second param is used for background color
@include cookie-consent.color(your-border-top-color, your-background-color);
<tld-cookie-consent></tld-cookie-consent>
To make cookie consent appear only if it has not been accepted, you need to check showConsent
value from CookieConsentService. Use the following code:
<!-- your.component.html -->
<tld-cookie-consent *ngIf="showCookieConsent"></tld-cookie-consent>
// your.component.ts
import { CookieConsentService } from 'ngx-cookie-consent';
....
export class YourComponent{
get showCookieConsent(){return this.cookieConsent.showConsent};
constructor(private readonly cookieConsent: CookieConsentService) {}
}
This should be enough to get cookie consent displayed and running.
This package is using ngx translate - if you have it in your project then it should be straight forward, otherwise follow their documentation to get started. Translations should be put under key "COOKIE_CONSENT".
For listening to changes, subscribe to observable provided in CookieConsentService:
// using take(1) since cookie consent should close after user action.
this.cookieConsent.cookiePreferencesChanged$
.pipe(take(1))
.subscribe((preferences) => {
// Handle user action here. Enable additional cookies etc.
});
This library has dependency of @ngbracket/ngx-layout which is not mentioned in package json, so there would be no errors while installing it.
FAQs
Library is created so there would be single component for accepting cookies across multiple Tilde projects which use angular.
We found that @tilde-nlp/ngx-cookie-consent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.