Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
feat(demo-app): Completely rewritten demo-app.
Browse files Browse the repository at this point in the history
  • Loading branch information
trimox committed Jun 2, 2017
1 parent 810ef9f commit e700e0b
Show file tree
Hide file tree
Showing 22 changed files with 1,264 additions and 169 deletions.
32 changes: 24 additions & 8 deletions src/demo-app/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@
import { RouterModule, Routes } from '@angular/router';

import { HomeComponent } from './components/home/home.component';
import { ButtonDemoComponent } from './components/button-demo/button-demo.component';
import { CheckboxDemoComponent } from './components/checkbox-demo/checkbox-demo.component';
import { FabDemoComponent } from './components/fab-demo/fab-demo.component';
import { SwitchDemoComponent } from './components/switch-demo/switch-demo.component';
import { SnackbarDemoComponent } from './components/snackbar-demo/snackbar-demo.component';
import { MenuDemoComponent } from './components/menu-demo/menu-demo.component';
import { TextfieldDemoComponent } from './components/textfield-demo/textfield-demo.component';
import { ToolbarDemoComponent } from './components/toolbar-demo/toolbar-demo.component';

export const appRoutes: Routes = [
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: '**', redirectTo: '' }
{ path: 'button-demo', component: ButtonDemoComponent },
{ path: 'checkbox-demo', component: CheckboxDemoComponent },
{ path: 'fab-demo', component: FabDemoComponent },
{ path: 'switch-demo', component: SwitchDemoComponent },
{ path: 'snackbar-demo', component: SnackbarDemoComponent },
{ path: 'menu-demo', component: MenuDemoComponent },
{ path: 'textfield-demo', component: TextfieldDemoComponent },
{ path: 'toolbar-demo', component: ToolbarDemoComponent },
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: '**', redirectTo: '' }
];

@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
],
exports: [
RouterModule
]
imports: [
RouterModule.forRoot(appRoutes, { useHash: true })
],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
25 changes: 22 additions & 3 deletions src/demo-app/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,45 @@ import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import { NavbarComponent } from './components/navigation/navbar.component';
import { ButtonDemoComponent } from './components/button-demo/button-demo.component';
import { CheckboxDemoComponent } from './components/checkbox-demo/checkbox-demo.component';
import { FabDemoComponent } from './components/fab-demo/fab-demo.component';
import { SwitchDemoComponent } from './components/switch-demo/switch-demo.component';
import { SnackbarDemoComponent } from './components/snackbar-demo/snackbar-demo.component';
import { MenuDemoComponent } from './components/menu-demo/menu-demo.component';
import { TextfieldDemoComponent } from './components/textfield-demo/textfield-demo.component';
import { ToolbarDemoComponent } from './components/toolbar-demo/toolbar-demo.component';

import { MaterialModule } from './../../lib';
import { HomeComponent } from './components/home/home.component';
//import { FlexLayoutModule } from '@angular/flex-layout';
import { FlexLayoutModule } from '@angular/flex-layout';

import { AppRoutingModule } from './app-routing.module';

require('@material/typography/mdc-typography.scss');
require('@material/card/mdc-card.scss');

@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
// FlexLayoutModule,
FlexLayoutModule,
MaterialModule,
AppRoutingModule
],
declarations: [
AppComponent,
NavbarComponent,
HomeComponent
HomeComponent,
ButtonDemoComponent,
CheckboxDemoComponent,
FabDemoComponent,
SwitchDemoComponent,
SnackbarDemoComponent,
MenuDemoComponent,
TextfieldDemoComponent,
ToolbarDemoComponent
],
bootstrap: [AppComponent]
})
Expand Down
127 changes: 127 additions & 0 deletions src/demo-app/app/components/button-demo/button-demo.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<div fxLayout="column" class="mdc-padding">
<h1 class="mdc-typography--display1">Buttons</h1>
<p class="mdc-typography--body1">The MDC Button component is a spec-aligned button component adhering to the Material Design button requirements.</p>
<a href="https://github.com/material-components/material-components-web/tree/master/packages/mdc-button">Google's Material Components for the web documentation</a>
<h1 class="mdc-typography--headline">Usage</h1>
<div style="width: 400px;">
<pre class="prettyprint"><![CDATA[import { ButtonModule } from '@angular-mdc/web';]]></pre>
</div>
<div fxLayout="row">
<div fxLayout="column">
<h1 class="mdc-typography--headline">API reference</h1>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><pre class="prettyprint">@Input() type: string</pre></td>
<td>Input type of button (e.g. email, password, url).</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() dense: boolean</pre></td>
<td>Compresses the button text to make it slightly smaller.</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() raised: boolean</pre></td>
<td>Elevates the button and creates a colored background.</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() compact: boolean</pre></td>
<td>Reduces the amount of horizontal padding in the button.</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() primary: boolean</pre></td>
<td>Colors the button with the primary color.</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() accent: boolean</pre></td>
<td>Colors the button with the accent color.</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() disabled: string</pre></td>
<td>Disables the component.</td>
</tr>
</tbody>
</table>
</div>

<div fxLayout="column" fxFlexOffset="5">
<h1 class="mdc-typography--headline">Events</h1>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><pre class="prettyprint">@HostListener() keydown</pre></td>
<td>Show ripple on keyboard down event.</td>
</tr>
<tr>
<td><pre class="prettyprint">@HostListener() keyup</pre></td>
<td>Show ripple on keyboard up event.</td>
</tr>
</tbody>
</table>
</div>
</div>

