Skip to content

Commit

Permalink
perf(ui): improve hover effect for post preview cards
Browse files Browse the repository at this point in the history
- home cards
- navigator buttons at the bottom post
  • Loading branch information
cotes2020 committed May 12, 2023
1 parent 34499f0 commit 7626e4d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 35 deletions.
44 changes: 27 additions & 17 deletions _sass/addon/commons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,32 @@ i {

/* --- post --- */

.post-preview {
@extend %rounded;

border: 0;
background: var(--card-bg);
box-shadow: var(--card-shadow);

&::before {
@extend %rounded;

content: '';
width: 100%;
height: 100%;
position: absolute;
background-color: var(--card-hovor-bg);
opacity: 0;
transition: opacity 0.35s ease-in-out;
}

&:hover {
&::before {
opacity: 0.3;
}
}
}

.post {
h1 {
margin-top: 3rem;
Expand Down Expand Up @@ -636,22 +662,6 @@ i {
@extend %no-decoration;
}

.card.post-preview {
border-radius: $card-radius;
border: 0;
background: var(--card-bg);
box-shadow: rgba(0, 0, 0, 0.05) 0 6px 14px 0,
var(--card-border-color) 0 0 0 1px;

&:hover {
background-color: var(--card-hovor-bg);

img {
filter: brightness(0.7) !important;
}
}
}

/* overwrite bootstrap muted */
.text-muted {
color: var(--text-muted-color) !important;
Expand All @@ -666,7 +676,7 @@ i {

/* Overwrite bootstrap outline button */
.btn.btn-outline-primary {
&:hover {
&:not(.disabled):hover {
border-color: #007bff !important;
}
}
Expand Down
5 changes: 3 additions & 2 deletions _sass/colors/dark-typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@
--btn-share-hover-color: #bfc1ca;
--relate-post-date: var(--text-muted-color);
--card-bg: #1e1e1e;
--card-hovor-bg: #3a3a3a;
--card-border-color: rgba(172, 169, 169, 0.17);
--card-hovor-bg: #464d51;
--card-shadow: rgb(21, 21, 21, 0.72) 0 6px 10px 0,
rgb(137, 135, 135, 0.3) 0 0 0 1px;
--kbd-wrap-color: #6a6a6a;
--kbd-text-color: #d3d3d3;
--kbd-bg-color: #242424;
Expand Down
3 changes: 2 additions & 1 deletion _sass/colors/light-typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
--btn-share-hover-color: var(--link-color);
--card-bg: white;
--card-hovor-bg: #e2e2e2;
--card-border-color: rgba(172, 169, 169, 0.13);
--card-shadow: rgb(104, 104, 104, 0.05) 0 2px 6px 0,
rgba(211, 209, 209, 0.15) 0 0 0 1px;
--label-color: #616161;
--relate-post-date: rgba(30, 55, 70, 0.4);
--footnote-target-bg: lightcyan;
Expand Down
35 changes: 20 additions & 15 deletions _sass/layout/post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
}

@mixin btn-post-nav {
%btn-post-nav {
width: 50%;
position: relative;
border-color: var(--btn-border-color);
Expand Down Expand Up @@ -172,27 +172,25 @@ h1 + .post-meta {
padding-bottom: 4rem;

.btn {
@include btn-post-nav;
@extend %btn-post-nav;

color: var(--link-color);
&:not(:hover) {
color: var(--link-color);
}

&:hover {
background: #2a408e;
color: #ffffff;
border-color: #2a408e;
&:not(.disabled)::before {
color: whitesmoke;
}
}

&.disabled {
@include btn-post-nav;
@extend %btn-post-nav;

pointer-events: auto;
cursor: not-allowed;
background: none;
color: gray;

&:hover {
border-color: none;
}
}

&.btn-outline-primary.disabled:focus {
Expand All @@ -207,14 +205,12 @@ h1 + .post-meta {
}

&:first-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-radius: $card-radius 0 0 $card-radius;
left: 0.5px;
}

&:last-child {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-radius: 0 $card-radius $card-radius 0;
right: 0.5px;
}
}
Expand All @@ -227,6 +223,15 @@ h1 + .post-meta {
}
} /* .post-navigation */

@media (hover: hover) {
.post-navigation {
.btn,
.btn::before {
transition: all 0.35s ease-in-out;
}
}
}

@-webkit-keyframes fade-up {
from {
opacity: 0;
Expand Down

0 comments on commit 7626e4d

Please sign in to comment.