feat(mdx): click-to-expand images in docs and blog#379
Open
kubeboiii wants to merge 2 commits into
Open
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 <[email protected]>
Contributor
|
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 <[email protected]>
Contributor
Author
|
@peterj Addressed the sizing feedback in ed2d259.
Updated the PR description with the sizing notes. Let me know if any page still needs tuning. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.