Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-custom-dropdown

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-custom-dropdown - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

angular-custom-dropdown.d.ts

52

package.json

@@ -1,51 +0,1 @@

{
"name": "angular-custom-dropdown",
"description": "Angular2+ Dropdown, simple dropdowns without relying on CSS frameworks.",
"author": {
"name": "Gerard Rovira Sánchez",
"email": "zurfyx@gmail.com",
"url": "zurfyx.com"
},
"version": "1.0.1",
"main": "dist/index.js",
"scripts": {
"build": "typings install && ngc -p tsconfig-aot.json",
"install": "npm run build",
"test": ""
},
"repository": {
"type": "git",
"url": "git+https://github.com/zurfyx/angular-dropdown.git"
},
"keywords": [
"angular",
"angular2",
"angular4",
"typescript"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/zurfyx/angular-dropdown/issues"
},
"homepage": "https://github.com/zurfyx/angular-dropdown#readme",
"dependencies": {
"@angular/compiler-cli": "^4.1.0",
"@angular/core": "^4.1.0",
"@angular/platform-server": "^4.1.0",
"typings": "^1.0.4"
},
"devDependencies": {
"@angular/animations": "^4.1.0",
"@angular/common": "^4.1.0",
"@angular/compiler": "^4.1.0",
"@angular/platform-browser": "^4.1.0",
"@angular/platform-browser-dynamic": "^4.1.0",
"rxjs": "^5.1.0",
"tslint": "^4.3.1",
"typescript": "~2.1.0",
"zone.js": "0.8.4"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
}
}
{"name":"angular-custom-dropdown","description":"Angular2+ Dropdown. Simple dropdowns without relying on CSS frameworks.","author":{"name":"Gerard Rovira Sánchez","email":"zurfyx@gmail.com","url":"zurfyx.com"},"version":"1.1.0","license":"MIT","scripts":{"start":"ng serve","build":"ng-packagr -p ng-package.json","build-ghpages":"ng build --base-href \"https://zurfyx.github.io/angular-custom-dropdown/\" --output-path \"dist-ghpages\"","test":"npm run lint && ng test --watch false","test-watch":"ng test","e2e":"ng e2e","lint":"ng lint"},"repository":{"type":"git","url":"git+https://github.com/zurfyx/angular-custom-dropdown.git"},"bugs":{"url":"https://github.com/zurfyx/angular-custom-dropdown/issues"},"homepage":"https://github.com/zurfyx/angular-custom-dropdown#readme","keywords":["angular","dropdown","custom","simple","css"],"private":false,"dependencies":{},"devDependencies":{"@angular/animations":"^4.2.4","@angular/cli":"1.4.9","@angular/common":"^4.2.4","@angular/compiler":"^4.2.4","@angular/compiler-cli":"^4.2.4","@angular/core":"^4.2.4","@angular/forms":"^4.2.4","@angular/http":"^4.2.4","@angular/language-service":"^4.2.4","@angular/platform-browser":"^4.2.4","@angular/platform-browser-dynamic":"^4.2.4","@angular/router":"^4.2.4","@types/jasmine":"~2.5.53","@types/jasminewd2":"~2.0.2","@types/node":"~6.0.60","codelyzer":"~3.2.0","core-js":"^2.4.1","jasmine-core":"~2.6.2","jasmine-spec-reporter":"~4.1.0","karma":"~1.7.0","karma-chrome-launcher":"~2.1.1","karma-cli":"~1.0.1","karma-coverage-istanbul-reporter":"^1.2.1","karma-jasmine":"~1.1.0","karma-jasmine-html-reporter":"^0.2.2","ng-packagr":"^1.5.0-rc.1","protractor":"~5.1.2","rxjs":"^5.4.2","ts-node":"~3.2.0","tslint":"~5.7.0","typescript":"~2.3.3","zone.js":"^0.8.14"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"main":"bundles/angular-custom-dropdown.umd.js","module":"angular-custom-dropdown.es5.js","es2015":"angular-custom-dropdown.js","typings":"angular-custom-dropdown.d.ts","metadata":"angular-custom-dropdown.metadata.json"}
# Angular Custom Dropdown
[![npm Version](https://img.shields.io/npm/v/angular-custom-dropdown.svg)](https://www.npmjs.com/package/angular-custom-dropdown)
[![Build Status](https://travis-ci.org/zurfyx/angular-custom-dropdown.svg?branch=master)](https://travis-ci.org/zurfyx/angular-custom-dropdown)
> Create simple Angular2+ dropdowns without relying on CSS frameworks.
## Demo
https://zurfyx.github.io/angular-custom-dropdown
## Features
- Light and simple
- No CSS framework tied
- Compatible with [Bootstrap](https://getbootstrap.com/docs/4.0/components/dropdowns/)
## Install

@@ -11,10 +24,6 @@

## Result
## Getting started
![Dropdown result](/assets/result.png)
[my-module.module.ts](https://github.com/zurfyx/angular-custom-modal/blob/master/example/app/app.module.ts)
## Usage
my-module.module.ts
```

@@ -30,31 +39,134 @@ import { DropdownModule } from 'angular-custom-dropdown';

my-module.component.ts
[my-module.component.ts](https://github.com/zurfyx/angular-custom-modal/blob/master/example/app/app.component.ts)
[my-module.component.html](https://github.com/zurfyx/angular-custom-modal/blob/master/example/app/app.component.html)
```
<a class="dropdown" dropdown>
<span>Click me to reveal dropdown</span>
<ul class="dropdown-menu">
<li><a [routerLink]="['...']">Profile</a></li>
<li><a [routerLink]="['...']">Log out</a></li>
<div class="dropdown" dropdown>
<h1 class="dropdown-toggle" dropdownToggle>Angular Custom Dropdown ▼</h1>
<ul class="dropdown-menu" dropdownMenu>
<li><a class="neat" href="https://github.com/zurfyx/angular-custom-modal" rel="noopener" target="_blank">Check it out @ GitHub</a></li>
<li><a class="neat" href="#">...</a></li>
</ul>
</a>
</div>
```
my-module.component.css
[my-module.component.css](https://github.com/zurfyx/angular-custom-modal/blob/master/example/app/app.component.scss) [Optional]
Styles are optional and up to you. Below are the ones that the demo page uses, but you can also use Bootstrap styles for that, or any other compatible library or framework. For most cases you'll just need to adapt the class names of the HTML snippet above.
```
/* Show dropdown on click (active class set). */
.dropdown.active > .dropdown-menu {
display: initial;
.dropdown {
position: relative;
}
/* Hide dropdown by default */
ul.dropdown-menu {
display: none;
.dropdown-menu {
position: absolute;
display: block;
align-self: center;
width: 80%;
opacity: 0;
margin: -.25rem 0 0 10%; // -.25rem top (animation).
padding: 0.25rem;
list-style-type: none;
background-color: #fff;
border-radius: 4px;
transition: .2s all ease-in;
}
.dropdown-menu li {
padding: .5rem .5rem;
}
.dropdown-menu li + li {
border-top: 1px solid #e1e1e1;
padding-top: .5rem;
}
.dropdown-menu li > a {
display: block;
border-radius: 4px;
padding: 1rem 1.5rem;
transition: .2s background-color ease-in;
}
.dropdown-menu li > a:hover {
background-color: #e9e9e9;
}
.dropdown.open .dropdown-menu {
opacity: 1;
margin-top: 0;
}
a.neat {
color: inherit;
text-decoration: none;
}
```
## Advanced
All directives are exported using the same selector names, which allows you to access inner methods on your own templates or components.
### Accessing the dropdown reference in your own template
```
<span (click)="myDropdown.toggle()">While the toggle element is outside the dropdown, it has a reference to dropdown.</span>
<div #myDropdown=dropdown dropdown>
...
</div>
```
### Accessing the dropdown reference in your own component
All the examples below require the HTML to have a reference such as the following:
```
<div #myDropdown=dropdown dropdown>...</div>
```
Toggle dropdown:
```
import { DropdownDirective } from 'angular-custom-dropdown';
...
@ViewChild('myDropdown') myDropdown: DropdownDirective;
openNow() {
this.myDropdown.open();
}
```
Subscribing to [dropdown status changes](https://github.com/zurfyx/angular-custom-modal/blob/master/example/app/app.component.ts):
```
import { DropdownDirective, TOGGLE_STATUS } from 'angular-custom-dropdown';
...
@ViewChild('myDropdown') myDropdown: DropdownDirective;
ngOnInit() {
this.myDropdown.statusChange()
.subscribe((status: TOGGLE_STATUS) => {
let statusValue: String;
if (status === TOGGLE_STATUS.OPEN) {
statusValue = 'Opened';
} else if (status === TOGGLE_STATUS.CLOSE) {
statusValue = 'Closed';
}
console.info(`Dropdown status changed to "${statusValue}".`);
});
}
```
Warning! This example has been shortened for the sake of readability. Subscriptions should always be cleaned up on destroy (see the full source code [here](https://github.com/zurfyx/angular-custom-modal/blob/master/example/app/app.component.ts)).
## Special thanks
To [pleerock](https://github.com/pleerock) for [ngx-dropdown](https://github.com/pleerock/ngx-dropdown), of which I took some design ideas.
## License
MIT © [Gerard Rovira Sánchez](//zurfyx.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc