Skip to content

Commit 013eabd

Browse files
iveysaurjelbourn
authored andcommitted
feat(button-toggle): add initial button-toggle (#517)
* md-toggle initial prototype * Use directives, no sass nesting, and private event emitter * Move toggle and radio dispatcher into shared unique selection dispatcher * Rename toggles to button-toggles * Update toggle to look more like radio after updates * Update child name from parent name * TSLint fixes * Misc style fixes for PR. * Update comment * Remove unused `_buttonToggles` * Use string literals for button toggle type * Move instantiation into the constructor * Add `isSingleSelection` getter * Move click event binding to component * Add missing tests to button toggles * Exclusive toggle should deselect all when group value is cleared * Button toggles should be checked when the checkbox is interacted with * Remove onClick() * Remove click event * Remove unnecessary getters and setters. * Add icons to demo app * Add missing semicolon * Change eventemitter to private in button toggle class * Get native elements in tests from debug elements * Move internal to end of comment and use BooleanFieldValue * Fix typo in test description. * vertical align middle all children in button toggle
1 parent e366fa0 commit 013eabd

File tree

13 files changed

+827
-25
lines changed

13 files changed

+827
-25
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<label [attr.for]="inputId" class="md-button-toggle-label">
2+
<input #input class="md-button-toggle-input"
3+
[type]="type"
4+
[id]="inputId"
5+
[checked]="checked"
6+
[disabled]="disabled"
7+
[name]="name"
8+
(change)="onInputChange($event)">
9+
10+
<div class="md-button-toggle-label-content">
11+
<ng-content></ng-content>
12+
</div>
13+
</label>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@import "elevation";
2+
@import "default-theme";
3+
@import "palette";
4+
@import "mixins";
5+
6+
$md-button-toggle-padding: 0 16px !default;
7+
$md-button-toggle-line-height: 36px !default;
8+
$md-button-toggle-border-radius: 3px !default;
9+
10+
md-button-toggle-group {
11+
@include md-elevation(2);
12+
position: relative;
13+
display: inline-flex;
14+
border-radius: $md-button-toggle-border-radius;
15+
cursor: pointer;
16+
white-space: nowrap;
17+
}
18+
19+
20+
.md-button-toggle-checked .md-button-toggle-label-content {
21+
background-color: md-color($md-grey, 300);
22+
}
23+
24+
.md-button-toggle-disabled .md-button-toggle-label-content {
25+
background-color: md-color($md-foreground, disabled);
26+
cursor: not-allowed;
27+
}
28+
29+
md-button-toggle {
30+
white-space: nowrap;
31+
}
32+
33+
.md-button-toggle-input {
34+
@include md-visually-hidden;
35+
}
36+
37+
.md-button-toggle-label-content {
38+
display: inline-block;
39+
line-height: $md-button-toggle-line-height;
40+
padding: $md-button-toggle-padding;
41+
cursor: pointer;
42+
}
43+
44+
.md-button-toggle-label-content > * {
45+
vertical-align: middle;
46+
}

0 commit comments

Comments
 (0)