Skip to content

Commit

Permalink
feat(popup): Added isFlowing and isInline properties (edcarroll#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalhakim authored and edcarroll committed Aug 23, 2018
1 parent 0a4045e commit 5056e03
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
12 changes: 12 additions & 0 deletions demo/src/app/pages/modules/popup/popup.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ export class PopupPage {
description: "When <code>true</code> the popup's arrow is hidden.",
defaultValue: "false"
},
{
name: "popupFlowing",
type: "boolean",
description: "When <code>true</code> have no maximum width and continue to flow to fit its content.",
defaultValue: "false"
},
{
name: "popupInline",
type: "boolean",
description: "When <code>true</code> popup will be appended as a sibling of the popup trigger element.",
defaultValue: "false"
},
{
name: "popupTransition",
type: "string",
Expand Down
7 changes: 6 additions & 1 deletion src/modules/popup/classes/popup-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface IPopupConfig {
isBasic?:boolean;
transition?:string;
transitionDuration?:number;
isFlowing?:boolean;
isInline?:boolean;
}

export class PopupConfig implements IPopupConfig {
Expand All @@ -34,6 +36,8 @@ export class PopupConfig implements IPopupConfig {
public isBasic:boolean;
public transition:string;
public transitionDuration:number;
public isFlowing:boolean;
public isInline:boolean;

constructor(defaults:IPopupConfig = {}) {
this.placement = PositioningPlacement.TopLeft;
Expand All @@ -43,7 +47,8 @@ export class PopupConfig implements IPopupConfig {
this.isBasic = false;
this.transition = "scale";
this.transitionDuration = 200;

this.isFlowing = false;
this.isInline = false;
Object.assign(this, defaults);
}
}
8 changes: 6 additions & 2 deletions src/modules/popup/classes/popup-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ export abstract class SuiPopupController implements IPopup, OnDestroy {
// Attach the generated component to the current application.
this._componentFactory.attachToApplication(this._componentRef);

// Move the generated element to the body to avoid any positioning issues.
this._componentFactory.moveToDocumentBody(this._componentRef);
if (this.popup.config.isInline) {
this._componentFactory.moveToElement(this._componentRef, this._element.nativeElement.parentElement);
} else {
// Move the generated element to the body to avoid any positioning issues.
this._componentFactory.moveToDocumentBody(this._componentRef);
}

// Attach a reference to the anchor element. We do it here because IE11 loves to complain.
this.popup.anchor = this._element;
Expand Down
3 changes: 3 additions & 0 deletions src/modules/popup/components/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export class SuiPopup implements IPopup {
if (this.config.isBasic) {
classes.basic = true;
}
if (this.config.isFlowing) {
classes.flowing = true;
}
return classes;
}

Expand Down
10 changes: 10 additions & 0 deletions src/modules/popup/directives/popup.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ export class SuiPopupDirective<T> extends SuiPopupTemplateController<T> {
this.popup.config.isBasic = Util.DOM.parseBooleanAttribute(basic);
}

@Input()
public set popupInline(inline:boolean) {
this.popup.config.isInline = Util.DOM.parseBooleanAttribute(inline);
}

@Input()
public set popupFlowing(flowing:boolean) {
this.popup.config.isFlowing = Util.DOM.parseBooleanAttribute(flowing);
}

@Input()
public set popupTransition(transition:string) {
this.popup.config.transition = transition;
Expand Down

0 comments on commit 5056e03

Please sign in to comment.