Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit 1e52e2b

Browse files
author
Matt Gaunt
committed
rebasing
2 parents caae313 + 9f56fd0 commit 1e52e2b

File tree

8 files changed

+70
-7
lines changed

8 files changed

+70
-7
lines changed

gulp-tasks/service-worker.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,30 @@ var packageName = JSON.parse(fs.readFileSync('./package.json', 'utf8')).name;
2525

2626
gulp.task('service-worker:watch', function(cb) {
2727
gulp.watch(GLOBAL.config.src + '/**/*.*', ['service-worker']);
28+
gulp.watch(GLOBAL.config.src + '/../server/views/**/*.*',
29+
['service-worker']);
2830
});
2931

3032
gulp.task('service-worker', function(cb) {
3133
swPrecache.write(path.join(GLOBAL.config.dest, 'sw.js'), {
3234
staticFileGlobs: [
3335
GLOBAL.config.dest + '/**/*.{js,html,css,png,jpg,jpeg,gif,svg}',
34-
GLOBAL.config.dest + '/manifest.json',
36+
GLOBAL.config.dest + '/manifest.json'
3537
],
3638
dynamicUrlToDependencies: {
37-
'/app-shell': ['server/layouts/app-shell.handlebars'],
38-
'/partials/': ['server/layouts/partial.handlebars', 'server/views/index.handlebars'],
39-
'/partials/url-1': ['server/layouts/partial.handlebars', 'server/views/url-1.handlebars'],
40-
'/partials/url-2': ['server/layouts/partial.handlebars', 'server/views/url-2.handlebars'],
39+
'/app-shell': ['server/views/layouts/app-shell.handlebars'],
40+
'/partials/': [
41+
'server/views/layouts/partial.handlebars',
42+
'server/views/index.handlebars'
43+
],
44+
'/partials/url-1': [
45+
'server/views/layouts/partial.handlebars',
46+
'server/views/url-1.handlebars'
47+
],
48+
'/partials/url-2': [
49+
'server/views/layouts/partial.handlebars',
50+
'server/views/url-2.handlebars'
51+
]
4152
},
4253
stripPrefix: GLOBAL.config.dest,
4354
navigateFallback: '/app-shell',

server/controllers/server-controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ ServerController.prototype.setUpServer = function(app) {
2020
app.set('views', path.join(__dirname, '/../views'));
2121
app.engine('handlebars', exphbs({
2222
defaultLayout: 'default',
23-
layoutsDir: path.join(__dirname, '/../layouts')
23+
layoutsDir: path.join(__dirname, '/../views/layouts'),
24+
partialsDir: path.join(__dirname, '/../views/partials'),
2425
}));
2526
app.set('view engine', 'handlebars');
2627

server/models/path-config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,29 @@ var pathConfigs = {
55
'/': {
66
view: 'index',
77
inlineStyles: getFileContents(['/styles/core.css']),
8+
remoteStyles: ['https://fonts.googleapis.com/css?family=Roboto:' +
9+
'400,300,700,500,400italic'],
810
remoteScripts: ['/scripts/static-page.js']
911
},
1012
'/url-1': {
1113
view: 'url-1',
1214
inlineStyles: getFileContents(['/styles/core.css']),
15+
remoteStyles: ['https://fonts.googleapis.com/css?family=Roboto:' +
16+
'400,300,700,500,400italic'],
1317
remoteScripts: ['/scripts/static-page.js']
1418
},
1519
'/url-2': {
1620
view: 'url-2',
1721
inlineStyles: getFileContents(['/styles/core.css']),
22+
remoteStyles: ['https://fonts.googleapis.com/css?family=Roboto:' +
23+
'400,300,700,500,400italic'],
1824
remoteScripts: ['/scripts/static-page.js']
1925
},
2026
'/app-shell': {
2127
view: '',
2228
inlineStyles: getFileContents(['/styles/core.css']),
29+
remoteStyles: ['https://fonts.googleapis.com/css?family=Roboto:' +
30+
'400,300,700,500,400italic'],
2331
remoteScripts: ['/scripts/core.js']
2432
}
2533
};

server/layouts/app-shell.handlebars renamed to server/views/layouts/app-shell.handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ limitations under the License.
112112
</svg>
113113
</div>
114114

115+
{{> async-css }}
116+
115117
{{#each remoteScripts}}
116118
<script src="{{this}}" async></script>
117119
{{~/each}}

server/layouts/default.handlebars renamed to server/views/layouts/default.handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ limitations under the License.
6363

6464
<aside class="toast-view js-toast-view"></aside>
6565

66+
{{> async-css }}
67+
6668
{{#each remoteScripts}}
6769
<script src="{{this}}" async></script>
6870
{{~/each}}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{#if remoteStyles}}
2+
<script>
3+
var remoteStyles = [
4+
{{#each remoteStyles}}
5+
'{{this}}',
6+
{{~/each}}
7+
];
8+
9+
// Asynchronously load CSS with a Request Animation Frame
10+
// For older browser support see this for a simple shim
11+
// http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
12+
window.requestAnimationFrame(function() {
13+
var elementToInsertLinkBefore =
14+
document.getElementsByTagName('script')[0];
15+
for (var i = 0; i < remoteStyles.length; i++) {
16+
var linkElement = document.createElement('link');
17+
linkElement.rel = 'stylesheet';
18+
linkElement.media = 'all';
19+
linkElement.href = remoteStyles[i];
20+
21+
elementToInsertLinkBefore.parentNode.insertBefore(linkElement,
22+
elementToInsertLinkBefore);
23+
}
24+
});
25+
</script>
26+
27+
<!-- In case the browser has JS disabled -->
28+
<noscript>
29+
{{#each remoteStyles}}
30+
<link href="{{this}}" rel="stylesheet" property="stylesheet" media="all">
31+
{{~/each}}
32+
</noscript>
33+
{{~/if}}

src/styles/core/_core.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ html, body {
2424
margin: 0;
2525
height: 100%;
2626
width: 100%;
27-
font-family: 'Roboto';
27+
font-family: 'Helvetica', 'Verdana', sans-serif;
2828
font-weight: 400;
29+
// Not implemented yet but is a nice solution for async loading fonts
30+
font-display: optional;
2931
color: #444;
3032
-webkit-font-smoothing: antialiased;
3133
-moz-osx-font-smoothing: grayscale;
@@ -59,6 +61,10 @@ body:after {
5961
transition: opacity 0.333s cubic-bezier(0,0,0.21,1) 0.4s;
6062
}
6163

64+
h1, h2, h3, h4, h5, h6 {
65+
font-family: 'Roboto', 'Helvetica', 'Verdana', sans-serif;
66+
}
67+
6268
.app-deeplink:after {
6369
opacity: 1;
6470
pointer-events: auto;

0 commit comments

Comments
 (0)