Skip to content

Commit

Permalink
feat(Popover): Popover component
Browse files Browse the repository at this point in the history
  • Loading branch information
atlwendy authored and benjamincharity committed Dec 16, 2019
1 parent d6af038 commit baf8e64
Show file tree
Hide file tree
Showing 27 changed files with 1,261 additions and 3 deletions.
1 change: 1 addition & 0 deletions ACKNOWLEDGMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ more on the communities needs.
- https://github.com/prestopasto/SCSS-Material-Shadows
- https://github.com/fknop/angular-pipes
- https://github.com/zefoy/ngx-perfect-scrollbar
- https://github.com/popperjs/popper.js


## Icons
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The library of UI components used for Terminus applications.
[![Github release][gh-release-badge]][gh-releases]
[![Library size][file-size-badge]][raw-distribution-js]
<br>
[![components](https://img.shields.io/badge/Components-38-%2316a085.svg)](#components)
[![components](https://img.shields.io/badge/Components-39-%2316a085.svg)](#components)
[![pipes](https://img.shields.io/badge/Pipes-6-%2316a085.svg)](#pipes)
[![services](https://img.shields.io/badge/Services-1-%2316a085.svg)](#services)
[![style helpers](https://img.shields.io/badge/StyleHelpers-14-%2316a085.svg)](#style-helpers)
Expand Down Expand Up @@ -123,6 +123,7 @@ for each feature.
| [navigation][src-navigation] | Global navigation menu | :white_check_mark: | [Demo][demo-navigation] | [Docs][navigation-docs] | [Usage][navigation-usage] |
| [paginator][src-paginator] | Paging controls for collections | :white_check_mark: | [Demo][demo-paginator] | [Docs][paginator-docs] | [Usage][paginator-usage] |
| [pipes][src-pipes] | A collection of pipes for Angular | :white_check_mark: | [Demo][demo-pipes] | [Docs][pipes-docs] | |
| [popover][src-popover] | Popover | :white_check_mark: | [Demo][demo-popover] | [Docs][popover-docs] | [Usage][popover-usage] |
| progress | | | | | |
| [radio-group][src-radio-group] | | :white_check_mark: | [Demo][demo-radio-group] | [Docs][radio-group-docs] | [Usage][radio-group-usage] |
| [scrollbars][src-scrollbars] | Custom scrollars for both axis' | :white_check_mark: | [Demo][demo-scrollbars] | [Docs][scrollbars-docs] | [Usage][scrollbars-usage] |
Expand Down Expand Up @@ -381,6 +382,7 @@ This project follows the [all-contributors](https://github.com/kentcdodds/all-co
[demo-navigation]: https://getterminus.github.io/ui-demos-release/components/navigation
[demo-paginator]: https://getterminus.github.io/ui-demos-release/components/paginator
[demo-pipes]: https://getterminus.github.io/ui-demos-release/components/pipes
[demo-popover]: https://getterminus.github.io/ui-demos-release/components/popover
[demo-radio-group]: https://getterminus.github.io/ui-demos-release/components/radio
[demo-scrollbars]: https://getterminus.github.io/ui-demos-release/components/scrollbars
[demo-search]: https://getterminus.github.io/ui-demos-release/components/search
Expand Down Expand Up @@ -437,6 +439,7 @@ This project follows the [all-contributors](https://github.com/kentcdodds/all-co
[src-pipes-titleCase]: https://github.com/GetTerminus/terminus-ui/blob/release/terminus-ui/pipes/src/title-case/title-case.pipe.ts
[src-pipes-truncate]: https://github.com/GetTerminus/terminus-ui/blob/release/terminus-ui/pipes/src/truncate/truncate.pipe.ts
[src-pipes]: https://github.com/GetTerminus/terminus-ui/blob/release/terminus-ui/pipes/src/
[src-popover]: https://github.com/Getterminus/terminus-ui/blob/release/terminus-ui/popover/src/
[src-radio-group]: https://github.com/GetTerminus/terminus-ui/blob/release/terminus-ui/radio-group/src/
[src-scrollbars]: https://github.com/GetTerminus/terminus-ui/blob/release/terminus-ui/scrollbars/src/
[src-search]: https://github.com/GetTerminus/terminus-ui/blob/release/terminus-ui/search/src/
Expand Down Expand Up @@ -478,6 +481,7 @@ This project follows the [all-contributors](https://github.com/kentcdodds/all-co
[navigation-docs]: http://uilibrary-docs.terminus.ninja/release/components/TsNavigationComponent.html
[paginator-docs]: http://uilibrary-docs.terminus.ninja/release/components/TsPaginatorComponent.html
[pipes-docs]: http://uilibrary-docs.terminus.ninja/release/modules/TsPipesModule.html
[popover-docs]: http://uilibrary-docs.terminus.ninja/release/modules/TsPopoverComponent.html
[radio-group-docs]: http://uilibrary-docs.terminus.ninja/release/components/TsRadioGroupComponent.html
[scrollbars-docs]: http://uilibrary-docs.terminus.ninja/release/components/TsScrollbarsComponent.html
[search-docs]: http://uilibrary-docs.terminus.ninja/release/components/TsSearchComponent.html
Expand Down Expand Up @@ -526,6 +530,7 @@ This project follows the [all-contributors](https://github.com/kentcdodds/all-co
[menu-usage]: http://uilibrary-docs.terminus.ninja/release/components/TsMenuComponent.html#readme
[paginator-usage]: http://uilibrary-docs.terminus.ninja/release/components/TsPaginatorComponent.html#readme
[navigation-usage]: http://uilibrary-docs.terminus.ninja/release/components/TsNavigationComponent.html#readme
[popover-usage]: http://uilibrary-docs.terminus.ninja/release/components/TsPopoverComponent.html#readme
[radio-group-usage]: http://uilibrary-docs.terminus.ninja/release/components/TsRadioGroupComponent.html#readme
[scrollbars-usage]: http://uilibrary-docs.terminus.ninja/release/directives/TsScrollbarsComponent.html#readme
[select-usage]: http://uilibrary-docs.terminus.ninja/release/directives/TsSelectComponent.html#readme
Expand Down
7 changes: 7 additions & 0 deletions demo/app/components/components.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ export const componentsList: Routes = [
name: 'Pipes',
},
},
{
path: 'popover',
loadChildren: `./components/popover/popover.module#PopoverModule`,
data: {
name: 'Popover',
}
},
{
path: 'radio',
loadChildren: `./components/radio/radio.module#RadioModule`,
Expand Down
18 changes: 18 additions & 0 deletions demo/app/components/popover/popover-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { PopoverComponent } from './popover.component';


const routes: Routes = [
{
path: '',
component: PopoverComponent,
},
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class PopoverRoutingModule { }
26 changes: 26 additions & 0 deletions demo/app/components/popover/popover.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div style="max-width: 200px; height: 600px;" class="demo-popover">
<select
[(ngModel)]="example1select"
(change)="change()"
>
<option value="top">Top</option>
<option value="right">Right</option>
<option value="bottom">Bottom</option>
<option value="left">Left</option>
</select>
<button
tsPopoverTrigger="popper1"
[position]="example1select"
[popover]="popper1"
[defaultOpened]="false"
style="margin: 200px 250px;"
[id]="myId"
(popoverOnShown)="popoverOnShown($event)"
(popoverOnHidden)="popoverOnHidden($event)"
>Click me!</button>
</div>

<ts-popover #popper1>
<h1>My Title</h1>
<p>Other random content.</p>
</ts-popover>
36 changes: 36 additions & 0 deletions demo/app/components/popover/popover.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
Component,
ElementRef,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import {
TsPopoverComponent,
TsPopoverPosition,
} from '@terminus/ui/popover';

@Component({
selector: 'demo-popover',
templateUrl: './popover.component.html',
})
export class PopoverComponent {
public myform = new FormControl('bottom');
public positions = ['bottom', 'top', 'left', 'right'];
public myId = 'custom-id';
example1select: TsPopoverPosition = 'right';
public popoverOnShown(event) {
console.log('popper on shown emitted event: ', event);
}
public popoverOnHidden(event) {
console.log('popover on hidden emitted event: ', event);
}

constructor(private elem: ElementRef) {
}

public change() {
setTimeout(() => {
this.elem.nativeElement.querySelector('.ts-popover-trigger').dispatchEvent(new Event('click'));
}, 100);

}
}
29 changes: 29 additions & 0 deletions demo/app/components/popover/popover.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import {
FormsModule,
ReactiveFormsModule,
} from '@angular/forms';
import { TsOptionModule } from '@terminus/ui/option';
import { TsPopoverModule } from '@terminus/ui/popover';
import { TsSelectionListModule } from '@terminus/ui/selection-list';

import { PopoverRoutingModule } from './popover-routing.module';
import { PopoverComponent } from './popover.component';


@NgModule({
imports: [
CommonModule,
FormsModule,
PopoverRoutingModule,
ReactiveFormsModule,
TsPopoverModule,
TsSelectionListModule,
TsOptionModule,
],
declarations: [
PopoverComponent,
],
})
export class PopoverModule {}
2 changes: 1 addition & 1 deletion jest.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
],
transform: {'^.+\\.(ts|js|html)$': 'ts-jest'},
transformIgnorePatterns: [
'node_modules/(?!@ngrx)',
'<rootDir>/node_modules/(?!@ngrx|popper)',
],
};

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
"@terminus/ui": "15.4.0",
"date-fns": "2.8.1",
"ngx-perfect-scrollbar": "8.0.0",
"popper.js": "1.16.0",
"text-mask-addons": "3.8.0",
"text-mask-core": "5.1.2"
},
Expand Down
15 changes: 15 additions & 0 deletions terminus-ui/popover/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ngPackage": {
"lib": {
"entryFile": "src/public-api.ts",
"umdModuleIds": {
"@terminus/ngx-tools": "terminus.ngxTools",
"@terminus/ngx-tools/browser": "terminus.ngxTools.browser",
"@terminus/ngx-tools/type-guards": "terminus.ngxTools.type-guards",
"@terminus/ngx-tools/utilities": "terminus.ngxTools.utilities",
"popper.js/dist/esm/popper.js": "Popper"
}
}
}
}

89 changes: 89 additions & 0 deletions terminus-ui/popover/src/popover-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Define positions that popover accepts
*/
export type TsPopoverPosition
=
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'top-start'
| 'bottom-start'
| 'left-start'
| 'right-start'
| 'top-end'
| 'bottom-end'
| 'left-end'
| 'right-end'
| 'auto'
| 'auto-start'
| 'auto-end'
;

/**
* List of accepted positions
*/
export const tsPopoverPositions = [
'top',
'bottom',
'left',
'right',
'top-start',
'bottom-start',
'right-start',
'top-end',
'bottom-end',
'left-end',
'right-end',
'top-end',
'bottom-end',
'left-end',
'right-end',
'auto',
'auto-start',
'auto-end',
];

/**
* A class of defined positions.
*/
export class TsPopoverPositions {
public static Top: TsPopoverPosition = 'top';
public static Bottom: TsPopoverPosition = 'bottom';
public static Left: TsPopoverPosition = 'left';
public static Right: TsPopoverPosition = 'right';
public static TopStart: TsPopoverPosition = 'top-start';
public static BottomStart: TsPopoverPosition = 'bottom-start';
public static LeftStart: TsPopoverPosition = 'left-start';
public static RightStart: TsPopoverPosition = 'right-start';
public static TopEnd: TsPopoverPosition = 'top-end';
public static BottomEnd: TsPopoverPosition = 'bottom-end';
public static LeftEnd: TsPopoverPosition = 'left-end';
public static RightEnd: TsPopoverPosition = 'right-end';
public static Auto: TsPopoverPosition = 'auto';
public static AutoStart: TsPopoverPosition = 'auto-start';
public static AutoEnd: TsPopoverPosition = 'auto-end';
}

/**
* Define Trigger type.
*/
export type TsTrigger = 'click';

/**
* A class of Triggers.
*/
export class TsTriggers {
public static CLICK: TsTrigger = 'click';
}

/**
* Our defined option interface.
*/
export interface TsPopoverOptions {
ariaRole?: string;
trigger?: TsTrigger;
placement?: TsPopoverPosition;
popperModifiers?: {};
styles?: Object;
}
Loading

0 comments on commit baf8e64

Please sign in to comment.