Skip to content

Commit e2ed5fe

Browse files
authored
[UI Enhancement] ApiDemoPanel: Expand modal cleanup (#566)
* Remove inline styling and fix content blurriness * Use flexbox positioning to correct modal blurriness * Set modal width and height based on viewport
1 parent 8f889a6 commit e2ed5fe

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/Container/_Container.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.openapi-demo__code-block-container {
2+
height: 100%;
23
background: var(--prism-background-color);
34
color: var(--prism-color);
45
margin-bottom: unset;

packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/Content/_Content.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.openapi-demo__code-block-content {
2+
height: 100%;
23
position: relative;
34
/* rtl:ignore */
45
direction: ltr;
@@ -15,6 +16,7 @@
1516
}
1617

1718
.openapi-demo__code-block {
19+
height: 100%;
1820
border-radius: var(--ifm-global-radius);
1921
--ifm-pre-background: var(--prism-background-color);
2022
margin: 0;

packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/_ExpandButton.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
.openapi-demo__expand-modal-content {
2+
padding: none;
3+
border: thin solid var(--ifm-toc-border-color);
4+
border-radius: var(--ifm-global-radius);
5+
max-width: 95%;
6+
width: 65vw;
7+
height: 65vh;
8+
overflow: auto;
9+
}
10+
11+
.openapi-demo__expand-modal-overlay {
12+
display: flex;
13+
align-items: center;
14+
justify-content: center;
15+
position: fixed;
16+
inset: 0px;
17+
background-color: rgba(0, 0, 0, 0.9);
18+
z-index: 201;
19+
}
20+
121
.theme-code-block:hover .openapi-demo__code-block-expand-btn--copied {
222
opacity: 1 !important;
323
}

packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,6 @@ export default function ExpandButton({
3838

3939
const [modalIsOpen, setIsOpen] = React.useState(false);
4040

41-
const customStyles = {
42-
overlay: { backgroundColor: "rgba(0, 0, 0, 0.9)", zIndex: "201" },
43-
content: {
44-
top: "50%",
45-
left: "50%",
46-
right: "auto",
47-
bottom: "auto",
48-
padding: "none",
49-
border: "thin solid var(--ifm-toc-border-color)",
50-
borderRadius: "var(--ifm-global-radius)",
51-
transform: "translate(-50%, -50%)",
52-
maxWidth: "95%",
53-
width: "min-content",
54-
overflow: "auto",
55-
},
56-
};
5741
useEffect(() => {
5842
Modal.setAppElement("body");
5943
});
@@ -107,9 +91,10 @@ export default function ExpandButton({
10791
</span>
10892
</button>
10993
<Modal
94+
className="openapi-demo__expand-modal-content"
95+
overlayClassName="openapi-demo__expand-modal-overlay"
11096
isOpen={modalIsOpen}
11197
onRequestClose={closeModal}
112-
style={customStyles}
11398
contentLabel="Code Snippet"
11499
>
115100
<Container

0 commit comments

Comments
 (0)