OLD | NEW |
| 1 <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_in
dicator.html"> |
1 <link rel="import" href="chrome://resources/html/polymer.html"> | 2 <link rel="import" href="chrome://resources/html/polymer.html"> |
2 <link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-button/pape
r-radio-button.html"> | 3 <link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys-behavior
/iron-a11y-keys-behavior.html"> |
3 <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_in
dicator.html"> | |
4 <link rel="import" href="pref_control_behavior.html"> | 4 <link rel="import" href="pref_control_behavior.html"> |
5 <link rel="import" href="../prefs/pref_util.html"> | 5 <link rel="import" href="../prefs/pref_util.html"> |
6 <link rel="import" href="../settings_shared_css.html"> | 6 <link rel="import" href="../settings_shared_css.html"> |
7 | 7 |
8 <dom-module id="controlled-radio-button"> | 8 <dom-module id="controlled-radio-button"> |
9 <template> | 9 <template> |
10 <style include="settings-shared"> | 10 <style include="settings-shared"> |
11 :host { | 11 :host { |
| 12 --ink-to-circle: calc((var(--paper-radio-button-ink-size) - |
| 13 var(--paper-radio-button-size)) / 2); |
| 14 @apply(--settings-actionable); |
12 align-items: center; | 15 align-items: center; |
13 display: flex; | 16 display: flex; |
14 outline: none; | 17 outline: none; |
15 } | 18 } |
16 | 19 |
17 #radioButton { | 20 #labelWrapper { |
| 21 -webkit-margin-start: var(--paper-radio-button-label-spacing, 10px); |
18 flex: 1; | 22 flex: 1; |
19 } | 23 } |
20 | 24 |
| 25 #label { |
| 26 color: var(--paper-radio-button-label-color, --primary-text-color); |
| 27 } |
| 28 |
| 29 .circle, |
| 30 .disc, |
| 31 .disc-wrapper, |
| 32 paper-ripple { |
| 33 border-radius: 50%; |
| 34 } |
| 35 |
| 36 .disc-wrapper { |
| 37 height: var(--paper-radio-button-ink-size); |
| 38 margin: 0 calc(-1 * var(--ink-to-circle)); |
| 39 position: relative; |
| 40 width: var(--paper-radio-button-ink-size); |
| 41 } |
| 42 |
| 43 .circle, |
| 44 .disc { |
| 45 box-sizing: border-box; |
| 46 height: var(--paper-radio-button-size); |
| 47 left: var(--ink-to-circle); |
| 48 position: absolute; |
| 49 top: var(--ink-to-circle); |
| 50 width: var(--paper-radio-button-size); |
| 51 } |
| 52 |
| 53 .circle { |
| 54 border: 2px solid var(--paper-radio-button-unchecked-color, |
| 55 --primary-text-color); |
| 56 } |
| 57 |
| 58 :host([checked]) .circle { |
| 59 border-color: var(--paper-radio-button-checked-color, --primary-color); |
| 60 } |
| 61 |
| 62 .disc { |
| 63 background-color: var(--paper-radio-button-unchecked-background-color, |
| 64 transparent); |
| 65 transform: scale(0); |
| 66 transition: border-color 200ms, transform 200ms; |
| 67 } |
| 68 |
| 69 :host([checked]) .disc { |
| 70 background-color: var(--paper-radio-button-checked-color, |
| 71 --primary-color); |
| 72 transform: scale(0.5); |
| 73 } |
| 74 |
| 75 paper-ripple { |
| 76 color: var(--paper-radio-button-unchecked-ink-color, |
| 77 --primary-text-color); |
| 78 opacity: .6; |
| 79 } |
| 80 |
| 81 :host([checked]) paper-ripple { |
| 82 color: var(--paper-radio-button-checked-ink-color, |
| 83 --primary-text-color); |
| 84 } |
| 85 |
21 :host([controlled_]) { | 86 :host([controlled_]) { |
22 /* Disable pointer events for this whole element, as outer on-tap gets | 87 /* Disable pointer events for this whole element, as outer on-tap gets |
23 * triggered when clicking/tapping anywhere in :host. */ | 88 * triggered when clicking/tapping anywhere in :host. */ |
24 pointer-events: none; | 89 pointer-events: none; |
25 } | 90 } |
26 | 91 |
| 92 :host([controlled_]) :-webkit-any(.circle, .disc) { |
| 93 opacity: .5; |
| 94 } |
| 95 |
| 96 :host([controlled_]) .circle { |
| 97 border-color: var(--paper-radio-button-unchecked-color, |
| 98 --primary-text-color); |
| 99 } |
| 100 |
| 101 :host([controlled_][checked]) .disc { |
| 102 background-color: var(--paper-radio-button-unchecked-color, |
| 103 --primary-text-color); |
| 104 } |
| 105 |
| 106 :host([controlled_]) #labelWrapper { |
| 107 opacity: .65; |
| 108 } |
| 109 |
27 cr-policy-pref-indicator { | 110 cr-policy-pref-indicator { |
28 -webkit-margin-start: var(--settings-control-spacing); | 111 -webkit-margin-start: var(--settings-control-spacing); |
29 /* Enable pointer events for the indicator so :hover works. Disable | 112 /* Enable pointer events for the indicator so :hover works. Disable |
30 * clicks/taps via onIndicatorTap_ so outer on-tap doesn't trigger. */ | 113 * clicks/taps via onIndicatorTap_ so outer on-tap doesn't trigger. */ |
31 pointer-events: all; | 114 pointer-events: all; |
32 } | 115 } |
33 </style> | 116 </style> |
34 | 117 |
35 <paper-radio-button id="radioButton" name="{{name}}" checked="{{checked}}" | 118 <div class="disc-wrapper"> |
36 disabled="[[controlled_]]" tabindex$="[[tabindex]]"> | 119 <div class="circle"></div> |
37 [[label]] <content></content> | 120 <div class="disc"></div> |
38 </paper-radio-button> | 121 <paper-ripple center hold-down="[[pressed_]]"></paper-ripple> |
| 122 </div> |
| 123 |
| 124 <div id="labelWrapper"> |
| 125 <span id="label" hidden$="[[!label]]">[[label]]</span> |
| 126 <content></content> |
| 127 </div> |
39 | 128 |
40 <template is="dom-if" if="[[showIndicator_(controlled_, name, pref.*)]]"> | 129 <template is="dom-if" if="[[showIndicator_(controlled_, name, pref.*)]]"> |
41 <cr-policy-pref-indicator pref="[[pref]]" on-tap="onIndicatorTap_" | 130 <cr-policy-pref-indicator pref="[[pref]]" on-tap="onIndicatorTap_" |
42 icon-aria-label="[[label]]"> | 131 icon-aria-label="[[label]]"> |
43 </cr-policy-pref-indicator> | 132 </cr-policy-pref-indicator> |
44 </template> | 133 </template> |
45 | 134 |
46 </template> | 135 </template> |
47 <script src="controlled_radio_button.js"></script> | 136 <script src="controlled_radio_button.js"></script> |
48 </dom-module> | 137 </dom-module> |
OLD | NEW |