Skip to content

Commit 9099cc1

Browse files
IsmaestroIsmael Ramos
authored andcommitted
feat(imports): add dynamic imports with html2canvas
1 parent 872a849 commit 9099cc1

10 files changed

Lines changed: 56 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ npm run docker | Builds the docker image and run the container
6868
* Internationalization
6969
* Lazy loading modules
7070
* Service Workers
71+
* Dynamic Imports
7172
* Custom [example library](https://github.com/Ismaestro/angular-example-library)
7273
* Modernizr (browser features detection)
7374
* Google Tag Manager

package-lock.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@angular/service-worker": "^5.2.10",
5555
"@ngx-translate/core": "9.1.1",
5656
"@ngx-translate/http-loader": "2.0.1",
57+
"@types/html2canvas": "0.0.33",
5758
"@types/jasmine": "2.8.6",
5859
"@types/jasminewd2": "2.0.3",
5960
"@types/node": "9.6.5",
@@ -62,6 +63,7 @@
6263
"codelyzer": "4.2.1",
6364
"coveralls": "3.0.0",
6465
"hammerjs": "2.0.8",
66+
"html2canvas": "^1.0.0-alpha.12",
6567
"http-server": "^0.11.1",
6668
"jasmine-core": "3.1.0",
6769
"jasmine-spec-reporter": "4.2.1",

src/app/heroes/hero-detail/hero-detail.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ <h1 class="header__title">{{'heroDetail' | translate}}</h1>
2929
</div>
3030
</ng-container>
3131
</div>
32-
32+
<button mat-raised-button type="button" (click)="dynamicImport()">
33+
{{'snapshot' | translate | uppercase}}
34+
</button>
3335
<button mat-raised-button type="button" (click)="goBack()">
3436
{{'goBack' | translate | uppercase}}
3537
</button>

src/app/heroes/hero-detail/hero-detail.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ export class HeroDetailComponent implements OnInit {
3838
});
3939
}
4040

41+
dynamicImport() {
42+
import('html2canvas').then(html2canvas => {
43+
html2canvas(document.getElementById('heroe-detail')).then((canvas) => {
44+
window.open().document.write('<img src="' + canvas.toDataURL() + '" />');
45+
});
46+
});
47+
}
48+
4149
goBack(): void {
4250
this.location.back();
4351
}

src/assets/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@
4949
"updateBrowser": "You are using an old browser, please update it and reload the page.",
5050
"firstTwoHeroesById": "Heroes (1-2)",
5151
"offlineMessage": "Without connection we can not load anything!",
52-
"goBack": "Go back"
52+
"goBack": "Go back",
53+
"snapshot": "Snapshot"
5354
}

src/assets/i18n/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@
4949
"updateBrowser": "Estas usando un navegador antiguo, por favor actualiza la versión y recarga la página.",
5050
"firstTwoHeroesById": "Heroes (1-2)",
5151
"offlineMessage": "Sin conexión no podemos cargar nada!",
52-
"goBack": "Volver"
52+
"goBack": "Volver",
53+
"snapshot": "Captura"
5354
}

src/assets/i18n/pt-br.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@
4949
"updateBrowser": "Você está usando um navegador antigo, atualize a versão e recarregue a página.",
5050
"firstTwoHeroesById": "Heróis (1-2)",
5151
"offlineMessage": "Sem conexão não podemos carregar nada!",
52-
"goBack": "Voltar"
52+
"goBack": "Voltar",
53+
"snapshot": "Instantâneo"
5354
}

src/assets/i18n/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@
4949
"updateBrowser": "您正在使用一个旧版本浏览器,请更新它并重新加载页面。",
5050
"firstTwoHeroesById": "英雄 (1-2)",
5151
"offlineMessage": "沒有連接,我們無法加載任何東西!",
52-
"goBack": "回來"
52+
"goBack": "回來",
53+
"snapshot": "快照"
5354
}

src/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
55
"baseUrl": "./",
6-
"module": "es2015",
6+
"module": "esnext",
77
"types": []
88
},
99
"exclude": [

0 commit comments

Comments
 (0)