npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adia-technology/policies-consent-widget

v1.1.6

Published

Angular module to manage terms, policies and Smartlook integration.

Downloads

36

Readme

PoliciesConsentWidget

Set of reusable components to compose customizable policy consent Angular modal. This library was generated with Angular CLI version 7.3.10.

Getting started

Installing

Npm installation:

npm install @adia-technology/policies-consent-widget --save

Usage & example

In order to customize the looks of a modal prepare property of type Theme and specify colors.

  theme: Theme =
  {
    'primary-color':'#53d356',
    'secondary-color':'#333333',
    'tertiary-color':'#E7E7E7',
    'quaternary-color':'#E2E6EA',
    'switch-bg-color':'#FFFFFF',
    'btn-text-color':'#FFFFFF'
  }

Add third party scss imports to your global styling scss.

@import '~ngx-smart-modal/ngx-smart-modal';
@import '~ngx-ui-switch/ui-switch.component.scss';

Basic example

<app-consent-modal [theme]="theme" [identifier]="your-modal-identifier">
  <app-consent-modal-navigation
  [theme]="theme"
  (onClose)="methodHandlingCloseAction()"></app-consent-modal-navigation>
  Put a content here e.g. html.
  <app-consent-switch [theme]="theme" (switchToggled)="setSwitch($event)"></app-consent-switch>
  <app-consent-button [theme]="theme" [innerText]="'Confirm'" (onClick)="confirmConsent()"></app-consent-button>
</app-consent-modal>

Example with markdown rendering within modal. This was accomplished by utilizing *ngIf=...; else ... and <ng-template #...>, thus the reason to supply below flags and events. You have to provide markdown string to app-markdown-to-html component via [markdownContent] binding. Provide flag for showing and hiding navigation back arrow, which is hidden by default. Inform app-consent-modal via [confirmedConsent] that consent is confirmed and modal can be closed. Toggle modal view when navigating back from rendered markdown by listening (onNavigateBack) event.

<app-consent-modal
[theme]="theme"
[identifier]="your-modal-identifier"
[confirmedConsent]="confirmedConsent">
  <app-consent-modal-navigation
  [theme]="theme"
  [showArrow]="showMarkdown"
  (onClose)="saveToCookie()"
  (onNavigateBack)="toggleMarkdown($event)"></app-consent-modal-navigation>
  <div *ngIf="!showMarkdown; else markdown">
    <h1>{{ primaryHeader }}</h1>
    <h2>{{ secondaryHeader }}</h2>
    <h3>{{ tertiaryHeader }}</h3>
    <div>{{ subheaderPart1 }}
      <a (click)="renderMarkdown()"> {{ subheaderPart2 }}</a>
    </div>
  </div>
  <app-consent-switch [theme]="theme" (switchToggled)="setSwitch($event)"></app-consent-switch>
  <app-consent-button [theme]="theme" [innerText]="'Confirm'" (onClick)="confirmedConsent()"></app-consent-button>
  <ng-template #markdown>
    <app-markdown-to-html [theme]="theme" [markdownContent]="markdown"></app-markdown-to-html>
  </ng-template>
</app-consent-modal>

Services

You need to call forRoot method on import in app.module like this:

import { ConsentModule, ConsentModuleConfig } from '@adia-technology/policies-consent-widget';

PoliciesConsentConfig: ConsentModuleConfig = {
  markdownBaseUrl: 'https://yur.domain.com/documents/',
  cookieName: 'smartlook-consent',
  countrySuffix: '-EN/',
  markdownNames: {
    SmartlookConsent: 'smartlook-info.md',
    TermsOfUse: 'platform-terms-of-use.md',
    PrivacyPolicy: 'platform-privacy-policy.md',
    GeneralStaffingTerms: "platform-general-staffing-terms.md"
  }
};

@NgModule({
    imports: [
        ConsentModule.forRoot(PoliciesConsentConfig)
    ],
    ...

You need to have a specific hierarchy of folders in your documents folder like this:

  • Documents --en-EN ---smartlook-info.md ---platform-terms-of-use.md ---platform-privacy-policy.md ---platform-general-staffing-terms.md --de-EN ---smartlook-info.md ---platform-terms-of-use.md ---platform-privacy-policy.md ---platform-general-staffing-terms.md ... --[lang]-[countrySuffix] ---your-policy.md ---your-terms.md ---your-smartlook-info.md ---your-staffing-terms.md
  • MarkdownService To download markdown you need to use getMarkdown method like this:
 private getMarkdown(type: MarkdownType) {
    this.markdownService.getMarkdown(type,
      lang,
      (result) => {
        this.markdown = result;
        this.consentPopup.open();
      },
      (error) => {console.log(error)});
  }

type is a MarkdownType enum lang is a string 2 letter language shortcut like "en"

  • Smartlook service This service use MarkdownService and have similar method getMarkdown to get smartlook info but it returns promise.
 private getMarkdown() {
    this.smartlookService.getMarkdown(lang)
    .then(result => {
        this.markdown = result;
        this.consent.open();
      });
  }

It also provide a methods for cookie management. Here are some use cases:

  saveConsent() {
    window.location.reload();
    window.onunload = () => {
      this.smartlookService.save(this.consentGiven);
    };
  }

  if (this.smartlookService.isConsentSet()) {
      this.consentGiven = this.smartlookService.isEnabled();
    }

.isConsentSet() - check if cookie is created with true or false value .isEnabled() - checks if value is true .save(boolean) - saves user choice.

Built With

  • ngx-smart-modal - Angular library for managing modals inside any Angular project
  • ngx-md - Angular directive for parsing markdown content in your web application
  • ngx-ui-switch - Switch component for Angular