|
| 1 | +"""Home — the introduction video. |
| 2 | +
|
| 3 | +Its own module rather than part of `example.py` because the two are different |
| 4 | +things: `example.py` is the live Leaflet 2 demo that proves the library |
| 5 | +renders, and this is a recording that explains it. `.. exec::` imports each by |
| 6 | +module path, so keeping them separate lets the markdown place them |
| 7 | +independently. |
| 8 | +
|
| 9 | +Embedded from `youtube-nocookie.com`, which is YouTube's no-tracking-cookie |
| 10 | +origin. It plays identically and does not set the visitor-tracking cookies the |
| 11 | +standard embed does — worth having on a documentation site that otherwise |
| 12 | +counts nothing about its readers beyond an anonymised page view. |
| 13 | +""" |
| 14 | + |
| 15 | +import dash_mantine_components as dmc |
| 16 | +from dash import html |
| 17 | + |
| 18 | +VIDEO_ID = "Wlmw98JrJZI" |
| 19 | +VIDEO_URL = f"https://youtu.be/{VIDEO_ID}" |
| 20 | +VIDEO_TITLE = "Dash Leaflet 2.0: Drone Tracking, Image Overlays & Map Packages in Python" |
| 21 | + |
| 22 | +component = dmc.Stack( |
| 23 | + [ |
| 24 | + html.Div( |
| 25 | + html.Iframe( |
| 26 | + src=( |
| 27 | + f"https://www.youtube-nocookie.com/embed/{VIDEO_ID}" |
| 28 | + "?rel=0&modestbranding=1" |
| 29 | + ), |
| 30 | + title=VIDEO_TITLE, |
| 31 | + # `fullscreen` belongs in `allow`, not in a separate |
| 32 | + # `allowFullScreen` prop: Dash 4.4.1's html.Iframe does not |
| 33 | + # expose the legacy attribute at all, and without the |
| 34 | + # permission the player still renders a fullscreen button that |
| 35 | + # silently does nothing — which reads as a broken embed rather |
| 36 | + # than a missing feature. |
| 37 | + allow=( |
| 38 | + "accelerometer; autoplay; clipboard-write; encrypted-media; " |
| 39 | + "fullscreen; gyroscope; picture-in-picture; web-share" |
| 40 | + ), |
| 41 | + # Nothing here needs the container's origin, and the iframe is |
| 42 | + # third-party — so it gets only what a video player requires. |
| 43 | + referrerPolicy="strict-origin-when-cross-origin", |
| 44 | + style={ |
| 45 | + "position": "absolute", |
| 46 | + "top": 0, |
| 47 | + "left": 0, |
| 48 | + "width": "100%", |
| 49 | + "height": "100%", |
| 50 | + "border": "0", |
| 51 | + "borderRadius": "8px", |
| 52 | + }, |
| 53 | + ), |
| 54 | + # The padding-bottom trick rather than `aspect-ratio`: it holds the |
| 55 | + # 16:9 box open from first paint in every engine, so the page does |
| 56 | + # not reflow when the iframe finally loads. (Dash 4.4.1's |
| 57 | + # html.Iframe exposes no `loading` prop, so the embed is eager and |
| 58 | + # the reserved box is what keeps the layout stable regardless.) |
| 59 | + style={ |
| 60 | + "position": "relative", |
| 61 | + "paddingBottom": "56.25%", |
| 62 | + "height": 0, |
| 63 | + "overflow": "hidden", |
| 64 | + "borderRadius": "8px", |
| 65 | + }, |
| 66 | + ), |
| 67 | + # A real link as well as the player. An agent reading /llms.txt never |
| 68 | + # sees the iframe, and neither does anyone whose browser blocks the |
| 69 | + # embed — both should still be able to reach the video. |
| 70 | + dmc.Anchor( |
| 71 | + f"Watch on YouTube: {VIDEO_TITLE}", |
| 72 | + href=VIDEO_URL, |
| 73 | + target="_blank", |
| 74 | + size="sm", |
| 75 | + c="dimmed", |
| 76 | + ), |
| 77 | + ], |
| 78 | + gap="xs", |
| 79 | +) |
0 commit comments