<h1 class="mdc-typography--headline">Examples</h1>
<div fxLayout="column" fxLayoutAlign="start start">
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<button mdc-button [accent]="true">Button</button>
</div>
<p>Accent</p>
<pre class="prettyprint">&lt;button mdc-button [accent]="true"&gt;Accent&lt;/button&gt;</pre>
</div>
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<button mdc-button [raised]="true">Button</button>
</div>
<p>Raised</p>
<pre class="prettyprint">&lt;button mdc-button [raised]="true"&gt;Raised&lt;/button&gt;</pre>
</div>
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<button mdc-button [dense]="true" [raised]="true">Button</button>
</div>
<p>Dense and Raised</p>
<pre class="prettyprint">&lt;button mdc-button [dense]="true" [raised]="true"&gt;Dense and Raised&lt;/button&gt;</pre>
</div>
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<button mdc-button [compact]="true" [raised]="true">Button</button>
</div>
<p>Compact and Raised</p>
<pre class="prettyprint">&lt;button mdc-button [compact]="true" [raised]="true"&gt;Compact and Raised&lt;/button&gt;</pre>
</div>
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<button mdc-button [accent]="true" [raised]="true">Button</button>
</div>
<p>Accent and Raised</p>
<pre class="prettyprint">&lt;button mdc-button [accent]="true" [raised]="true"&gt;Accent and Raised&lt;/button&gt;</pre>
</div>
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<button mdc-button [primary]="true" [raised]="true">Button</button>
</div>
<p>Primary and Raised</p>
<pre class="prettyprint">&lt;button mdc-button [primary]="true" [raised]="true"&gt;Primary and Raised&lt;/button&gt;</pre>
</div>
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<button mdc-button [primary]="true" [raised]="true" disabled>Button</button>
</div>
<p>Disabled</p>
<pre class="prettyprint">&lt;button mdc-button [primary]="true" [raised]="true" disabled&gt;Disabled&lt;/button&gt;</pre>
</div>
</div>
</div>
22 changes: 22 additions & 0 deletions src/demo-app/app/components/button-demo/button-demo.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {
Component,
OnInit,
ViewChild
} from '@angular/core';

@Component({
selector: 'button-demo',
templateUrl: './button-demo.component.html'
})
export class ButtonDemoComponent implements OnInit {

ngOnInit() {
let doc = <HTMLDivElement>document.body;
let script = document.createElement('script');
script.innerHTML = '';
script.src = 'https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=sunburst';
script.async = true;
script.defer = true;
doc.appendChild(script);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<div fxLayout="column" class="mdc-padding">
<h1 class="mdc-typography--display1">Checkbox</h1>
<p class="mdc-typography--body1">The MDC Checkbox component is a spec-aligned checkbox component adhering to the Material Design checkbox requirements.</p>
<a href="https://github.com/material-components/material-components-web/tree/master/packages/mdc-checkbox">Google's Material Components for the web documentation</a>
<h1 class="mdc-typography--headline">Usage</h1>
<div style="width: 400px;">
<pre class="prettyprint"><![CDATA[import { CheckboxModule } from '@angular-mdc/web';]]></pre>
</div>
<h1 class="mdc-typography--headline">Directives</h1>
<div style="width: 400px;">
<pre class="prettyprint"><![CDATA[@Directive({selector: '[mdc-checkbox-label]'})]]></pre>
</div>
<div fxLayout="row">
<div fxLayout="column">
<h1 class="mdc-typography--headline">API reference</h1>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><pre class="prettyprint">@Input() checked: boolean</pre></td>
<td>Boolean for verifying the checked value.</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() indeterminate: boolean</pre></td>
<td>To represent a checkbox with three states (e.g. a nested list of checkable items).</td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() labelId: string</pre></td>
<td></td>
</tr>
<tr>
<td><pre class="prettyprint">@Input() disabled: string</pre></td>
<td>Disables the component.</td>
</tr>
</tbody>
</table>
</div>

<div fxLayout="column" fxFlexOffset="5">
<h1 class="mdc-typography--headline">Events</h1>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><pre class="prettyprint">@Output() change</pre></td>
<td>Event dispatched on value change.</td>
</tr>
</tbody>
</table>
</div>
</div>

<h1 class="mdc-typography--headline">Examples</h1>
<div fxLayout="column" fxLayoutAlign="start start">
<div fxLayout="column" class="mdc-padding">
<div fxFlexAlign="start">
<mdc-form-field>
<mdc-checkbox [(ngModel)]="isChecked"></mdc-checkbox>
<label mdc-checkbox-label [id]="labelId">The checkbox is {{isChecked}}</label>
</mdc-form-field>
</div>
<pre class="prettyprint">
&lt;mdc-form-field&gt;
&lt;mdc-checkbox [(ngModel)]="isChecked"&gt;&lt;/mdc-checkbox&gt;
&lt;label mdc-checkbox-label [id]="labelId"&gt;Label text&lt;/label&gt;
&lt;/mdc-form-field&gt;
</pre>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
Component,
OnInit,
ViewChild
} from '@angular/core';

@Component({
selector: 'checkbox-demo',
templateUrl: './checkbox-demo.component.html'
})
export class CheckboxDemoComponent implements OnInit {
isChecked = false;

ngOnInit() {
let doc = <HTMLDivElement>document.body;
let script = document.createElement('script');
script.innerHTML = '';
script.src = 'https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=sunburst';
script.async = true;
script.defer = true;
doc.appendChild(script);
}
}
Loading

0 comments on commit e700e0b

Please sign in to comment.