Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Unified Diff: sky/framework/sky-checkbox/sky-checkbox.sky

Issue 836723006: Improve the appearance of <sky-checkbox> (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/sky-box/sky-box.sky ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/sky-checkbox/sky-checkbox.sky
diff --git a/sky/framework/sky-checkbox/sky-checkbox.sky b/sky/framework/sky-checkbox/sky-checkbox.sky
index 48067b83c73a5a66c877b1f7d548ba8e11d64165..74fa9585ae05d11d2ec2dc8e448ffbe4276cf0fb 100644
--- a/sky/framework/sky-checkbox/sky-checkbox.sky
+++ b/sky/framework/sky-checkbox/sky-checkbox.sky
@@ -9,28 +9,53 @@
<template>
<style>
:host {
- display: inline-flex;
+ display: flex;
justify-content: center;
align-items: center;
-webkit-user-select: none;
- width: 20px;
- height: 20px;
- border-radius: 4px;
- border: 1px solid blue;
- margin: 5px;
+ cursor: pointer;
+ width: 30px;
+ height: 30px;
+ }
+ #container {
+ border: solid 2px;
+ border-color: rgba(90, 90, 90, 0.25);
+ width: 10px;
+ height: 10px;
}
- :host([highlight=true]) {
+ #container.highlight {
+ border-radius: 10px;
background-color: orange;
+ border-color: orange;
+ }
+ #check {
+ top: 0px;
+ left: 0px;
+ }
+ #check.checked {
+ transform: translate(2px, -15px) rotate(45deg);
+ width: 10px;
+ height: 20px;
+ border-style: solid;
+ border-top: none;
+ border-left: none;
+ border-right-width: 2px;
+ border-bottom-width: 2px;
+ border-color: #0f9d58;
}
</style>
- <template if="{{ checked }}">
- <check>&check;</check>
- </template>
+ <div id="container" class="{{ containerStyle }}">
+ <div id="check" class="{{ checkStyle }}"></div>
+ </div>
</template>
<script>
module.exports = class extends SkyButton {
created() {
super.created();
+
+ this.containerStyle = "";
+ this.checkStyle = "";
+
this.setChecked(this.getAttribute('checked') == 'true');
this.addEventListener("mouseup", function() {
@@ -43,6 +68,19 @@ module.exports = class extends SkyButton {
setChecked(checked) {
this.checked = checked;
this.setAttribute('checked', checked);
+ this.checkStyle = checked ? 'checked' : '';
+ }
+ setHighlight(newValue) {
+ super.setHighlight(newValue);
+ this.containerStyle = newValue ? 'highlight' : '';
+ }
+ shadowRootReady() {
+ // TODO(esprehn): This is needed because the checked and highlight
+ // setters might be called before the shadowRoot is created since that
+ // doesn't happen until attached(). We should figure out a better way to do
+ // this.
+ this.setHighlight(this.highlight);
+ this.setChecked(this.checked);
}
}.register();
</script>
« no previous file with comments | « sky/framework/sky-box/sky-box.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698