|
8 | 8 | <footer class="storybook-footer"> |
9 | 9 | Microsoft Graph Toolkit (v<span id="mgt-version"></span>) Playground was founded by Microsoft as a community guided, |
10 | 10 | open source project. |
11 | | - <a tabindex="-1" href="https://privacy.microsoft.com/en-us/privacystatement">Privacy & cookies</a> |
12 | | - <a tabindex="-1" href="https://www.microsoft.com/en-us/legal/intellectualproperty/copyright/default">Term of use</a> |
| 11 | + <a href="https://privacy.microsoft.com/en-us/privacystatement">Privacy & cookies</a> |
| 12 | + <a href="https://www.microsoft.com/en-us/legal/intellectualproperty/copyright/default">Terms of use</a> |
13 | 13 | </footer> |
14 | 14 |
|
15 | 15 | <script src="https://consentdeliveryfd.azurefd.net/mscc/lib/v2/wcp-consent.js"></script> |
|
30 | 30 |
|
31 | 31 | window.onload = () => { |
32 | 32 | addUsefulLinks(); |
33 | | - setUpBottomBar(); |
34 | 33 | } |
35 | 34 |
|
36 | 35 | function addUsefulLinks() { |
|
157 | 156 | return svgElem; |
158 | 157 | } |
159 | 158 | const windowWidth = window.innerWidth; |
160 | | - // Whenever the browser zoom is added or reduced, as long as it's |
161 | | - // over 100%, then get the footer height and set that as the value |
162 | | - // of the bottom offset of the bar. |
163 | | - const updateOnZoom = () => { |
164 | | - const pr = window.devicePixelRatio; |
165 | | - // Add an event listener to get any zoom changes based on |
166 | | - // on the resolution. |
167 | | - matchMedia(`(resolution: ${pr}dppx)`).addEventListener("change", updateOnZoom, { |
168 | | - once: true, |
169 | | - }); |
170 | | - |
171 | | - if ((pr * 100).toFixed(0) > 110) { |
172 | | - return setUpBottomBar(); |
173 | | - } |
174 | | - return; |
175 | | - }; |
176 | | - |
177 | | - // Whenever the browser is resized, also get the footer height and set the |
178 | | - // bottom bar value offset to it. |
179 | | - const updateOnWindowResize = () => { |
180 | | - if (windowWidth.innerWidth != windowWidth) { |
181 | | - setUpBottomBar(); |
182 | | - } |
183 | | - window.addEventListener("resize", updateOnWindowResize, { |
184 | | - once: true, |
185 | | - }); |
186 | | - return; |
187 | | - }; |
188 | | - |
189 | | - const updateOnOrientationChange = () => { |
190 | | - const orientation = window.matchMedia("(orientation: landscape)"); |
191 | | - updateBottomBar(); |
192 | | - // This is just to detect whether there has been an orientation change |
193 | | - // By default we expect to be in landscape so just in case it's something |
194 | | - // else, we still do the updates. |
195 | | - orientation.addEventListener("change", updateOnOrientationChange, { |
196 | | - once: true, |
197 | | - }); |
198 | | - }; |
199 | | - |
200 | | - const setUpBottomBar = () => { |
201 | | - const pr = (window.devicePixelRatio * 100).toFixed(0); |
202 | | - // This is a special case. When zooming in, in the first instance the content |
203 | | - // has to make the side bar disappear, the content takes a while to load. This |
204 | | - // makes the bottom bar unavailable hence it's hidden when the content loads. |
205 | | - // This delay should allow that to happen so that we are able to do get the |
206 | | - // bottom bar when we query it after 3 seconds. |
207 | | - if (pr > 190 && pr < 310) { |
208 | | - sleep(3000) |
209 | | - .then(() => { |
210 | | - updateBottomBar(); |
211 | | - }) |
212 | | - .catch(() => { }); |
213 | | - } |
214 | | - return updateBottomBar(); |
215 | | - }; |
216 | | - |
217 | | - function updateBottomBar() { |
218 | | - const footer = document.getElementsByClassName("storybook-footer")[0]; |
219 | | - const bottomBar = document.getElementsByClassName("css-1td7bem"); |
220 | | - if (bottomBar && bottomBar.length > 0) { |
221 | | - bottomBar[0].style.bottom = `${footer.clientHeight}px`; |
222 | | - } |
223 | | - return; |
224 | | - } |
225 | | - |
226 | | - function sleep(ms) { |
227 | | - return new Promise((resolve) => setTimeout(resolve, ms)); |
228 | | - } |
229 | | - |
230 | | - updateOnZoom(); |
231 | | - updateOnWindowResize(); |
232 | | - updateOnOrientationChange(); |
233 | 159 | </script> |
234 | 160 |
|
235 | 161 | <style> |
|
311 | 237 | </style> |
312 | 238 |
|
313 | 239 | <style> |
314 | | - |
315 | | - /* don't show the footer on mobile */ |
316 | | - @media (max-width: 599px) { |
317 | | - .storybook-footer { |
318 | | - display: none !important; |
319 | | - } |
320 | | - } |
321 | | - |
322 | | - /* this keeps the storybook body area above footer */ |
323 | | - @media (max-width: 768px) { |
324 | | - #root>div:first-of-type { |
325 | | - height: calc(100% - 50px); |
326 | | - } |
327 | | - } |
328 | | - |
329 | | - @media (min-width: 769px) { |
330 | | - #root>div:first-of-type { |
331 | | - height: calc(100% - 40px); |
332 | | - } |
333 | | - } |
334 | 240 | .sidebar-header button { |
335 | 241 | display: none !important; |
336 | 242 | } |
|
402 | 308 | display: none !important; |
403 | 309 | } |
404 | 310 | </style> |
| 311 | +<script> |
| 312 | + let attempts = 0; |
| 313 | + // Uses setInterval to wait for the sidebar to be rendered into the page |
| 314 | + // interval is cleared on success or after 100 tries (10 seconds) |
| 315 | + const retry = setInterval(() => { |
| 316 | + attempts++; |
| 317 | + if (attempts > 100) { |
| 318 | + clearInterval(retry); |
| 319 | + return; |
| 320 | + } |
| 321 | + const footer = document.querySelector('footer'); |
| 322 | + const sidebar = document.querySelector('nav.sidebar-container'); |
| 323 | + if (!sidebar) return; |
| 324 | + sidebar.parentElement.appendChild(footer); |
| 325 | + sidebar.style.height = `calc(100% - ${footer.clientHeight}px)`; |
| 326 | + clearInterval(retry); |
| 327 | + }, 100) |
| 328 | +</script> |
0 commit comments