I am currently utilizing the paper-scroll-header-panel along with a custom CSS property
paper-scroll-header-panel {
--paper-scroll-header-panel-full-header: {
background-image: url(images/abcd.jpg);
};
}
in order to customize the full-sized header. However, I am facing an issue where the header image in this custom component needs to change based on the image URL provided by the loading page. I have defined a property and attempted to assign it through a computed property, but my approach does not seem to be effective. This is what I have tried.
<paper-scroll-header-panel style$={{backgroundCover}}>
and within the JavaScript:
Polymer({
is: 'dummy-layout',
properties: {
cover: String,
backgroundCover: {
type: String,
computed: 'computeBackground(cover)'
}
},
computeBackground: function(cover) {
return '--paper-scroll-header-panel-full-header: { background-image: url(' + cover + ');};';
},
Unfortunately, this method does not work as intended. How can I implement a varying background-image for different instances of a component while using a custom CSS component?
Update: The current code is displayed below. Nonetheless, it is still not functioning correctly.
<dom-module id="recipe-layout">
<link rel="import" type="css" href="recipe-layout.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url();
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-color: #00bcd4;
};
}
paper-toolbar {
height: 400px;
background-color: transparent;
}
</style>
<template>
<paper-scroll-header-panel condenses condensed-header-height="56" id="scroller">
<!-- Main Toolbar -->
<paper-toolbar>
<paper-icon-button icon="arrow-back" onclick="javascript:history.go(-1)"></paper-icon-button>
<div class="flex"></div>
<paper-icon-button icon="more-vert"></paper-icon-button>
<div class="bottom title"><content select=".cover-title"></content></div>
</paper-toolbar>
<div class="content">
<content select=".main-content"></content>
</div>
</paper-scroll-header-panel>
</template>
<script>
Polymer({
is: 'dummy-layout',
properties: {
cover: {
type: String,
observer: '_updateBg'
},
},
_updateBg: function(cover) {
this.async(function() { this.subupdateBg(cover); }, 100);
},
subupdateBg: function(cover) {
var scrollerBg = this.$.scroller;
console.dir(scrollerBg);
var newStyle = 'background-image: url('+ cover + ');';
scrollerBg.customStyle['--paper-scroll-header-panel-full-header'] = newStyle;
scrollerBg.updateStyles();
}
</script>
</dom-module>