I have this template in my code:
<template is="auto-binding" id="app">
<style>
core-header-panel core-toolbar{
height: 100px;
}
[drawer] div{
padding: 20px;
color: #fff;
}
[drawer] core-toolbar div{
font-size: 24px;
}
[main] div{
padding: 20px;
}
[main] core-toolbar {
background: #A319A3;
color: #fff;
font-size: 24px;
}
.login_dialog {
background: red
}
</style>
<core-drawer-panel>
<core-header-panel drawer>
<core-toolbar>
<div>Admin Managment</div>
</core-toolbar>
<div>
<core-menu selected="{{page}}" valueattr="data-category">
<core-submenu data-category="Dashboard" label="Dashboard">
<core-item label="Dashboard 1" horizontal="" center="" layout=""></core-item>
<core-item label="Dashboard 2" horizontal="" center="" layout=""></core-item>
<core-item label="Dashboard 3" horizontal="" center="" layout=""></core-item>
</core-submenu>
<core-submenu data-category="Topics" label="Topics" class="core-selected">
<core-item label="Topic 1" horizontal="" center="" layout=""></core-item>
<core-item label="Topic 2" horizontal="" center="" layout=""></core-item>
</core-submenu>
<core-submenu data-category="Favorites" label="Favorites">
<core-item label="Favorite 1" horizontal="" center="" layout=""></core-item>
<core-item label="Favorite 2" horizontal="" center="" layout=""></core-item>
<core-item label="Favorite 3" horizontal="" center="" layout=""></core-item>
</core-submenu>
</core-menu>
</div>
</core-header-panel>
<core-header-panel main>
<core-toolbar>
<core-icon-button icon="menu" core-drawer-toggle></core-icon-button>
<div>{{page}}</div>
</core-toolbar>
<core-pages selected="{{page}}" valueattr="data-category">
<section data-category="Dashboard">
<div>
Dashboard
<paper-action-dialog class="login_dialog" transition="core-transition-bottom" opened backdrop="" autoclosedisabled="">
<div>
<h1>Admin Login</h1>
<paper-input class="width100" floatingLabel label="Username"></paper-input>
<paper-input class="width100" floatingLabel label="Password"></paper-input>
<paper-button affirmative="" autofocus="" role="button" tabindex="0">Login</paper-button>
</div>
</paper-action-dialog>
</div>
</section><section data-category="Topics">
<div>Topics</div>
</section>
<section data-category="Favorites">
<div>Favorites</div>
</section>
</core-pages>
</core-header-panel>
</core-drawer-panel>
What is the best way to style this section of code:
<paper-action-dialog class="login_dialog" transition="core-transition-bottom" opened backdrop="" autoclosedisabled="">
<div>
<h1>Admin Login</h1>
<paper-input class="width100" floatingLabel label="Username"></paper-input>
<paper-input class="width100" floatingLabel label="Password"></paper-input>
<paper-button affirmative="" autofocus="" role="button" tabindex="0">Login</paper-button>
</div>
</paper-action-dialog>
I have tried to give it a class and change it but it doesn't seem to work. I have also looked up in the styling docs but nothing there is working for me.
You need to punch the shadow DOM to propagate down the styles. Something like this selector in the template style should work:
::host /deep/ paper-action-dialog.login_dialog {
...
}
Related
Using the template from starter kit 2, is it possible to have the app drawer below the app-header? Right now the app drawer starts from the top of viewport and is columnized next to app-header.
I would like my app to be like google keep and google cloud console where the app header spans the entire width of the viewport and the app drawer begins underneath.
After reading the element catalog for app-layout, I did not see a offical api/attribute to set this. I've tried a few things but no success:
<app-drawer-layout fullbleed>
<!-- Drawer content -->
<app-header condenses reveals effects="waterfall">
<app-toolbar>
<paper-icon-button icon="menu" drawer-toggle></paper-icon-button>
<div main-title>My App</div>
</app-toolbar>
</app-header>
<app-drawer>
<app-toolbar>Menu</app-toolbar>
<iron-selector selected="[[page]]" attr-for-selected="name" class="drawer-list" role="navigation">
<a name="view1" href="/view1">View One</a>
<a name="view2" href="/view2">View Two</a>
<a name="view3" href="/view3">View Three</a>
</iron-selector>
</app-drawer>
Basically you need to use an app-drawer-layout inside an app-header-layout.
Here is a JSBin with the desired layout.
And the code itself:
<dom-module id="test-app">
<template>
<style>
:host {
display: block;
--app-primary-color: #3F51B5;
}
app-header {
background-color: var(--app-primary-color);
color: white;
}
app-drawer {
top: 64px;
--app-drawer-content-container: {
padding: 0px;
background-color: #eee;
};
}
</style>
<app-header-layout fullbleed>
<app-header fixed shadow>
<app-toolbar id="toolbar">
<paper-icon-button icon="menu" on-tap="_onTap"></paper-icon-button>
<div main-title>Stormwind</div>
</app-toolbar>
</app-header>
<app-drawer-layout>
<app-drawer id="drawer">
drawer content
</app-drawer>
<div>
main content
</div>
</app-drawer-layout>
</app-header-layout>
</template>
<script>
Polymer({
is: 'test-app',
properties: {
},
ready: function() {
},
attached: function() {
},
_onTap: function() {
this.$.drawer.toggle();
}
});
</script>
</dom-module>
NOTE
You need to manually handle the drawer button (the drawer-toggle property won't work).
I have <iron-list> with grid mode encapsulated by <neon-animated-pages> and somehow neon-pages ruin its ability to adapt to screen size and rearrange items. I tried changing position of neon pages to relative and so on. Nothing helped. Thanks in advance.
Here is the code
<app-location route="{{route}}"></app-location>
<app-route
route="{{route}}"
pattern="/games/:subject"
data="{{router}}"
tail="{{subroute}}">
</app-route>
<neon-animated-pages selected="0" id="pages">
<games-subjects-module item="{{item}}"></games-subjects-module>
<games-subject-module item="{{item}}"></games-subject-module>
</neon-animated-pages>
And here is <games-subjects-module> where i have my iron-list
<template>
<style is="custom-style">
paper-card{
width: 200px;
height: 300px;
margin: 20px;
--paper-card-header-image:{
height: 250px;
}
}
</style>
<iron-list id="list" items="{{subjects}}" as="subject" selection-enabled selected-item="{{item}}" grid>
<template>
<div>
<a href="/games/{{subject.val.name}}">
<paper-card elevation="1">
<div class="card-content">
{{subject.val.name}}
</div>
</paper-card>
</a>
</div>
</template>
</iron-list>
</template>
How to place paper-icon-buttonin right corner of application header ?
Now my icon floats under title and it's not looking good.
Screenshot below
My element Code:
<polymer-element name="sidebar-layout" attributes="selected" noscript>
<template>
<link rel="stylesheet" href="/assets/css/sidebar-layout.css">
<core-scaffold>
<core-header-panel navigation flex mode="seamed">
<core-toolbar>Menu</core-toolbar>
<core menu theme="core-light-theme">
<core-item icon="info-outline" label="Notes" active?="{{selected == 'notes-page'}}"><a is="pushstate-anchor" href="/notes"></a></core-item>
<core-item icon="key" label="Logowanie" active?="{{selected == 'login-page'}}}}"><a is="pushstate-anchor" href="/login"></a></core-item>
<core-item icon="key" label="Pozalogowaniu" active?="{{selected == 'main-page'}}}}"><a is="pushstate-anchor" href="/main-page"></a></core-item>
</core>
</core-header-panel>
<div tool>
<content select=".title"></content>
<paper-icon-button id="morebutton"
icon="more-vert"></paper-icon-button>
</div>
<div class="content">
<content></content>
</div>
</core-scaffold>
</template>
</polymer-element>
Though you can do this using CSS pretty nicely here's a workaround that makes more semantic sense, adding a flex attribute to the <content> element or a <span> tag like I have dont below.
<polymer-element name="sidebar-layout" attributes="selected" noscript>
<template>
<link rel="stylesheet" href="/assets/css/sidebar-layout.css">
<core-scaffold>
<core-header-panel navigation flex mode="seamed">
<core-toolbar>Menu</core-toolbar>
<core menu theme="core-light-theme">
<core-item icon="info-outline" label="Notes" active?="{{selected == 'notes-page'}}"><a is="pushstate-anchor" href="/notes"></a></core-item>
<core-item icon="key" label="Logowanie" active?="{{selected == 'login-page'}}}}"><a is="pushstate-anchor" href="/login"></a></core-item>
<core-item icon="key" label="Pozalogowaniu" active?="{{selected == 'main-page'}}}}"><a is="pushstate-anchor" href="/main-page"></a></core-item>
</core>
</core-header-panel>
<div tool>
<content select=".title"></content>
<span flex></span>
<paper-icon-button id="morebutton"
icon="more-vert"></paper-icon-button>
</div>
<div class="content">
<content></content>
</div>
</core-scaffold>
</template>
</polymer-element>
This <span> tag with the flex attribute takes just the amount of space that it lets the icon fit in the far right.
More about the flex attribute at:
https://www.polymer-project.org/0.5/docs/polymer/layout-attrs.html
https://www.polymer-project.org/0.5/docs/elements/layout-elements.html
You should learn about layout attributes.
Specifically in this case the attribute justified does the job
<div horizontal layout justified tool>
<content select=".title"></content>
<paper-icon-button id="morebutton" icon="more-vert"></paper-icon-button>
</div>
I'm learning polymer and I've run into an issue where I have a core-list iterating on a datasource templating a paper-item that houses a core-icon-button.
<core-list id="list" fit>
<template>
<paper-item flex class="row {{ {selected: selected} | tokenList }}">
<core-icon-button id="settings"
icon="settings"
on-tap={{settingTap}}>
</core-icon-button>
{{model.Name}}
</paper-item>
</template>
</core-list>
The problem I am having is that on my buttons' on-tap function I need the parent items' model. Is there a "polymer way" to do what I am describing? Or do I have to extend
<polymer-element name='cust-list'>
<template>
<style>
</style>
<core-list id="list" fit data={{models}}>
<template>
<paper-item flex class="row {{ {selected: selected} | tokenList }}">
<core-icon-button id="settings" icon="settings" on-tap={{settingTap}}></core-icon-button>
{{model.name}}
</paper-item>
</template>
</core-list>
</template>
<script>
Polymer('cust-list', {
models: [{name: "test1"}, {name: "test2"}],
settingTap: function(e,d,s) {
console.log(s.templateInstance.model.model);
}
});
</script>
</polymer-element>
<cust-list></cust-list>
I'm in the middle of a project building a website for a family takeaway, I've managed to get the core design right for what I want. I now have a problem displaying adsense within my website.
I receive a message in console
Uncaught Error: adsbygoogle.push(): All ins elements in the DOM with class=adsbygoogle already have ads in them.
please take a look at the website http://tastygrillbristol.uk
</style>
<core-drawer-panel transition id="core_drawer_panel" touch-action>
<section id="section" drawer>
<core-header-panel mode="standard" id="core_header_panel">
<core-toolbar id="core_toolbar">
<div id="div">Menu</div>
</core-toolbar>
<section id="section2">
<core-menu selected="0" id="core_menu">
<core-item id="core_item7" icon="home" label="Home" horizontal center layout></core-item>
<core-submenu id="core_submenu" icon="list" label="Online Menu">
<core-item id="core_item" label="Special Offers" horizontal center layout></core-item>
<core-item id="core_item" label="Everything" horizontal center layout></core-item>
<core-item id="core_item" label="Burgers" horizontal center layout></core-item>
<core-item id="core_item1" label="Kebabs" horizontal center layout></core-item>
<core-item id="core_item2" label="Doners" horizontal center layout></core-item>
<core-item id="core_item3" label="Pizzas" horizontal center layout></core-item>
</core-submenu>
<core-item id="core_item4" icon="shopping-cart" label="Deliver to you" horizontal center layout></core-item>
<core-item id="core_item5" icon="perm-phone-msg" label="Call us" horizontal center layout></core-item>
<core-item id="core_item6" icon="file-map" label="Find us" horizontal center layout></core-item>
<core-item id="core_item6" icon="favorite" label="Follow us" horizontal center layout ></core-item>
</core-menu>
</section>
</core-header-panel>
</section>
<section id="section1" main>
<core-scroll-header-panel condenses id="core_scroll_header_panel" headerHeight="256" condensedHeaderHeight="64">
<core-toolbar class="tall" id="core_toolbar1">
<paper-icon-button core-drawer-toggle id="navicon" icon="menu"></paper-icon-button>
<div flex></div>
<div horizontal center-justified layout class="bottom indent title" > <p><b><font color=#FF1744>Tasty Grill</font></b></p> </div>
</core-toolbar>
<div class="content" horizontal layout center>
<post-card1>
<div align="center"><h2 align="center">WELCOME TO OUR WEBSITE, BARE IN MIND WE'RE STILL UNDER CONSTRUCTION</h2><p align="center">Take a look at our online Menu by pressing the Burger <core-icon icon="menu"></core-icon> Button above, or if you know exactly what you want call us now on <p><b>(0117)9522233</b></p></p></div>
</post-card1></div>
<section class="section1" horizontal center-justified layout>
<h1>ADSENSE CODE GOES HERE</h1>
</core-header-panel>
</core-scroll-header-panel>
</section>
</core-drawer-panel>
</template>
Just tested today (2017-05-05) the Ads is working fine within element (Polymer 1), no warnings, following is the sample code:
<paper-card>
<div class="card-content">
<p>my content here</p>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- AutoSize -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-000000000"
data-ad-slot="000000000"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
</paper-card>