Skip to content

Instantly share code, notes, and snippets.

@acdn-sglanzer
Last active October 30, 2020 19:45
Embed
What would you like to do?
New Twiddle
import Controller from '@ember/controller';
export default Controller.extend({
get routeHeader () {
return document.getElementById('route-header')
}
});
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@tracked isNavHidden = false
@action toggleNav () {
this.isNavHidden = !this.isNavHidden
}
}
import Controller from '@ember/controller';
export default Controller.extend({
get routeHeader () {
return document.getElementById('route-header')
}
});
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('a')
this.route('b')
});
export default Router;
import Route from '@ember/routing/route';
export default Route.extend({
});
import Route from '@ember/routing/route';
export default Route.extend({
});
import Route from '@ember/routing/route';
export default Route.extend({
redirect () {
this.transitionTo('a')
}
});
body {
margin: 0;
}
.application {
height: 100vh;
display: flex;
flex-direction: column;
background-color: green;
}
.header {
height: 4rem;
display: flex;
flex-direction: row;
}
.logo {
width: 4rem;
background-color: purple;
cursor: pointer;
}
.route-header {
flex: 1;
background-color: blue;
}
.menu {
width: 10rem;
background: pink;
}
.main {
flex: 1;
display: flex;
flex-direction: row;
background-color: red;
}
.nav {
width: 4rem;
background-color: green;
transition: width 0.2s;
}
.nav--hidden {
width: 0rem;
}
.content {
flex: 1;
display: flex;
flex-direction: column;
}
.route-content {
flex: 1;
display: flex;
flex-direction: column;
background-color: orange;
}
.route-content--center {
flex: 1;
align-self: center;
width: 10rem;
background-color: yellow;
display: flex;
flex-direction: column;
}
{{#-in-element this.routeHeader}}
Stuff for route A header
{{/-in-element}}
<div class='route-content'>
Stuff for route A content
</div>
<div class='application'>
<div class='header'>
<div class='logo' {{on 'click' this.toggleNav}}>
</div>
<div id='route-header' class='route-header'>
</div>
<div class='menu'>
</div>
</div>
<div class='main'>
<div class='nav {{if isNavHidden 'nav--hidden'}}'>
<LinkTo @route='a'>a</LinkTo>
<LinkTo @route='b'>b</LinkTo>
</div>
<div class='content'>
{{outlet}}
</div>
</div>
</div>
{{#-in-element this.routeHeader}}
Stuff for route B header
{{/-in-element}}
<div class='route-content'>
<div class='route-content--center'>
Stuff for route B content
</div>
</div>
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment