Skip to content

Commit

Permalink
fix: fix hover background color for the code copy box (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored Aug 31, 2023
1 parent 6d75ee9 commit 2f614e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ document.addEventListener("DOMContentLoaded", function (event) {
const trigger = e.trigger

if (trigger.hasAttribute("data-copy-feedback")) {
trigger.classList.add("gdoc-post__codecopy--success")
trigger.classList.add("gdoc-post__codecopy--success", "gdoc-post__codecopy--out")
trigger.querySelector(".gdoc-icon.copy").classList.add("hidden")
trigger.querySelector(".gdoc-icon.check").classList.remove("hidden")

setTimeout(function () {
trigger.classList.remove("gdoc-post__codecopy--success")
trigger.classList.remove("gdoc-post__codecopy--success", "gdoc-post__codecopy--out")
trigger.querySelector(".gdoc-icon.copy").classList.remove("hidden")
trigger.querySelector(".gdoc-icon.check").classList.add("hidden")
}, 3000)
Expand Down
12 changes: 10 additions & 2 deletions src/sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ svg.gdoc-icon {
.gdoc-language__list {
background: var(--body-background);
border-radius: $border-radius;
box-shadow: 0 1px 3px 0 var(--accent-color-dark), 0 1px 2px 0 var(--accent-color);
box-shadow:
0 1px 3px 0 var(--accent-color-dark),
0 1px 2px 0 var(--accent-color);
position: absolute;
margin: 0;
padding: $padding-8 $padding-4 !important;
Expand Down Expand Up @@ -534,6 +536,10 @@ svg.gdoc-icon {
color: var(--code-copy-success-color);
}
}

&--out {
transition: visibility 2s ease-out;
}
}
}

Expand Down Expand Up @@ -584,7 +590,9 @@ svg.gdoc-icon {
padding: $padding-8;
padding-left: $padding-32;

transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
transition:
border-color 0.15s ease-in-out,
box-shadow 0.15s ease-in-out;
border: 1px solid transparent;
border-radius: $border-radius;

Expand Down
8 changes: 4 additions & 4 deletions src/sass/_color_mode.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@
--code-accent-color-lite: #{darken($code-background-dark, 2)};
--code-font-color: #{$code-font-color-dark};

--code-copy-background: #{$body-background-dark};
--code-copy-font-color: #{lighten($body-font-color, 24)};
--code-copy-border-color: #{lighten($body-font-color, 24)};
--code-copy-background: #{$code-background-dark};
--code-copy-font-color: #{$code-font-color-dark};
--code-copy-border-color: #{$code-font-color-dark};
--code-copy-success-color: #{scale-color(map.get($hint-colors, "ok"), $alpha: -55%)};
}

Expand All @@ -130,7 +130,7 @@
--code-font-color: #{$code-font-color};

--code-copy-background: #{$code-background};
--code-copy-font-color: #{lighten($body-font-color, 24)};
--code-copy-font-color: #{$code-font-color};
--code-copy-border-color: #{lighten($body-font-color, 48)};
--code-copy-success-color: #{map.get($hint-colors, "ok")};
}

0 comments on commit 2f614e6

Please sign in to comment.