Skip to content

Commit

Permalink
feat(docs): added basic Modal example
Browse files Browse the repository at this point in the history
  • Loading branch information
pimenovoleg committed Dec 2, 2019
1 parent 42f8a4f commit 0db75d1
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ const DOCS: { [key: string]: DocCategory[] } = {
}
]
},
{
id: 'modals',
name: 'Popups & Modals',
summary: '',
items: [
{
id: 'modal',
name: 'Modal',
summary: '',
examples: ['modal-types']
}
]
},
{
id: 'forms',
name: 'Form Controls',
Expand Down
19 changes: 11 additions & 8 deletions packages/mosaic-examples/mosaic-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import { McButtonModule } from '@ptsecurity/mosaic/button';
import { McCheckboxModule } from '@ptsecurity/mosaic/checkbox';
import { McDropdownModule } from '@ptsecurity/mosaic/dropdown';
import { McFormFieldModule } from '@ptsecurity/mosaic/form-field';
import { McModalModule } from '@ptsecurity/mosaic/modal';
import { McRadioModule } from '@ptsecurity/mosaic/radio';
import { McTextareaModule } from '@ptsecurity/mosaic/textarea';


@NgModule({

imports: [
McButtonModule,
McCheckboxModule,
McDropdownModule,
McRadioModule,
McMomentDateModule,
McFormFieldModule,
McTextareaModule
McButtonModule,
McCheckboxModule,
McDropdownModule,
McRadioModule,
McMomentDateModule,
McFormFieldModule,
McTextareaModule,
McModalModule
],
exports: [
McButtonModule,
Expand All @@ -26,7 +28,8 @@ import { McTextareaModule } from '@ptsecurity/mosaic/textarea';
McMomentDateModule,
McDropdownModule,
McFormFieldModule,
McTextareaModule
McTextareaModule,
McModalModule
]
})
export class ExampleMosaicModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** No CSS for this example */
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button mc-button color="primary" (click)="openModal()">Open Modal</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Component, Input } from '@angular/core';
import { McModalRef, McModalService } from '@ptsecurity/mosaic/modal';


/**
* @title Basic Modal
*/
@Component({
selector: 'modal-overview-example',
templateUrl: 'modal-overview-example.html',
styleUrls: ['modal-overview-example.css']
})
export class ModalOverviewExample {

constructor(
private modalService: McModalService
) {}

openModal() {
this.modalService.open({
mcComponent: McModalCustomComponent
});
}
}

@Component({
selector: 'mc-modal-full-custom-component',
template: `
<mc-modal-title>
Modal Title
</mc-modal-title>
<mc-modal-body>
<h2>{{ title }}</h2>
<h4>{{ subtitle }}</h4>
<p>
<span>Get Modal instance in component</span>
<button mc-button color="primary" (click)="destroyModal()">destroy modal in the component</button>
</p>
</mc-modal-body>
<div mc-modal-footer>
<button mc-button color="primary" >Save</button>
<button mc-button autofocus>Close</button>
</div>
`
})
export class McModalCustomComponent {
@Input() title: string;
@Input() subtitle: string;

constructor(private modal: McModalRef) { }

destroyModal() {
this.modal.destroy({ data: 'this the result data' });
}
}
28 changes: 28 additions & 0 deletions packages/mosaic-examples/mosaic/modal/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { McButtonModule } from '@ptsecurity/mosaic/button';
import { McIconModule } from '@ptsecurity/mosaic/icon';
import { McModalModule } from '@ptsecurity/mosaic/modal';

import { McModalCustomComponent, ModalOverviewExample } from './modal-overview/modal-overview-example';


const EXAMPLES = [
ModalOverviewExample,
McModalCustomComponent
];

@NgModule({
imports: [
FormsModule,
McButtonModule,
McModalModule,
McIconModule
],
declarations: EXAMPLES,
exports: EXAMPLES,
entryComponents: [
McModalCustomComponent
]
})
export class ModalExamplesModule {}
1 change: 1 addition & 0 deletions packages/mosaic/modal/modal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- example(modal-overview) -->

0 comments on commit 0db75d1

Please sign in to comment.