Refactor like/unlike buttons SCSS

We were using the same selectors three times. Since we're going to
change that part of the code, we're simplifying it so we don't have to
do the same changes three times.
This commit is contained in:
Javi Martín
2023-10-10 22:25:17 +02:00
parent 0f45dbb896
commit 1387356c86
2 changed files with 18 additions and 30 deletions

View File

@@ -22,41 +22,30 @@
line-height: rem-calc(30); line-height: rem-calc(30);
padding: rem-calc(3) rem-calc(6) rem-calc(6); padding: rem-calc(3) rem-calc(6) rem-calc(6);
position: relative; position: relative;
}
@mixin like-unlike-icon($icon, $pressed-color) {
@include has-fa-icon($icon, solid);
&:not([disabled]) { &:not([disabled]) {
cursor: pointer;
&:hover, &:hover,
&:active, &:active,
&[aria-pressed=true] { &[aria-pressed=true] {
background: $pressed-color;
border-color: $pressed-color;
color: #fff; color: #fff;
cursor: pointer;
} }
} }
} }
.in-favor button { .in-favor button {
@include has-fa-icon(thumbs-up, solid); @include like-unlike-icon(thumbs-up, $like);
&:not([disabled]) {
&:hover,
&:active,
&[aria-pressed=true] {
background: $like;
border-color: $like;
}
}
} }
.against button { .against button {
@include has-fa-icon(thumbs-down, solid); @include like-unlike-icon(thumbs-down, $unlike);
&:not([disabled]) {
&:hover,
&:active,
&[aria-pressed=true] {
background: $unlike;
border-color: $unlike;
}
}
} }
.percentage { .percentage {

View File

@@ -1707,22 +1707,21 @@ table {
} }
} }
.in-favor button { @mixin like-unlike-icon($icon, $pressed-color) {
@include has-fa-icon(thumbs-up, solid); @include has-fa-icon($icon, solid);
&:hover, &:hover,
&[aria-pressed=true] { &[aria-pressed=true] {
color: $like; color: $pressed-color;
} }
} }
.against button { .in-favor button {
@include has-fa-icon(thumbs-down, solid); @include like-unlike-icon(thumbs-up, $like);
}
&:hover, .against button {
&[aria-pressed=true] { @include like-unlike-icon(thumbs-down, $unlike);
color: $unlike;
}
} }
} }