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

@finlexlabs/sidebar

v0.0.8

Published

Library Name: finlex-sidebar Package Name: @finlexlabs/sidebar Repo Name: fx-ng-components

Downloads

9

Readme

FinlexSidebar (@finlexlabs/sidebar)

Library Name: finlex-sidebar Package Name: @finlexlabs/sidebar Repo Name: fx-ng-components


Steps to Build & Publish Library

Package Renaming

Go to ./src/finlex-sidebar/package.json Rename package name from finlex-sidebar to @finlexlabs/sidebar

Build

npm run build:sidebar

It will build finlex-sidebar using ng-packagr. The build artifacts will be stored in the dist/ directory.

Publishing

After building your library with ng build:sidebar, go to the dist folder cd dist/finlex-sidebar and run npm publish.

Finlex Sidebar


Background knowledge:

  1. Read here an intro to Angular Entry components
  2. Read here an intro to Dynamic component loader
  • Finlex Sidebar is a dynamic component that loads another component inside it dynamically at run time.

(TL;DR) Simple example to use Finlex Sidebar:

module.ts

import { FinlexSidebarModule } from '@finlexlabs/sidebar';

@NgModule({
	imports: [
		FinlexSidebarModule
	]
)

export class ProductsModule { }

view.ts

  import { SidebarService } from '@finlexlabs/sidebar';


  constructor(public sidebarService: SidebarService) { }
  const sub = this.sidebarService
      .open(ExampleComponent,  // THIS COULD BE ANY COMPONENT
     {
        resolver: null,
        headline: this.translate.instant('HEADLINE'),
        bindings: { data: data }
      })


Finlex Sidebar Component

  1. Finlex Sidebar Component is an entry component that will be instantiated dynamically and it will also inject and load provided component inside its body.

  2. Explanation of each type property value and other properties of SidebarService will follow below.

FinlexSidebarComponent properties:

Properties

  • componentHolder (type: ComponentHolderDirective) -> It will hold the reference where dynamic component will be inserted.
  • childComponentType (type: Type) -> It will hold type of component that has to create.
  • componentRef (type: ComponentRef) -> it will hold a reference to the instance of the sidebar component that we will create.
  • opened (type: boolean) -> It will hold the state of the sidebar either is open or not
  • headline (type: string) -> heading of the sidebar
  • ANIMATION_TIMEOUT (type: number) -> animation timeout

Functions

  • close: (params: none) -> used to close the sidebar.
  • loadChildComponent: (params: none) -> This method takes the type of the child-component as a parameter. We then use this type to resolve the factory for this component. With the help of the factory and the componentHolder, we then instantiate the dynamic child-component.

SidebarService class

  1. This class is an injectable service used to open and close sidebar.

  2. Explanation of each type property value and other properties of SidebarService will follow below.

SidebarService properties:

Properties

  • sidebarComponentRef (type: ComponentRef) -> The will hold the refrence to the dynamically generated component.

Functions

  • open: (params: Type, SidebarConfig) -> used to open sidebar with a child-component to be loaded and an optional config object. The open method will return an instance of SidebarRef.
  • close: (params: none) -> used to close side bar.
  • appendSidebarComponentToBody: (params: SidebarConfig) -> This function will dynamically generate sidebar component, inject provided component into sidebar component and will attatch them to body. This method will return an instance of SidebarRef.
  • removeSidebarComponentFromBody: (params: none) -> This function will remove sidebar component from body.