Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit bf6cbbb

Browse files
committed
Material Radio, needs a little bit more love
1 parent 8177fbf commit bf6cbbb

File tree

4 files changed

+62
-9
lines changed

4 files changed

+62
-9
lines changed

dev/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const data = () => ({
120120
type: 'checkbox',
121121
label: 'Disabled',
122122
name: 'disabled',
123-
inline: false,
123+
value: true,
124124
disabled: true,
125125
customClass: 'col-12',
126126
}),

src/components/input-checkbox/InputCheckbox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="input-checkbox">
33
<input
4-
class="input-checkbox__toggle"
4+
class="input-checkbox__input"
55
type="checkbox"
66
:id="formControl.name"
77
v-model="formControl.value"

src/components/input-radio/InputRadio.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<template>
2-
<div class="input-radio">
2+
<div
3+
class="input-radio"
4+
:class="{ 'input-radio--inline': formControl.inline }"
5+
>
36
<div
4-
class="form-check"
5-
:class="{ 'form-check--inline': formControl.inline }"
7+
class="input-radio__base"
68
v-for="opt in formControl.options"
79
:key="opt.name"
810
>
911
<input
10-
class="form-check__input"
12+
class="input-radio__input"
1113
type="radio"
1214
:id="opt.value"
1315
v-model="formControl.value"
1416
:value="opt.value"
1517
:disabled="opt.disabled"
1618
/>
17-
<label class="form-check__label" :for="opt.value">
19+
<label class="input-radio__label" :for="opt.value">
1820
{{ opt.text }}
1921
</label>
2022
</div>

src/styles/themes/material.scss

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ select.form-control ~ .form-label,
158158
line-height: 1.5;
159159

160160
&:hover {
161-
#{$checkbox}__toggle {
161+
#{$checkbox}__input {
162162
opacity: 0.04;
163163

164164
&:hover {
@@ -167,7 +167,7 @@ select.form-control ~ .form-label,
167167
}
168168
}
169169

170-
&__toggle {
170+
&__input {
171171
appearance: none;
172172
-moz-appearance: none;
173173
-webkit-appearance: none;
@@ -284,3 +284,54 @@ select.form-control ~ .form-label,
284284
}
285285
}
286286
}
287+
288+
.input-radio {
289+
&--inline {
290+
display: inline-block;
291+
}
292+
293+
input[type='radio'] {
294+
display: none;
295+
296+
&:checked + label:before {
297+
border-color: $theme-color;
298+
animation: ripple 0.2s linear forwards;
299+
}
300+
&:checked + label:after {
301+
transform: scale(1);
302+
}
303+
}
304+
305+
label {
306+
display: inline-block;
307+
min-height: 20px;
308+
position: relative;
309+
padding: 0 (20px + 10px);
310+
margin-bottom: 0;
311+
cursor: pointer;
312+
vertical-align: bottom;
313+
&:before,
314+
&:after {
315+
position: absolute;
316+
content: '';
317+
border-radius: 50%;
318+
transition: all 0.3s ease;
319+
transition-property: transform, border-color;
320+
}
321+
&:before {
322+
left: 0;
323+
top: 0;
324+
width: 20px;
325+
height: 20px;
326+
border: 2px solid $base-color;
327+
}
328+
&:after {
329+
top: 20px / 2 - 10px / 2;
330+
left: 20px / 2 - 10px / 2;
331+
width: 10px;
332+
height: 10px;
333+
transform: scale(0);
334+
background: $theme-color;
335+
}
336+
}
337+
}

0 commit comments

Comments
 (0)