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

header-test-c

v0.1.2

Published

testing header component with lit element

Downloads

17

Readme

Thiqah Lit-Element Header Component POC

Thiqah Lit-Element Header Component POC is the beta version of lit-element web components development developed by Thiqah Frontend Development Team

Installation

in case using NPM package installer run one of the following commnad lines

npm i header-test-c -D
npm install header-test-c --save-dev

in case using YARN package installer

yarn add header-test-c

Usage in regular web project

static pages, .NET or any none JS framework inside your html file

<!-- 
    add vendor custom element adapters and styles before the body tag be sure that file comes from 
    ./node-module/header-test-c/vendor/custom-elements-es5-adapter.js
    ./node-module/header-test-c/src/header.min.css

-->
<script src="./node-module/header-test-c/vendor/custom-elements-es5-adapter.js"></script>
<link rel="stylesheet" href="./node-module/header-test-c/src/header.min.css" />
<main>
   <header-component backgroundColor="#0d8a86" mainMenu='[]'
        userDetails='{"shortName": "علي الغامدي", "hasDetails": false}' logo='' logoLink='#' slogan=''
        sloganLink='#' projectName='الاسماء التجارية' languages='["EN", "AR"]' isSinglePage="false"
        currentLang="ar" />
    </header-component>
</main>
<!-- 
    add web components loader and header component source be sure that file comes from 
    /node-module/header-test-c/vendor/webcomponents-loader.js 
    /node-module/header-test-c/header.min.js 
-->
<script src="./node-module/header-test-c/vendor/webcomponents-loader.js"></script>
<script type="text/javascript" src="header.min.js"></script>

<!-- to listen to language changes please add the current listener -->
<script>
        var Thiqah = function () {
            this.header = document.querySelector('header-component');
            this.nav = {
                ar: [{
                        "name": "الشركات",
                        "link": "#"
                    },
                    {
                        "name": "الأسماء التجارية",
                        "link":"#"
                    },
                    {
                        "name": "طلباتي",
                        "link": "#"
                    },
                    {
                        "name": "المحفظة",
                        "link": "#",
                        "counter": 3000
                    }
                ],
                en: [{
                        "name": "companies",
                        "link": "#"
                    },
                    {
                        "name": "names",
                        "link": "#"
                    },
                    {
                        "name": "requests",
                        "link": "#"
                    },
                    {
                        "name": "walet",
                        "link": "#",
                        "counter": 200
                    }
                ]
            };
            this.init();
            this.eventListeners();
        };

        Thiqah.prototype.init = function () {
            this.header.mainMenu = this.nav['ar'];
        };

        Thiqah.prototype.eventListeners = function () {
            this.header.addEventListener('langValueChange', this.switchLanguage.bind(this));
        };

        Thiqah.prototype.switchLanguage = function (event) {
            event.detail.lang === 'ar' ?
                document.body.classList.add('rtl') :
                document.body.classList.remove('rtl');

            this.header.mainMenu = this.nav[event.detail.lang];
        };

        window.onload = new Thiqah();
    </script>

Usage in Angular Project

// inside app.module.ts allow CUSTOM_ELEMENTS_SCHEMA
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@NgModule({
  declarations: [],
  imports: [],
  providers: [],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
<!-- inside index.html add vendors and assets from node-modules -->
<!-- 
    add vendor custom element adapters before the body tag be sure that file comes from 
    /node-module/header-test-c/vendor/custom-elements-es5-adapter.js
    /node-module/header-test-c/vendor/webcomponents-loader.js
    /node-module/header-test-c/header.min.js
-->
<script src="./node-module/header-test-c/vendor/custom-elements-es5-adapter.js"></script>
<script src="./node-module/header-test-c/vendor/webcomponents-loader.js"></script>
<script type="text/javascript" src="header.min.js"></script>

Or import assets inside angular.json

// inside your app.component.ts add your event listener
import { Component, ElementRef, NgZone } from '@angular/core';
import { MainMenu } from './models/MainMenu.model';

/** 
 * MainMenu.model should contain the current models
  interface Menu {
      name: string;
      link: string;
      counter?: number;
  };

  export interface MainMenu {
      ar: Menu[];
      en: Menu[];
  }
*/

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  public dir: string = 'ar';
  public mainMenu: MainMenu = {
    ar: [{ "name": "الشركات", "link": "#" },
    { "name": "الأسماء التجارية", "link": "my-names.html" },
    { "name": "طلباتي", "link": "#" },
    { "name": "المحفظة", "link": "/Wallet/Purchase", "counter": 3000 }],
    en: [{ "name": "compony", "link": "#" },
    { "name": "الأسماء التجارية", "link": "my-names.html" },
    { "name": "طلباتي", "link": "#" },
    { "name": "المحفظة", "link": "/Wallet/Purchase", "counter": 3000 }]
  };

  constructor(
    private elementRef: ElementRef,
    private _ngZone: NgZone
  ) { }

  switchLanguage() {
    const header = this.elementRef.nativeElement.querySelector('header-component');
    header.addEventListener('langValueChange', (event) => {
      this._ngZone.run(() => this.dir = event['detail'].lang);
    });
  }

  ngAfterViewInit() {
    this.switchLanguage();
  }
}
<!-- inside app.component.html render menu and current language -->
<div [ngClass]="dir === 'ar' ? 'rtl' : 'ltr'">
  <header-component backgroundColor="#0d8a86" [mainMenu]="mainMenu[dir]"
    userDetails='{"shortName": "علي الغامدي", "hasDetails": false}' logo='' logoLink='#' slogan='' sloganLink='#'
    projectName='الاسماء التجارية' languages='["EN", "AR"]' isSinglePage="false" currentLang="ar">
  </header-component>

  <router-outlet></router-outlet>
</div>

Contributing

License

THIQAH Frontend Team KSA