forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert external example write to StackBlitz (angular#331)
- Loading branch information
Showing
21 changed files
with
137 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './stackblitz-button'; |
6 changes: 3 additions & 3 deletions
6
src/app/shared/plunker/plunker-button.html → .../shared/stackblitz/stackblitz-button.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 20 additions & 20 deletions
40
src/app/shared/plunker/plunker-button.ts → ...pp/shared/stackblitz/stackblitz-button.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
import {Component, Input, NgModule} from '@angular/core'; | ||
import {PlunkerWriter} from './plunker-writer'; | ||
import {StackblitzWriter} from './stackblitz-writer'; | ||
import {ExampleData} from '@angular/material-examples'; | ||
import {MatButtonModule, MatIconModule, MatTooltipModule} from '@angular/material'; | ||
|
||
@Component({ | ||
selector: 'plunker-button', | ||
templateUrl: './plunker-button.html', | ||
providers: [PlunkerWriter], | ||
selector: 'stackblitz-button', | ||
templateUrl: './stackblitz-button.html', | ||
providers: [StackblitzWriter], | ||
host: { | ||
'(mouseover)': 'isDisabled = !plunkerForm' | ||
'(mouseover)': 'isDisabled = !stackblitzForm' | ||
} | ||
}) | ||
export class PlunkerButton { | ||
export class StackblitzButton { | ||
/** | ||
* The button becomes disabled if the user hovers over the button before the plunker form | ||
* The button becomes disabled if the user hovers over the button before the stackblitz form | ||
* is created. After the form is created, the button becomes enabled again. | ||
* The form creation usually happens extremely quickly, but we handle the case of the | ||
* plunker not yet being ready for people will poor network connections or slow devices. | ||
* stackblitz not yet being ready for people will poor network connections or slow devices. | ||
*/ | ||
isDisabled = false; | ||
plunkerForm: HTMLFormElement; | ||
stackblitzForm: HTMLFormElement; | ||
|
||
@Input() | ||
set example(example: string) { | ||
const exampleData = new ExampleData(example); | ||
|
||
this.plunkerWriter.constructPlunkerForm(exampleData).then(plunkerForm => { | ||
this.plunkerForm = plunkerForm; | ||
this.stackblitzWriter.constructStackblitzForm(exampleData).then(stackblitzForm => { | ||
this.stackblitzForm = stackblitzForm; | ||
this.isDisabled = false; | ||
}); | ||
} | ||
|
||
constructor(private plunkerWriter: PlunkerWriter) {} | ||
constructor(private stackblitzWriter: StackblitzWriter) {} | ||
|
||
openPlunker(): void { | ||
openStackblitz(): void { | ||
// When the form is submitted, it must be in the document body. The standard of forms is not | ||
// to submit if it is detached from the document. See the following chromium commit for | ||
// more details: | ||
// https://chromium.googlesource.com/chromium/src/+/962c2a22ddc474255c776aefc7abeba00edc7470%5E! | ||
document.body.appendChild(this.plunkerForm); | ||
this.plunkerForm.submit(); | ||
document.body.removeChild(this.plunkerForm); | ||
document.body.appendChild(this.stackblitzForm); | ||
this.stackblitzForm.submit(); | ||
document.body.removeChild(this.stackblitzForm); | ||
} | ||
} | ||
|
||
@NgModule({ | ||
imports: [MatTooltipModule, MatButtonModule, MatIconModule], | ||
exports: [PlunkerButton], | ||
declarations: [PlunkerButton], | ||
providers: [PlunkerWriter], | ||
exports: [StackblitzButton], | ||
declarations: [StackblitzButton], | ||
providers: [StackblitzWriter], | ||
}) | ||
export class PlunkerButtonModule {} | ||
export class StackblitzButtonModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.