Skip to content

Commit cd22eb1

Browse files
authored
Button code cleanup (#22951)
* use a mixin there * revamp .btn-link to match default and outline variants * remove unnecessary properties
1 parent bb0cab9 commit cd22eb1

3 files changed

Lines changed: 36 additions & 38 deletions

File tree

scss/_button-group.scss

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
> .btn {
1111
position: relative;
1212
flex: 0 1 auto;
13-
margin-bottom: 0;
1413

1514
// Bring the hover, focused, and "active" buttons to the front to overlay
1615
// the borders properly
@@ -66,15 +65,18 @@
6665
.btn-group > .btn-group {
6766
float: left;
6867
}
68+
6969
.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
7070
border-radius: 0;
7171
}
72+
7273
.btn-group > .btn-group:first-child:not(:last-child) {
7374
> .btn:last-child,
7475
> .dropdown-toggle {
7576
@include border-right-radius(0);
7677
}
7778
}
79+
7880
.btn-group > .btn-group:last-child:not(:first-child) > .btn:first-child {
7981
@include border-left-radius(0);
8082
}
@@ -129,7 +131,6 @@
129131
//
130132

131133
.btn-group-vertical {
132-
display: inline-flex;
133134
flex-direction: column;
134135
align-items: flex-start;
135136
justify-content: center;
@@ -146,30 +147,35 @@
146147
margin-top: -$input-btn-border-width;
147148
margin-left: 0;
148149
}
149-
}
150150

151-
.btn-group-vertical > .btn {
152-
&:not(:first-child):not(:last-child) {
153-
border-radius: 0;
151+
> .btn {
152+
&:not(:first-child):not(:last-child) {
153+
border-radius: 0;
154+
}
154155
}
156+
155157
&:first-child:not(:last-child) {
156158
@include border-bottom-radius(0);
157159
}
160+
158161
&:last-child:not(:first-child) {
159162
@include border-top-radius(0);
160163
}
161-
}
162-
.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
163-
border-radius: 0;
164-
}
165-
.btn-group-vertical > .btn-group:first-child:not(:last-child) {
166-
> .btn:last-child,
167-
> .dropdown-toggle {
168-
@include border-bottom-radius(0);
164+
165+
> .btn-group:not(:first-child):not(:last-child) > .btn {
166+
border-radius: 0;
167+
}
168+
169+
> .btn-group:first-child:not(:last-child) {
170+
> .btn:last-child,
171+
> .dropdown-toggle {
172+
@include border-bottom-radius(0);
173+
}
174+
}
175+
176+
> .btn-group:last-child:not(:first-child) > .btn:first-child {
177+
@include border-top-radius(0);
169178
}
170-
}
171-
.btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child {
172-
@include border-top-radius(0);
173179
}
174180

175181

scss/_buttons.scss

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,36 +71,28 @@ fieldset[disabled] a.btn {
7171
.btn-link {
7272
font-weight: $font-weight-normal;
7373
color: $link-color;
74+
background-color: transparent;
7475
border-radius: 0;
7576

76-
&,
77-
&:active,
78-
&.active,
79-
&:disabled {
77+
@include hover {
78+
color: $link-hover-color;
79+
text-decoration: $link-hover-decoration;
8080
background-color: transparent;
81-
@include box-shadow(none);
81+
border-color: transparent;
8282
}
83-
&,
83+
8484
&:focus,
85-
&:active {
85+
&.focus {
8686
border-color: transparent;
8787
box-shadow: none;
8888
}
89-
@include hover {
90-
border-color: transparent;
91-
}
92-
@include hover-focus {
93-
color: $link-hover-color;
94-
text-decoration: $link-hover-decoration;
95-
background-color: transparent;
96-
}
97-
&:disabled {
98-
color: $btn-link-disabled-color;
9989

100-
@include hover-focus {
101-
text-decoration: none;
102-
}
90+
&:disabled,
91+
&.disabled {
92+
color: $btn-link-disabled-color;
10393
}
94+
95+
// No need for an active state here
10496
}
10597

10698

scss/mixins/_buttons.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
border-color: $border;
1010
@include box-shadow($btn-box-shadow);
1111

12-
&:hover {
12+
@include hover {
1313
@include color-yiq($background);
1414
background-color: $active-background;
1515
border-color: $active-border;

0 commit comments

Comments
 (0)