forked from material-components/material-components-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
radio.html
256 lines (237 loc) · 10.3 KB
/
radio.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<!--
Copyright 2016 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License
-->
<html class="mdc-typography">
<head>
<meta charset="utf-8">
<title>Radio Button - Material Components Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png" />
<script src="assets/material-components-web.css.js" charset="utf-8"></script>
<link href="demos.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<style type="text/css">
.mdc-theme--dark {
background-color: #303030;
}
/* Example of manually theming a radio. In a real app, the primary color would have enough
contrast from the dark background that this wouldn't be necessary. */
.mdc-theme--dark .mdc-radio__native-control:checked:not(:disabled) ~ .mdc-radio__background .mdc-radio__outer-circle {
border-color: #e91e63;
}
.mdc-theme--dark .mdc-radio__native-control:checked:not(:disabled) ~ .mdc-radio__background .mdc-radio__inner-circle {
background-color: #e91e63;
}
.mdc-theme--dark .mdc-radio__background::before {
background-color: #e91e63;
}
.mdc-theme--dark .mdc-radio.mdc-ripple-upgraded::before,
.mdc-theme--dark .mdc-radio.mdc-ripple-upgraded::after {
background-color: rgba(233, 31, 99, .2);
}
.example {
margin: 24px;
padding: 24px;
}
</style>
</head>
<body>
<header class="mdc-toolbar mdc-toolbar--fixed">
<div class="mdc-toolbar__row">
<section class="mdc-toolbar__section mdc-toolbar__section--align-start">
<span class="catalog-back">
<a href="/"><i class="material-icons"></i></a>
</span>
<span class="mdc-toolbar__title catalog-title">Radio</span>
</section>
</div>
</header>
<main>
<div class="mdc-toolbar-fixed-adjust"></div>
<section class="hero">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" checked name="hero">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" checked name="hero">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
</section>
<section class="example">
<h2>With Javascript</h2>
<div class="mdc-form-field">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="ex2-radio1" checked name="ex2">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex2-radio1-label" for="ex2-radio1">Radio 1</label>
</div>
<div class="mdc-form-field">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="ex2-radio2" name="ex2">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex2-radio2-label" for="ex2-radio2">Radio 2</label>
</div>
</section>
<section class="example">
<h2>CSS Only</h2>
<div class="mdc-form-field">
<div class="mdc-radio" data-demo-no-js>
<input class="mdc-radio__native-control" type="radio" id="ex1-radio1" checked name="ex1">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex1-radio1-label" for="ex1-radio1">Radio 1</label>
</div>
<div class="mdc-form-field">
<div class="mdc-radio" data-demo-no-js>
<input class="mdc-radio__native-control" type="radio" id="ex1-radio2" name="ex1">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex1-radio2-label" for="ex1-radio2">Radio 2</label>
</div>
</section>
<section class="example">
<h2>CSS Only - Disabled</h2>
<div class="mdc-form-field">
<div class="mdc-radio mdc-radio--disabled" data-demo-no-js>
<input class="mdc-radio__native-control" type="radio" id="ex2-radio1" checked name="ex2" disabled>
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex2-radio1-label" for="ex2-radio1">Radio 1</label>
</div>
<div class="mdc-form-field">
<div class="mdc-radio mdc-radio--disabled" data-demo-no-js>
<input class="mdc-radio__native-control" type="radio" id="ex2-radio2" name="ex2" disabled>
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex2-radio2-label" for="ex2-radio2">Radio 2</label>
</div>
</section>
<section class="example mdc-theme--dark">
<h2 class="mdc-theme--text-primary-on-dark">Dark Theme</h2>
<div class="mdc-form-field">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="ex3-radio1" checked name="ex3">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex3-radio1-label" for="ex3-radio1">Radio 1</label>
</div>
<div class="mdc-form-field">
<div class="mdc-radio">
<input class="mdc-radio__native-control" type="radio" id="ex3-radio2" name="ex3">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex3-radio2-label" for="ex3-radio2">Radio 2</label>
</div>
</section>
<section class="example">
<h2>Disabled</h2>
<div>
<div class="mdc-form-field">
<div class="mdc-radio mdc-radio--disabled">
<input class="mdc-radio__native-control" type="radio" id="ex4a-radio1" checked disabled name="ex4a">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex4a-radio1-label" for="ex4a-radio1">Disabled Radio 1</label>
</div>
<div class="mdc-form-field">
<div class="mdc-radio mdc-radio--disabled">
<input class="mdc-radio__native-control" type="radio" id="ex4a-radio2" disabled name="ex4a">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex4a-radio2-label" for="ex4a-radio2">Disabled Radio 2</label>
</div>
</div>
<div class="mdc-theme--dark">
<div class="mdc-form-field">
<div class="mdc-radio mdc-radio--disabled">
<input class="mdc-radio__native-control" type="radio" id="ex4b-radio1" checked disabled name="ex4b">
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex4b-radio1-label" for="ex4b-radio1">Disabled Radio 1</label>
</div>
<div class="mdc-form-field">
<div class="mdc-radio mdc-radio--disabled">
<input class="mdc-radio__native-control" type="radio" id="ex4b-radio2" name="ex4b" disabled>
<div class="mdc-radio__background">
<div class="mdc-radio__outer-circle"></div>
<div class="mdc-radio__inner-circle"></div>
</div>
</div>
<label id="ex4b-radio2-label" for="ex4b-radio2">Disabled Radio 2</label>
</div>
</div>
</section>
</main>
<script src="assets/material-components-web.js" charset="utf-8"></script>
<script>
(function(global) {
'use strict';
var MDCFormField = global.mdc.formField.MDCFormField;
var MDCRadio = global.mdc.radio.MDCRadio;
var formFields = document.querySelectorAll('.mdc-form-field');
for (var i = 0, formField; formField = formFields[i]; i++) {
var formFieldInstance = new MDCFormField(formField);
var radio = formField.querySelector('.mdc-radio:not([data-demo-no-js])');
if (radio) {
var radioInstance = new MDCRadio(radio);
formFieldInstance.input = radioInstance;
}
}
})(this);
</script>
</body>
</html>