Skip to content

Commit b7cb584

Browse files
KirtiRamchandaniatscott
authored andcommitted
fix(docs-infra): avoid code copy button overlap
Reveal code copy controls on hover and focus so long code snippets stay readable while keyboard access and copy state feedback remain intact.
1 parent 3c70270 commit b7cb584

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

adev/shared-docs/styles/docs/_code.scss

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,14 @@ $code-font-size: 0.875rem;
228228
border-radius: 0.25rem;
229229
cursor: pointer;
230230
z-index: var(--z-index-icon);
231+
opacity: 0;
232+
pointer-events: none;
231233
background-color: var(--octonary-contrast);
232234
border: 1px solid var(--senary-contrast);
233235
transition:
234236
background-color 0.3s ease,
235-
border-color 0.3s ease;
237+
border-color 0.3s ease,
238+
opacity 0.3s ease;
236239

237240
.docs-icon {
238241
transition: opacity 0.3s ease-out;
@@ -256,6 +259,9 @@ $code-font-size: 0.875rem;
256259
}
257260

258261
&.docs-copy-source-code-button-success {
262+
opacity: 1;
263+
pointer-events: auto;
264+
259265
.docs-copy {
260266
opacity: 0;
261267
}
@@ -273,6 +279,32 @@ $code-font-size: 0.875rem;
273279
}
274280
}
275281

282+
.docs-code:hover,
283+
.docs-code:focus-within,
284+
.docs-example-viewer-code-wrapper:hover,
285+
.docs-example-viewer-code-wrapper:focus-within {
286+
> button[docs-copy-source-code] {
287+
opacity: 1;
288+
pointer-events: auto;
289+
}
290+
}
291+
292+
button[docs-copy-source-code]:focus-visible,
293+
button[docs-copy-source-code].docs-copy-source-code-button-failed {
294+
opacity: 1;
295+
pointer-events: auto;
296+
}
297+
298+
.docs-code:has(.docs-code-header) {
299+
button[docs-copy-source-code] {
300+
top: 0.45rem;
301+
}
302+
303+
.docs-code-header {
304+
padding-inline-end: 3rem;
305+
}
306+
}
307+
276308
.docs-code .docs-code-header {
277309
position: relative;
278310
h3 {

0 commit comments

Comments
 (0)