Skip to content

Commit

Permalink
refactor(): restructure components to loosen coupling, move overlay-p…
Browse files Browse the repository at this point in the history
…ortal, click-block, menu-controller and other app-level functionality to app directory. The motivation for this change is logical grouping, decoupling components from each other, and improving the ability to drop more unused components from bundle
  • Loading branch information
danbucholtz authored Apr 21, 2017
1 parent 83509db commit 59eb9a3
Show file tree
Hide file tree
Showing 92 changed files with 475 additions and 1,650 deletions.
34 changes: 0 additions & 34 deletions src/components/action-sheet/action-sheet.module.ts

This file was deleted.

34 changes: 0 additions & 34 deletions src/components/alert/alert.module.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/app/app-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { App } from './app';
import { assert } from '../../util/util';
import { Config } from '../../config/config';
import { Ion } from '../ion';
import { OverlayPortal } from '../nav/overlay-portal';
import { OverlayPortal } from './overlay-portal';
import { Platform } from '../../platform/platform';
import * as Constants from './app-constants';

Expand Down Expand Up @@ -42,7 +42,7 @@ export class IonicApp extends Ion implements OnInit {
private _plt: Platform,
app: App
) {
super(config, elementRef, renderer);
super(config, elementRef, renderer, 'app-root');
// register with App that this is Ionic's appRoot component. tada!
app._appRoot = this;
this._stopScrollPlugin = (<any>window)['IonicStopScroll'];
Expand Down
28 changes: 0 additions & 28 deletions src/components/app/app.module.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Title, DOCUMENT } from '@angular/platform-browser';

import { IonicApp } from './app-root';
import * as Constants from './app-constants';
import { ClickBlock } from '../click-block/click-block';
import { ClickBlock } from './click-block';
import { runInDev } from '../../util/util';
import { Config } from '../../config/config';
import { isNav, NavOptions, DIRECTION_FORWARD, DIRECTION_BACK } from '../../navigation/nav-util';
import { MenuController } from '../menu/menu-controller';
import { MenuController } from './menu-controller';
import { NavController } from '../../navigation/nav-controller';
import { Platform } from '../../platform/platform';
import { ViewController } from '../../navigation/view-controller';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Menu } from './menu';
import { MenuType } from './menu-types';
import { Menu, MenuType } from './menu-interface';
import { Platform } from '../../platform/platform';
import { removeArrayItem, assert } from '../../util/util';

Expand Down Expand Up @@ -343,3 +342,5 @@ export class MenuController {
}

let menuTypes: { [name: string]: new(...args: any[]) => MenuType } = {};


31 changes: 31 additions & 0 deletions src/components/app/menu-interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Animation } from '../../animations/animation';

export interface Menu {
setOpen(shouldOpen: boolean, animated: boolean): Promise<boolean>;
open(): Promise<boolean>;
close(): Promise<boolean>;
toggle(): Promise<boolean>;
enable(shouldEnable: boolean, menuId?: string): Menu;
swipeEnable(shouldEnable: boolean): Menu;
isOpen: boolean;
enabled: boolean;
side: string;
id: string;
isAnimating(): boolean;
width(): number;
getContentElement(): HTMLElement;
getMenuElement(): HTMLElement;
getBackdropElement(): HTMLElement;
_canOpen(): boolean;
persistent: boolean;
};

export interface MenuType {
ani: Animation;
isOpening: boolean;
setOpen(shouldOpen: boolean, animated: boolean, done: Function): void;
setProgressStart(isOpen: boolean): void;
setProgessStep(stepValue: number): void;
setProgressEnd(shouldComplete: boolean, currentStepValue: number, velocity: number, done: Function): void;
destroy(): void;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFactoryResolver, Directive, ElementRef, ErrorHandler, forwardRef, Inject, Input, NgZone, Optional, Renderer, ViewContainerRef } from '@angular/core';

import { App } from '../app/app';
import { App } from './app';
import { Config } from '../../config/config';
import { DeepLinker } from '../../navigation/deep-linker';
import { DomController } from '../../platform/dom-controller';
Expand Down Expand Up @@ -55,4 +55,3 @@ export class OverlayPortal extends NavControllerBase {
}

}

4 changes: 2 additions & 2 deletions src/components/app/test/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { App } from '../app';
import { ClickBlock } from '../../click-block/click-block';
import { ClickBlock } from '../click-block';
import { Config } from '../../../config/config';
import { mockApp, mockConfig, mockElementRef, mockNavController, mockPlatform, MockPlatform, mockRenderer, mockTab, mockTabs, mockView, mockViews } from '../../../util/mock-providers';
import { OverlayPortal } from '../../nav/overlay-portal';
import { OverlayPortal } from '../overlay-portal';
import { PORTAL_MODAL } from '../app-constants';


Expand Down
20 changes: 0 additions & 20 deletions src/components/avatar/avatar.module.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/components/avatar/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ import { Directive } from '@angular/core';
selector: 'ion-avatar'
})
export class Avatar {

constructor() {
}
}
20 changes: 0 additions & 20 deletions src/components/backdrop/backdrop.module.ts

This file was deleted.

7 changes: 2 additions & 5 deletions src/components/backdrop/backdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import { Directive, ElementRef, Renderer } from '@angular/core';
},
})
export class Backdrop {

constructor(
private _elementRef: ElementRef,
private _renderer: Renderer
) { }
constructor(private _elementRef: ElementRef, private _renderer: Renderer) {
}

getNativeElement(): HTMLElement {
return this._elementRef.nativeElement;
Expand Down
20 changes: 0 additions & 20 deletions src/components/badge/badge.module.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ export class Badge extends Ion {
constructor(config: Config, elementRef: ElementRef, renderer: Renderer) {
super(config, elementRef, renderer, 'badge');
}

}
20 changes: 0 additions & 20 deletions src/components/button/button.module.ts

This file was deleted.

29 changes: 0 additions & 29 deletions src/components/card/card.module.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/components/checkbox/checkbox.module.ts

This file was deleted.

10 changes: 2 additions & 8 deletions src/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, forwardRef, HostListener, Input, OnDestroy, Optional, Renderer, ViewEncapsulation } from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, HostListener, Input, OnDestroy, Optional, Renderer, ViewEncapsulation } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';

import { Config } from '../../config/config';
Expand All @@ -7,12 +7,6 @@ import { Form, IonicTapInput } from '../../util/form';
import { BaseInput } from '../../util/base-input';
import { Item } from '../item/item';

export const CHECKBOX_VALUE_ACCESSOR: any = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => Checkbox),
multi: true
};

/**
* @name Checkbox
* @module ionic
Expand Down Expand Up @@ -69,7 +63,7 @@ export const CHECKBOX_VALUE_ACCESSOR: any = {
host: {
'[class.checkbox-disabled]': '_disabled'
},
providers: [CHECKBOX_VALUE_ACCESSOR],
providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: Checkbox, multi: true } ],
encapsulation: ViewEncapsulation.None,
})
export class Checkbox extends BaseInput<boolean> implements IonicTapInput, AfterViewInit, OnDestroy {
Expand Down
Loading

0 comments on commit 59eb9a3

Please sign in to comment.