Skip to content

Commit

Permalink
Feature - widescreen
Browse files Browse the repository at this point in the history
* Added optional extra stylesheets to layout
* If widescreen set in query, set for user session.
* If widescreen in session, add wide stylesheet
  • Loading branch information
joefitter committed May 5, 2020
1 parent f3789ee commit 5ffc512
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ui/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,21 @@ module.exports = settings => {
directives: getContentSecurityPolicy(settings)
}));

app.use((req, res, next) => {
if (req.query.widescreen) {
set(req.session, 'widescreen', true);
}
next();
});

app.use((req, res, next) => {
res.locals.user = req.user || {};
res.locals.static = res.locals.static || {};
set(res.locals, 'static.content', merge({}, res.locals.static.content, settings.content));
set(res.locals, 'static.urls', merge({}, settings.urls));
if (req.session.widescreen) {
set(res.locals, 'stylesheets', '/public/css/wide.css');
}
next();
});

Expand Down
3 changes: 2 additions & 1 deletion ui/views/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const Layout = ({
error,
children,
scripts = [],
stylesheets = [],
user,
crumbs,
footerLinks,
Expand Down Expand Up @@ -52,7 +53,7 @@ const Layout = ({
const page = (
<HomeOffice
propositionHeader={siteTitle}
stylesheets={['/public/css/app.css']}
stylesheets={['/public/css/app.css'].concat(stylesheets)}
scripts={scripts}
headerContent={<StatusBar user={user} />}
nonce={nonce}
Expand Down

0 comments on commit 5ffc512

Please sign in to comment.