<html>
<head>
<meta charset="utf-8">
<title>Custom properties in Polymer</title>
<link href='http://fonts.googleapis.com/css?family=Lato:400,300,700' rel='stylesheet' type='text/css'>
<script src="https://www.polymer-project.org/1.0/components/webcomponentsjs/webcomponents.min.js"></script>
<script>
// Force Polymer to use the Shadow DOM. This only works in Chrome.
window.Polymer = window.Polymer || {};
window.Polymer.dom = 'shadow';
</script>
<link rel="import" href="http://www.polymer-project.org/1.0/samples/components/polymer/polymer.html">
</head>
<!-- If you're using custom properties, they need to go in a custom-style element -->
<!-- Normal CSS styles can also go in here -->
<style is="custom-style">
body {
margin: 40px;
background-color: white;
}
/* This works, because you're styling the host, not inside the shadow DOM */
shiny-button.fancy {
font-family: "Lato";
font-weight: 300;
--shiny-button-background: #E91E63;
--shiny-button-container: {
text-transform: uppercase;
border-radius:3px;
color: white;
};
--shiny-button-text: {
padding: 10px;
};
--shiny-button-sides: {
text-shadow: 0 1px 1px #880E4F;
};
}
/* This shows you the difference between the host and the .container. */
/* shiny-button {
background-color: red;
}*/
/* None of these things work, because you can't cross the shadow boundary */
shiny-button .container {
color: red;
background-color: pink;
}
shiny-button .text-in-the-shadow-dom {
font-weight: 300;
}
</style>
<body>
<shiny-button>hallo hai</shiny-button>
<br><br>
<shiny-button class="fancy">hallo hai</shiny-button>
<dom-module id="shiny-button">
<style>
:host {
display: inline-block;
color: white;
}
.container {
background-color: var(--shiny-button-background, cornflowerblue);
padding: 10px;
border-radius: 10px;
@apply(--shiny-button-container);
}
.icon {
font-size: 20px;
@apply(--shiny-button-sides);
}
.user-text {
@apply(--shiny-button-text);
}
.text-in-the-shadow-dom {
font-weight: 900;
@apply(--shiny-button-sides);
}
</style>
<template>
<div class="container">
<span class="icon">♡</span>
<span class="user-text"><content></content></span>
<span class="text-in-the-shadow-dom">!!!</span>
</div>
</template>
<script>
Polymer({
is: 'shiny-button'
});
</script>
</dom-module>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |