Skip to content

Commit 610a75e

Browse files
committed
fix: resolve the copy button ghosting issue
Signed-off-by: Akshay Mestry <[email protected]>
1 parent 81077e5 commit 610a75e

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed

docs/source/conf.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Author: Akshay Mestry <[email protected]>
66
Created on: Saturday, February 22 2025
7-
Last updated on: Saturday, March 01 2025
7+
Last updated on: Wednesday, March 05 2025
88
99
This file contains the configuration settings for building SMART,
1010
Study, Mentorship, And Resourceful Teaching website using Sphinx, a
@@ -25,6 +25,11 @@
2525
button doesn't seem to work. Hence, relying on external sphinx
2626
extension. This support is added through the `sphinx_copybutton`
2727
extension.
28+
29+
.. versionchanged:: 5.3.2025
30+
31+
[1] Customized the CSS of the copy button extension and fixed a bug
32+
caused by default copy button element.
2833
"""
2934

3035
from __future__ import annotations
@@ -108,9 +113,27 @@
108113
ogp_type: t.Final[str] = "website"
109114
ogp_enable_meta_description: bool = True
110115

111-
docsearch_app_id = os.getenv("DOCSEARCH_APP_ID", "")
112-
docsearch_api_key = os.getenv("DOCSEARCH_API_KEY", "")
113-
docsearch_index_name = os.getenv("DOCSEARCH_INDEX_NAME", "")
114-
docsearch_container = "#smart-search"
115-
docsearch_placeholder = "SMART Search"
116-
docsearch_missing_results_url = source + "/issues/new?title=${query}"
116+
docsearch_app_id: str = os.getenv("DOCSEARCH_APP_ID", "")
117+
docsearch_api_key: str = os.getenv("DOCSEARCH_API_KEY", "")
118+
docsearch_index_name: str = os.getenv("DOCSEARCH_INDEX_NAME", "")
119+
docsearch_container: t.Final[str] = "#smart-search"
120+
docsearch_placeholder: t.Final[str] = "SMART Search"
121+
docsearch_missing_results_url: str = source + "/issues/new?title=${query}"
122+
123+
copybutton_exclude: str = ".linenos, .gp, .go"
124+
copybutton_line_continuation_character: str = "\\"
125+
copybutton_selector: str = "div:not(.no-copybutton) > div.highlight > pre"
126+
copybutton_image_svg: str = """\
127+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
128+
stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
129+
width="24" height="24" stroke-width="2">
130+
<path d="M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0
131+
0 0 -2 -2h-2"></path>
132+
<path d="M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0
133+
1 -2 -2z"></path>
134+
<path d="M9 12l.01 0"></path>
135+
<path d="M13 12l2 0"></path>
136+
<path d="M9 16l.01 0"></path>
137+
<path d="M13 16l2 0"></path>
138+
</svg>
139+
"""

theme/base/static/smart.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,22 @@ button.copybtn {
226226
border-width: 1px !important;
227227
border-color: hsl(var(--border)) !important;
228228
border-radius: 8px !important;
229-
background-color: hsl(var(--background)) !important;
229+
background-color: hsl(var(--background)) !important
230+
}
231+
232+
button.copybtn svg {
233+
padding-left: 0.15em
234+
}
235+
236+
.o-tooltip--left:after {
237+
transform: translateX(-102%) translateY(0);
238+
transition: opacity 0.2s cubic-bezier(0.64, 0.09, 0.08, 1), transform 0.2s cubic-bezier(0.64, 0.09, 0.08, 1);
239+
background-color: hsl(var(--code-background)) !important;
240+
color: hsl(0, 0%, 63%) !important;
241+
padding: 4px 5px !important;
242+
border: 1px solid hsl(var(--border)) !important;
243+
border-radius: 8px !important
244+
230245
}
231246

232247
pre span.linenos {

theme/base/static/theme.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)