Skip to content

Commit f4a7266

Browse files
committed
fix(checkbox): fix horizontal spacing between checkboxes and radio buttons
1 parent 9a6ab35 commit f4a7266

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

src/components/checkbox/checkbox.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@import "variables";
44

55
/** The width/height of the checkbox element. */
6-
$md-checkbox-size: 18px !default;
6+
$md-checkbox-size: $md-toggle-size !default;
77
/** The width of the line used to draw the checkmark / mixedmark. */
88
$md-checkbox-mark-stroke-size: 2/15 * $md-checkbox-size !default;
99
/** The width of the checkbox border shown when the checkbox is unchecked. */
@@ -17,7 +17,7 @@ $md-checkbox-background-color: md-color($md-accent, 500);
1717
/** The base duration used for the majority of transitions for the checkbox. */
1818
$md-checkbox-transition-duration: 90ms;
1919
/** The amount of spacing between the checkbox and its label. */
20-
$md-checkbox-item-spacing: 4px;
20+
$md-checkbox-item-spacing: $md-toggle-padding;
2121

2222
// Manual calculation done on SVG
2323
$_md-checkbox-mark-path-length: 22.910259;
@@ -250,6 +250,11 @@ $_md-checkbox-indeterminate-checked-easing-function: cubic-bezier(0.14, 0, 0, 1)
250250
}
251251
}
252252

253+
// TODO(kara): Remove this style when fixing vertical baseline
254+
.md-checkbox-layout label {
255+
line-height: 24px;
256+
}
257+
253258
.md-checkbox-frame {
254259
@extend %md-checkbox-outer-box;
255260

src/components/radio/radio.scss

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import "default-theme";
2+
@import "variables";
23

3-
$md-radio-width: 20px !default;
4+
$md-radio-size: $md-toggle-size !default;
45

56
// Top-level host container.
67
md-radio-button {
@@ -12,18 +13,17 @@ md-radio-button {
1213
.md-radio-label {
1314
cursor: pointer;
1415
display: block;
15-
padding: 8px;
1616
white-space: nowrap;
1717
}
1818

1919
// Container for radio circles and ripple.
2020
.md-radio-container {
2121
box-sizing: border-box;
2222
display: inline-block;
23-
height: $md-radio-width;
23+
height: $md-radio-size;
2424
position: relative;
2525
top: 2px;
26-
width: $md-radio-width;
26+
width: $md-radio-size;
2727
}
2828

2929
// TODO(mtlin): Replace when ink ripple component is implemented.
@@ -60,12 +60,12 @@ md-radio-button {
6060
border: solid 2px;
6161
border-radius: 50%;
6262
box-sizing: border-box;
63-
height: $md-radio-width;
63+
height: $md-radio-size;
6464
left: 0;
6565
position: absolute;
6666
top: 0;
6767
transition: border-color ease 0.28s;
68-
width: $md-radio-width;
68+
width: $md-radio-size;
6969

7070
.md-radio-checked & {
7171
border-color: md-color($md-accent);
@@ -81,13 +81,13 @@ md-radio-button {
8181
background-color: md-color($md-accent);
8282
border-radius: 50%;
8383
box-sizing: border-box;
84-
height: $md-radio-width;
84+
height: $md-radio-size;
8585
left: 0;
8686
position: absolute;
8787
top: 0;
8888
transition: transform ease 0.28s, background-color ease 0.28s;
8989
transform: scale(0);
90-
width: $md-radio-width;
90+
width: $md-radio-size;
9191

9292
.md-radio-checked & {
9393
transform: scale(0.5);
@@ -103,11 +103,15 @@ md-radio-button {
103103
display: inline-block;
104104
float: right;
105105
line-height: 24px;
106-
// Equal padding on both sides, for RTL.
107-
padding-left: 8px;
108-
padding-right: 8px;
106+
padding-left: $md-toggle-padding;
109107
position: relative;
110108
vertical-align: top;
109+
110+
[dir='rtl'] & {
111+
float: left;
112+
padding-right: $md-toggle-padding;
113+
padding-left: 0;
114+
}
111115
}
112116

113117
// Underlying native input element.

src/core/style/_variables.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ $z-index-drawer: 100 !default;
1515
// Global constants
1616
$pi: 3.14159265;
1717

18+
// Padding between input toggles and their labels
19+
$md-toggle-padding: 8px !default;
20+
// Width and height of input toggles
21+
$md-toggle-size: 20px !default;
22+
1823
// Easing Curves
1924
// TODO(jelbourn): all of these need to be revisited
2025

src/demo-app/checkbox/checkbox-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h1>md-checkbox: Basic Example</h1>
66
[align]="alignment">
77
Do you want to <em>foobar</em> the <em>bazquux</em>?
88
</md-checkbox> - <strong>{{printResult()}}</strong>
9-
<div>
9+
<div class="demo-checkboxes">
1010
<input id="indeterminate-toggle"
1111
type="checkbox"
1212
[(ngModel)]="isIndeterminate"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.demo-checkboxes {
2+
margin: 8px 0;
3+
4+
}

src/demo-app/radio/radio-demo.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77
background-color: #f7f7f7;
88
margin: 8px;
99
padding: 16px;
10+
11+
md-radio-button {
12+
margin: 8px;
13+
}
1014
}

0 commit comments

Comments
 (0)