Skip to content

Commit 867f640

Browse files
Website - Refactor DocCodeBlock to fix z-index issues (#2704)
1 parent c4b114f commit 867f640

File tree

5 files changed

+17
-38
lines changed

5 files changed

+17
-38
lines changed

website/app/initializers/showdown-extensions.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ export function initialize(/* application */) {
109109
selfExecutingBlock += ` <div class="doc-code-block__code-rendered">`;
110110
selfExecutingBlock += ` ${inputCodeblock}`;
111111
selfExecutingBlock += ' </div>';
112-
selfExecutingBlock += ` <Doc::CopyButton @id='${blockUniqueId}' @type="solid" @textToCopy='${codeblockEncoded}' @encoded={{true}} aria-labelledby="copy-label-${blockUniqueId} pre-block-${blockUniqueId}"/>`;
113-
selfExecutingBlock += ` ${preBlock}`;
112+
selfExecutingBlock += ' <div class="doc-code-block__code-snippet-wrapper">';
113+
selfExecutingBlock += ` <Doc::CopyButton @id='${blockUniqueId}' @type="solid" @textToCopy='${codeblockEncoded}' @encoded={{true}} aria-labelledby="copy-label-${blockUniqueId} pre-block-${blockUniqueId}"/>`;
114+
selfExecutingBlock += ` ${preBlock}`;
115+
selfExecutingBlock += ' </div>';
114116
selfExecutingBlock += '</div>';
115117

116118
if(attributeString.includes('data-execute=false')) {

website/app/styles/doc-components/code-block.scss

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,10 @@
1111
// Notice: vertical spacing is declared in `/styles/spacing`
1212

1313
.doc-code-block {
14-
position: relative;
15-
z-index: 2;
1614
border-radius: 3px;
17-
18-
.doc-copy-button {
19-
position: absolute;
20-
right: 13px;
21-
margin-top: 13px;
22-
}
2315
}
2416

2517
.doc-code-block__code-rendered {
26-
position: relative;
27-
z-index: 1;
2818
padding: 16px;
2919
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2'%3E%3Cpath d='M1 2V0h1v1H0v1z' fill-opacity='.05'/%3E%3C/svg%3E");
3020
// use this to fine tune the size of the checkered pattern
@@ -43,6 +33,16 @@
4333
}
4434
}
4535

36+
.doc-code-block__code-snippet-wrapper {
37+
position: relative;
38+
39+
.doc-copy-button {
40+
position: absolute;
41+
right: 13px;
42+
margin-top: 13px;
43+
}
44+
}
45+
4646
// notice: in some cases it's rendered as standalone element, so we have to have
4747
.doc-code-block__code-snippet {
4848
padding: 16px;

website/app/styles/doc-components/scroll-to-top.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
position: fixed;
88
right: 40px;
99
bottom: 40px;
10-
z-index: 99;
10+
z-index: 48; // Needs to be below z-index of hds-dialog-primitive__overlay
1111
width: 44px;
1212
height: 44px;
1313
padding: 8px;

website/app/styles/pages/application/sidebar.scss

-13
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,6 @@ body.application.index {
5858
// ALL THE OTHER PAGES
5959

6060
body.application:not(.index) {
61-
// if dialog is open, set sidebar z-index to 1
62-
&.doc-page-wrapper:has(dialog[open]),
63-
&.doc-page-wrapper:has(.hds-code-editor--is-full-screen) {
64-
--doc-z-index-sidebar: 1;
65-
66-
.doc-scroll-to-top {z-index: 1;}
67-
}
68-
69-
// if code editor is in full screen mode, set page header & scroll to top z-index to 1
70-
&.doc-page-wrapper:has(.hds-code-editor--is-full-screen) {
71-
.doc-page-header, .doc-scroll-to-top {z-index: 1;}
72-
}
73-
7461
// Notice: for `display` and animation/transition look below
7562
.doc-page-sidebar {
7663
position: fixed;

website/app/styles/pages/application/tabs.scss

+2-12
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,10 @@
3636
@include breakpoint.x-large() {
3737
padding: 24px var(--doc-page-stage-gutter-x-large) 0;
3838
}
39-
}
4039

41-
// Make tabs position sticky/fixed if:
42-
// * the viewport height is greater than 480px AND
43-
// * dialog is NOT open
44-
// * code editor is NOT in full screen mode
45-
.doc-page-wrapper
46-
:not(:has(dialog[open]))
47-
:not(:has(.hds-code-editor--is-full-screen)) {
4840
@media (height >= 480px) {
49-
.doc-page-tabs {
50-
position: sticky;
51-
top: var(--doc-page-header-height);
52-
}
41+
position: sticky;
42+
top: var(--doc-page-header-height);
5343
}
5444
}
5545

0 commit comments

Comments
 (0)