Polymer update style from child to parent -


i have 2 elements. first 1 called test-layout using styles core-layout

in test-layout:

<link rel="import" href="../commons/core-layout.html"> <style include="core-layout"></style> <div class="containertest">test layout text</div> 

in core-layout:

<style>  .containertest{     color: var(--color, blue); } </style>  <div class="containertest">core layout text</div>  <script> _mediachanged(e){   if(this.mediadetail.desktop){         this.customstyle['--color'] = 'blue';         this.updatestyles();     }     else if(this.mediadetail.tablet){         this.customstyle['--color'] = 'green';         this.updatestyles();     }     else if(this.mediadetail.mobile){         this.customstyle['--color'] = 'red';         this.updatestyles();     } } </script> 

_mediachange() using iron-media-query notify me if view desktop, tablet or mobile. there change font color

when resize page text in core-layout changes text in test-layout (parent) doesnt.

tablet size

enter image description here

mobile view

enter image description here

desktop view

enter image description here

is there way me update parent (test-layout)? want use core-layout styles media dependent , don't want have copy styles every component


solution

ok think figured out. if change mixin test-layout works. guess has go parent child , not other way around. did move _mediachanged() test-layout instead

mixins , css variables parent > children related when want apply them, updating variable children need have api in parent can apply changes on themself , changed of it's childrens.

your solution move _mediachanged() method works because moved variable assigment parent element , of it's children has value 😉


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -