Skip to content

Commit 5203ddf

Browse files
committed
Merge pull request #13 from Polymer/checkbox
Replace switch with checkbox
2 parents d81cd15 + 09ae150 commit 5203ddf

File tree

3 files changed

+92
-115
lines changed

3 files changed

+92
-115
lines changed

src/shop-checkbox.html

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!--
2+
@license
3+
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7+
Code distributed by Google as part of the polymer project is also
8+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9+
-->
10+
11+
<link rel="import" href="../bower_components/polymer/polymer.html">
12+
13+
<dom-module id="shop-checkbox">
14+
<template>
15+
<style>
16+
17+
shop-checkbox {
18+
display: inline-block;
19+
width: 14px;
20+
height: 14px;
21+
position: relative;
22+
border: 2px solid var(--app-accent-color);
23+
border-radius: 2px;
24+
}
25+
26+
shop-checkbox > input[type=checkbox] {
27+
position: absolute;
28+
top: 0;
29+
left: 0;
30+
width: 100%;
31+
height: 100%;
32+
margin: 0;
33+
opacity: 0;
34+
}
35+
36+
shop-checkbox > shop-md-decorator {
37+
pointer-events: none;
38+
}
39+
40+
/* Checked state overlay */
41+
shop-checkbox > shop-md-decorator::after {
42+
content: '';
43+
position: absolute;
44+
top: -5px;
45+
left: -5px;
46+
right: -5px;
47+
bottom: -5px;
48+
background-image: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23172C50%22%20d%3D%22M19%203H5c-1.11%200-2%20.9-2%202v14c0%201.1.89%202%202%202h14c1.11%200%202-.9%202-2V5c0-1.1-.89-2-2-2zm-9%2014l-5-5%201.41-1.41L10%2014.17l7.59-7.59L19%208l-9%209z%22%2F%3E%3C%2Fsvg%3E');
49+
opacity: 0;
50+
transition: opacity 0.1s;
51+
will-change: opacity;
52+
}
53+
54+
shop-checkbox > input[type=checkbox]:checked + shop-md-decorator::after {
55+
opacity: 1;
56+
}
57+
58+
/* Focused state */
59+
shop-checkbox > shop-md-decorator::before {
60+
content: '';
61+
pointer-events: none;
62+
position: absolute;
63+
top: -13px;
64+
left: -13px;
65+
width: 40px;
66+
height: 40px;
67+
background-color: var(--app-accent-color);
68+
border-radius: 50%;
69+
opacity: 0.2;
70+
-webkit-transform: scale3d(0, 0, 0);
71+
transform: scale3d(0, 0, 0);
72+
transition: -webkit-transform 0.1s;
73+
transition: transform 0.1s;
74+
will-change: transform;
75+
}
76+
77+
shop-checkbox > input[type=checkbox]:focus + shop-md-decorator::before {
78+
-webkit-transform: scale3d(1, 1, 1);
79+
transform: scale3d(1, 1, 1);
80+
}
81+
82+
</style>
83+
</template>
84+
</dom-module>

src/shop-checkout.html

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<link rel="import" href="shop-form-styles.html">
1717
<link rel="import" href="shop-input.html">
1818
<link rel="import" href="shop-select.html">
19-
<link rel="import" href="shop-switch.html">
19+
<link rel="import" href="shop-checkbox.html">
2020

2121
<!-- resources loaded by lazy-resources.html -->
2222
<!--
@@ -29,7 +29,7 @@
2929
<dom-module id="shop-checkout">
3030

3131
<template>
32-
<style include="shop-common-styles shop-button shop-form-styles shop-input shop-select shop-switch">
32+
<style include="shop-common-styles shop-button shop-form-styles shop-input shop-select shop-checkbox">
3333

3434
.main-frame {
3535
transition: opacity 0.5s;
@@ -54,12 +54,13 @@
5454
}
5555

5656
.billing-address-picker {
57-
margin: 30px 0;
57+
margin: 28px 0;
58+
height: 20px;
59+
@apply(--layout-horizontal);
5860
}
5961

6062
.billing-address-picker > label {
61-
margin-left: 10px;
62-
vertical-align: middle;
63+
margin-left: 12px;
6364
}
6465

6566
.grid {
@@ -224,11 +225,11 @@ <h2 id="shipAddressHeading">Shipping Address</h2>
224225
</div>
225226
<h2 id="billAddressHeading">Billing Address</h2>
226227
<div class="billing-address-picker">
227-
<shop-switch>
228+
<shop-checkbox>
228229
<input type="checkbox" id="setBilling" name="setBilling"
229230
checked$="[[hasBillingAddress]]" on-change="_toggleBillingAddress">
230231
<shop-md-decorator></shop-md-decorator aria-hidden="true">
231-
</shop-switch>
232+
</shop-checkbox>
232233
<label for="setBilling">Use different billing address</label>
233234
</div>
234235
<div hidden$="[[!hasBillingAddress]]">

src/shop-switch.html

-108
This file was deleted.

0 commit comments

Comments
 (0)