Skip to content

Commit 862bedf

Browse files
committed
feat: add watcher for AngularJS template changes to enable CLI's auto reload
- add gulp type defs - improvements to AngularJS tabs/buttons - disable click hijacking in AngularJS Material
1 parent 158f0af commit 862bedf

File tree

8 files changed

+149
-17
lines changed

8 files changed

+149
-17
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,23 @@ The following steps will configure a module that loads `$templateCache` at build
4848
- The [src/app/angularjs/templates/index.js](src/app/angularjs/templates/index.js) file sets up a module.
4949
- Then we import the module and use the `'templates'` string in our AngularJS module creation.
5050

51+
If you are working on AngularJS Templates (`.html` files referenced via `templateUrl`) and you want
52+
to enable the Angular CLI to auto-reload on changes, run:
53+
54+
```sh
55+
npm run watch:templates
56+
```
57+
5158
## TODO
5259

53-
- [ ] Add more AngularJS Material components.
54-
- [ ] Add more Angular Material components.
55-
- [ ] Add more CDK components.
5660
- [ ] Add some AngularJS Material services.
5761
- [ ] Add some Angular Material services.
5862
- [ ] Add some CDK services.
63+
- [x] Set up a watcher to rebuild AngularJS `$templateCache`
64+
- [x] Customize the AngularJS Material theme.
65+
- [x] Customize the Angular Material theme.
66+
- [x] Add more AngularJS Material components.
67+
- [x] Add more Angular Material components.
68+
- [x] Add more CDK components.
5969
- [x] Work around Terser mangling, using [dependency annotation](https://docs.angularjs.org/guide/di#dependency-annotation).
6070
- [x] Look into loading `$templateCache` at build time, using Gulp.

gulpfile.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
/* tslint:disable:no-var-requires */
12
const gulp = require('gulp');
23
const htmlmin = require('gulp-htmlmin');
34
const templateCache = require('gulp-angular-templatecache');
45

5-
gulp.task('templates', () => {
6+
const templates = () => {
67
return gulp
7-
.src('src/angularjs/**/*.html')
8+
.src('src/app/angularjs/**/*.html')
89
.pipe(htmlmin({ collapseWhitespace: true }))
910
.pipe(templateCache('templates.js', { standalone: true }))
10-
.pipe(gulp.dest('src/angularjs/templates'));
11+
.pipe(gulp.dest('src/app/angularjs/templates'));
12+
};
13+
14+
gulp.task('templates', templates);
15+
16+
gulp.task('watch', () => {
17+
return gulp.watch('src/app/angularjs/**/*.html', templates);
1118
});

package-lock.json

Lines changed: 92 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
@@ -6,6 +6,7 @@
66
"ng": "ng",
77
"start": "npm run build:templates && ng serve",
88
"build:templates": "gulp templates",
9+
"watch:templates": "gulp watch",
910
"build": "npm run build:templates && ng build",
1011
"test": "ng test",
1112
"prettier": "prettier --write \"**/*.{js,json,css,scss,less,md,ts,html,component.html}\"",
@@ -48,6 +49,7 @@
4849
"@angular/language-service": "~9.1.6",
4950
"@types/jasmine": "^3.5.10",
5051
"@types/jasminewd2": "^2.0.8",
52+
"@types/gulp": "^4.0.6",
5153
"@types/node": "^13.13.5",
5254
"codelyzer": "^5.2.2",
5355
"firebase-tools": "^8.2.0",

src/app/angularjs/app-angularjs.module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ import { bootstrapAngular } from './bootstrap-module';
1313

1414
const downgradedModule = downgradeModule(bootstrapAngular);
1515

16-
const configFunction = $mdThemingProvider => {
16+
const configFunction = ($mdThemingProvider, $mdGestureProvider) => {
1717
$mdThemingProvider
1818
.theme('default')
1919
.primaryPalette('indigo')
2020
.accentPalette('green', { default: '500' })
2121
.backgroundPalette('grey', { default: 'A100' });
22+
$mdGestureProvider.skipClickHijack();
2223
};
23-
configFunction.$inject = ['$mdThemingProvider'];
24+
configFunction.$inject = ['$mdThemingProvider', '$mdGestureProvider'];
2425

2526
export const appAngularjsModule = angular
2627
.module('AngularJSApp', ['ngMaterial', 'ngMessages', 'templates', downgradedModule])

src/app/angularjs/tabs.component.html

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1+
<style>
2+
#tabsContainer md-tab-content {
3+
min-height: 240px;
4+
}
5+
</style>
16
<div class="layout-margin">
27
<div id="tabsContainer">
3-
<md-tabs>
8+
<md-tabs md-dynamic-height md-border-bottom md-swipe-content>
49
<md-tab>
510
<md-tab-label>Buttons</md-tab-label>
611
<md-tab-body>
12+
<md-subheader>Flat Buttons</md-subheader>
713
<section layout="row" layout-align="start center" layout-wrap layout-margin>
814
<md-button>Button</md-button>
9-
<md-button md-no-ink class="md-primary">Primary (md-noink)</md-button>
10-
<md-button ng-disabled="true" class="md-primary">Disabled</md-button>
15+
<md-button md-no-ink class="md-primary"
16+
>Primary
17+
<md-tooltip>md-noink</md-tooltip>
18+
</md-button>
19+
<md-button class="md-accent">Accent</md-button>
1120
<md-button class="md-warn">Warn</md-button>
21+
<md-button ng-disabled="true" class="md-primary">Disabled</md-button>
1222
</section>
1323
<md-divider></md-divider>
24+
<md-subheader>Raised Buttons</md-subheader>
1425
<section layout="row" layout-align="start center" layout-wrap layout-margin>
1526
<md-button class="md-raised">Button</md-button>
1627
<md-button class="md-raised md-primary">Primary</md-button>
17-
<md-button ng-disabled="true" class="md-raised md-primary">Disabled</md-button>
28+
<md-button class="md-raised md-accent">Accent</md-button>
1829
<md-button class="md-raised md-warn">Warn</md-button>
30+
<md-button ng-disabled="true" class="md-raised md-primary">Disabled</md-button>
1931
</section>
2032
</md-tab-body>
2133
</md-tab>
2234
<md-tab>
2335
<md-tab-label>tab two</md-tab-label>
24-
<md-tab-body>tab two content</md-tab-body>
36+
<md-tab-body>
37+
<div class="md-padding md-margin">
38+
tab two content
39+
</div>
40+
</md-tab-body>
2541
</md-tab>
2642
<md-tab>
2743
<md-tab-label>tab three</md-tab-label>
28-
<md-tab-body>tab three content</md-tab-body>
44+
<md-tab-body>
45+
<div class="md-padding md-margin">
46+
tab three content
47+
</div></md-tab-body
48+
>
2949
</md-tab>
3050
</md-tabs>
3151
</div>

src/app/angularjs/templates/templates.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/angularjs/version-stamp.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export const versionStampComponent = {
2323
.version img {
2424
vertical-align: top;
2525
}
26-
md-divider {
26+
#version-stamp-divider {
2727
margin-top: 64px;
2828
}
2929
</style>
3030
31-
<md-divider></md-divider>
31+
<md-divider id="version-stamp-divider"></md-divider>
3232
<div class="version-container">
3333
<span class="version"><img src="/assets/angularjs.svg" alt="AngularJS icon" height="24px"> AngularJS v{{ $ctrl.versions.angularjs.full }} ({{ $ctrl.versions.angularjs.codeName }})</span>
3434
<span class="version"><img src="/assets/angularjs-material.png" alt="AngularJS Material icon" height="24px"> AngularJS Material v{{ $ctrl.versions.md }}</span>

0 commit comments

Comments
 (0)