1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/templates/application.hbs
Kevin Ansfield 3855e1a7b7 Added ability to set <main> class using route metadata
no issue
- modified `ui` service's `routeDidChange` handler to update it's `mainClass` property based on the new route's metadata
- used in the future for switching screen background colours

To use the feature, modify or add a `buildRouteInfoMetadata` hook in the route which you'd like to change, eg:

```js
export default AuthenticatedRoute.extend({
    ...

    buildRouteInfoMetadata() {
        return {
            bodyClasses: ['my-body-class'],
            mainClasses: ['grey-bg'] // <--------
        };
    }
});

```

The route hierarchy is taken into consideration with classes being added for all currently shown routes. For example if you wanted to add an `editor` class to all editor routes you could use the hook in `routes/editor.js` then if you added an `editor-new` class in `routes/editor/new.js` the resulting HTML output on the "New story" screen would be:

```html
<main class="gh-main editor editor-new">
```
2019-05-20 15:33:12 +01:00

25 lines
662 B
Handlebars

{{#gh-app showSettingsMenu=ui.showSettingsMenu}}
{{#gh-skip-link anchor=".gh-main"}}Skip to main content{{/gh-skip-link}}
{{gh-alerts}}
<div class="gh-viewport {{if ui.showSettingsMenu 'settings-menu-expanded'}} {{if ui.showMobileMenu 'mobile-menu-expanded'}}">
{{#if showNavMenu}}
{{gh-nav-menu
icon=settings.settledIcon
}}
{{/if}}
<main class="gh-main {{this.ui.mainClass}}" role="main">
{{outlet}}
</main>
{{gh-notifications}}
{{gh-content-cover}}
{{gh-mobile-nav-bar}}
</div>{{!gh-viewport}}
{{/gh-app}}
{{ember-load-remover}}