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

angular-dropdown

v0.5.5

Published

Simple angular dropdown component.

Downloads

358

Readme

Angular Dropdown

A simple angular dropdown component

Installation

$ yarn add angular-dropdown ng-wormhole

Import AngularDropdownModule in your app:

import { NgModule } from '@angular/core';
import { AngularDropdownModule } from 'angular-dropdown';

@NgModule({
  imports: [AngularDropdownModule]
})
export class AppModule {}

In your SASS stylesheet:

@import '~angular-dropdown/styles';

Example usage

<div ngDropdown>
  <button ngDropdownControl>Open Dropdown!</button>
  <div ngDropdownContent dropdownClass="slide-fade">
    <ul>
      <li><a href="#">Dropdown Item 1</a></li>
      <li><a href="#">Dropdown Item 2</a></li>
      <li><a href="#">Dropdown Item 3</a></li>
      <li><a href="#">Dropdown Item 4</a></li>
    </ul>
  </div>
</div>

ngDropdown

Inputs

renderInPlace: boolean = false Should the component render its children in place?

<div ngDropdown [renderInPlace]="true">
  <button ngDropdownControl>Open Dropdown!</button>
  <div ngDropdownContent>
    ...
  </div>
</div>

calculatePosition: (trigger: Element, dropdown: Element, options: any) => any Overwrite the default calculatePosition function

calculateInPlacePosition: (trigger: Element, dropdown: Element, options: any) => any Overwrite the default calculatePosition function used when dropdown is rendered in-place.

disabled: boolean = false Disable the dropdown

beforeOpen: () => boolean = null Hook before the dropdown is opened, return false to cancel it.

beforeClose: () => boolean = null Hook before the dropdown is closed, return false to cancel it.

verticalPosition: 'auto' | 'above' | 'below' Vertical positioning

horizontalPosition: 'auto' | 'right' | 'center' | 'left' Horizontal positioning

Outputs

open: void Triggers when opening the dropdown

<div ngDropdown (open)="doSomething()">
  <button ngDropdownControl>Open Dropdown!</button>
  <div ngDropdownContent>
    ...
  </div>
</div>

close: void Triggers when closing the dropdown

<div ngDropdown (close)="doSomething()">
  <button ngDropdownControl>Open Dropdown!</button>
  <div ngDropdownContent>
    ...
  </div>
</div>

Programatically open/close

<div ngDropdown #dropdown="ngDropdown">
  <button (click)="ngDropdown.open()">Open Dropdown!</button>
  <button (click)="ngDropdown.close()">Close Dropdown!</button>

  <div ngDropdownContent>
    ...
  </div>
</div>

ngDropdownContent

Inputs

dropdownClass: string Class to apply on the dropdown element, classes with animations will be properly animated.

transitioningInClass: string = 'ng-dropdown-content--transitioning-in' Class which will be applied when the dropdown element is inserted into the DOM.

transitionedInClass: string = 'ng-dropdown-content--transitioned-in' Class which will be applied once the transitioningInClass animation finished.

transitioningOutClass: string = 'ng-dropdown-content--transitioning-out' Class which will be applied when closing the dropdown.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

Credits

This component is heavily inspired by ember-basic-dropdown. Contributions from @cibernox, @locks and others.