diff --git a/extras/playground/samples.js b/extras/playground/samples.js index 49c2b777..3a07cf12 100644 --- a/extras/playground/samples.js +++ b/extras/playground/samples.js @@ -1034,18 +1034,38 @@ html .clear-completed:active { } `; -const RESPONSIVE = `class SubWidget extends owl.Component { - constructor() { - super(...arguments); - this.template = "subwidget"; - } +const RESPONSIVE = `class Navbar extends owl.Component { + template="navbar"; } -class ResponsiveWidget extends owl.Component { +class ControlPanel extends owl.Component { + template="controlpanel"; + widgets = { MobileSearchView }; +} + +class FormView extends owl.Component { + template="formview"; + widgets = { AdvancedWidget }; +} + +class AdvancedWidget extends owl.Component { + template="advancedwidget"; +} + +class Chatter extends owl.Component { + template="chatter"; +} + +class MobileSearchView extends owl.Component { + template="mobilesearchview"; +} + + +class App extends owl.Component { constructor() { super(...arguments); - this.template = "responsivewidget"; - this.widgets = { SubWidget }; + this.template = "app"; + this.widgets = { Navbar, ControlPanel, FormView, Chatter }; } } @@ -1058,50 +1078,119 @@ const env = { isMobile: isMobile() }; -const widget = new ResponsiveWidget(env); -widget.mount(document.body); +const app = new App(env); +app.mount(document.body); window.addEventListener( "resize", owl.utils.debounce(function() { const _isMobile = isMobile(); if (_isMobile !== env.isMobile) { - widget.updateEnv({ + app.updateEnv({ isMobile: _isMobile }); } }, 20) -); -`; +);`; const RESPONSIVE_XML = ` -
-
- Mobile - Desktop - mode -
- + + +
+

controlpanel

+
-
- This widget is only instantiated in desktop mode. It will be destroyed - and recreated if the mode changes from destop to mobile, and back to desktop + +
+

formview

+ +
+ +
+

Chatter

+
Message
+
+ +
MOBILE searchview
+ +
+ + +
+
+ + +
+
+ + + + + +
+
+ This widget is only created in desktop mode. +
`; -const RESPONSIVE_CSS = `.info { - font-size: 30px; +const RESPONSIVE_CSS = `body { + margin: 0; } -.desktop { - color: green; + +.app { + height: 100%; + flex-direction: column; } -.mobile { - color: blue; + +.app.desktop { + display: flex; } -.subwidget { - margin: 30px; -}`; +.navbar { + flex: 0 0 30px; + height: 30px; + background-color: cadetblue; + color: white; + line-height: 30px; +} + +.controlpanel { + flex: 0 0 100px; + height: 100px; + background-color: #dddddd; + padding: 8px; +} + +.content-wrapper { + flex: 1 1 auto; + position: relative; +} + +.content { + display: flex; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; +} + +.formview { + overflow-y: auto; + flex: 1 1 60%; + min-height: 200px; + padding: 8px; +} + +.chatter { + overflow-y: auto; + flex: 1 1 40%; + background-color: #eeeeee; + color: #333333; + padding: 8px; +} +`; const EMPTY = `class App extends owl.Component { }