feat(mdx): click-to-expand images in docs and blog - #379
Conversation
Add MdxFigure for docs and blog MDX images: clickable next/image thumbnail and a Radix dialog lightbox with a viewport-fitted view. Lazy-load lightbox code (next/dynamic, ssr: false). Fix alt text to use markdown alt instead of title. Convert remaining raw img tags on the telegram bot page and one blog post. Preserve telegram bot figure widths (55% / 40%). Closes kagent-dev#362 Signed-off-by: Himanshu <kubeboiii@users.noreply.github.com>
|
thanks for the PR -- could you also do a pass on other images in the docs (e.g. quickstart) as some of those are rendered too big to start with -- perhaps use this new component there too and set the minwidth/width so the original image doesn't render too big? |
Centralize default, compact, and large presets in mdx-image-sizes.ts. MdxFigure resolves size by pathname and src override. Addresses review feedback on slack-a2a, kmcp quickstart, and hero diagrams. Signed-off-by: Himanshu <kubeboiii@users.noreply.github.com>
|
@peterj Addressed the sizing feedback in ed2d259.
Updated the PR description with the sizing notes. Let me know if any page still needs tuning. |
|
@kubeboiii We just migrated the docs to use Hugo instead, so this functionality won't affect the rendering of images in docs now. I opened an issue to add the functionality to the Hugo theme we use for the docs separately. This feature could still apply to blogs though. To change the scope of this PR, drop the |
Closes #362
Summary
Adds click-to-expand for images in docs and blog MDX. Markdown images route through
MdxFigure, which renders a clickable thumbnail and opens a dialog with a larger view of the same file. Two doc/blog pages that used raw<img>tags now useMdxFigureor markdown image syntax so they get the same behavior.After review feedback, inline images also use a central size config (
default,compact,large) so screenshots render smaller in the prose column. Click still opens the full image in the lightbox.Changes
src/components/mdx/mdx-figure.tsx: Client component withnext/imagethumbnail, optionalfigcaptionfrom markdown title, lazy-loaded lightbox (next/dynamic,ssr: false),aria-label/ dialog attributes. Optionalstyle/classNameapply to<figure>for page-specific layout. Resolves inline size viausePathname()and config; figures usemx-auto.src/config/mdx-image-sizes.ts: Presets (default75%/800px max,compact65%/640px,large90%/960px).PAGE_IMAGE_SIZESfor/docs/kagent/examples/slack-a2a(compact) and/docs/kmcp/quickstart(large).IMAGE_SIZE_BY_SRCfor slack and discord hero PNGs (large).src/components/mdx/mdx-figure-lightbox.tsx: Radix dialog; native<img>with viewport max dimensions;DialogContentusesw-autoso the modal fits the image.src/components/ui/dialog.tsx: shadcn dialog primitive.package.json:@radix-ui/react-dialog.src/mdx-components.tsx:imgmaps to<MdxFigure />; exportMdxFigurefor explicit MDX use.src/app/docs/kagent/examples/telegram-bot/page.mdx: Replace two<img>elements with<MdxFigure />(width: 55%/minWidth: 300pxandwidth: 50%/minWidth: 280pxon<figure>).src/blogContent/kagent-celebrating-100-days.mdx: Replace one HTML<img>with markdown.Default markdown images use the
defaultpreset (75% width, max 800px). Slack-a2a usescompact; kmcp quickstart useslarge; slack and discord hero diagrams use per-srclargeoverrides. Telegram bot keeps explicit percentage widths on<MdxFigure />. The lightbox still shows the full image on click.Also fixes MDX
imgalt:mainpassedprops.titletoImagealtinstead ofprops.alt.Out of scope
Homepage and other non-MDX images are unchanged.
Test plan
npm run lintnpm run build/docs/kagent/examples/slack-a2a: compact preset; slack hero useslargeoverride; open dialog, close with X / Escape/docs/kagent/examples/telegram-bot: GIF and architecture diagram size; open dialog on architecture image/docs/kagent/getting-started/first-agent: default preset; sample docs page/docs/kmcp/quickstart:largepreset on step screenshots; lightbox works/docs/kagent/examples/discord-a2a: discord hero diagram useslargevia src override/blog/kagent-celebrating-100-days: markdown image and dialogScreenshots
Default docs (markdown images)
Inline — default preset; image is clickable.
Lightbox — click opens dialog; image fits viewport; close with X or Escape.
Custom layout (explicit
MdxFigure)Telegram bot page — GIF (~55%) and architecture diagram (~50%) in flex layout.
Lightbox — architecture diagram enlarged in dialog.
Blog
Markdown image — same click-to-expand behavior as docs.
Inline sizing (follow-up)
Quickstart welcome wizard — default preset.
Slack workspace step — compact preset.
kmcp echo success — large preset.