Skip to content

Commit 9f558e7

Browse files
gabalafoudrammock
andauthored
BUG - center search dialog on wide screens (#2085)
I noticed while reading the docs that on very wide screens, the search dialog was off center. This PR gets rid of all unnecessary CSS that was left over from when the search dialog was implemented without the built-in benefits of the HTML modal dialog element. ### How to test 1. Go to the preview docs build for this PR. 2. Make your screen really wide > 2000px. 3. Click on the search button in the header nav. 4. The search dialog should be centered now. 5. For good measure, type something in the search bar and hit enter. --------- Co-authored-by: Daniel McCloy <[email protected]>
1 parent 6345c7d commit 9f558e7

File tree

1 file changed

+33
-48
lines changed
  • src/pydata_sphinx_theme/assets/styles/components

1 file changed

+33
-48
lines changed

src/pydata_sphinx_theme/assets/styles/components/_search.scss

+33-48
Original file line numberDiff line numberDiff line change
@@ -82,60 +82,45 @@
8282
/**
8383
* The search modal <dialog>
8484
*/
85-
#pst-search-dialog {
86-
display: none;
87-
88-
&[open] {
89-
display: flex;
90-
91-
// Center in middle of screen just underneath header
92-
position: fixed;
93-
z-index: $zindex-modal;
94-
top: 30%;
95-
left: 50%;
96-
transform: translate(-50%, -30%);
97-
right: 1rem;
98-
margin-bottom: 0;
99-
margin-top: 0.5rem;
100-
width: 90%;
101-
max-width: 800px;
102-
background-color: transparent;
103-
padding: $focus-ring-width;
104-
border: none;
105-
flex-direction: column;
106-
height: 80vh;
85+
#pst-search-dialog[open] {
86+
margin: 15vh auto 0; // an open modal dialog has a fixed position, so these margins bring it 15% down the viewport height and center it horizontally
87+
width: 90%;
88+
max-width: 800px;
89+
background-color: transparent;
90+
padding: $focus-ring-width;
91+
border: none;
92+
height: 80vh;
93+
94+
&::backdrop {
95+
background-color: black;
96+
opacity: 0.5;
97+
}
98+
99+
form.bd-search {
100+
flex-grow: 0;
107101

108-
&::backdrop {
109-
background-color: black;
110-
opacity: 0.5;
102+
// Font and input text a bit bigger
103+
svg,
104+
input {
105+
font-size: var(--pst-font-size-icon);
111106
}
107+
}
112108

113-
form.bd-search {
114-
flex-grow: 0;
109+
/* In pydata-sphinx-theme.js this container is appended below
110+
* the query input node after the user types their search query.
111+
* Search results are populated into this container using Sphinx's
112+
* built-in, JS-powered local search tools. */
113+
#search-results {
114+
overflow-y: scroll;
115+
background-color: var(--pst-color-background);
116+
padding: 1em;
115117

116-
// Font and input text a bit bigger
117-
svg,
118-
input {
119-
font-size: var(--pst-font-size-icon);
120-
}
118+
a {
119+
color: var(--pst-color-link);
121120
}
122121

123-
/* In pydata-sphinx-theme.js this container is appended below
124-
* the query input node after the user types their search query.
125-
* Search results are populated into this container using Sphinx's
126-
* built-in, JS-powered local search tools. */
127-
#search-results {
128-
overflow-y: scroll;
129-
background-color: var(--pst-color-background);
130-
padding: 1em;
131-
132-
a {
133-
color: var(--pst-color-link);
134-
}
135-
136-
&.empty {
137-
display: none;
138-
}
122+
&.empty {
123+
display: none;
139124
}
140125
}
141126
}

0 commit comments

Comments
 (0)