From c2db8fbf76c26eaa4ee3d6da7005e67fe4edfde9 Mon Sep 17 00:00:00 2001 From: Jenny Wong Date: Mon, 27 Jan 2025 17:38:59 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=98=20Add=20support=20for=20buttons=20?= =?UTF-8?q?(#521)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ref: https://github.com/2i2c-org/infrastructure/issues/5346 Add LinkOrButton renderer Co-authored-by: Angus Hollands * Updated links and add initial styling * fix: style names * lint: prettier * Remove unused class from import * Revert "Remove unused class from import" This reverts commit da3d945c9f12b2b0621ee348c91cfa97fa857774. * Revert "lint: prettier" This reverts commit efb41a5a0e0c30d32a25bd1efd3af0e2914b4043. * refactor: use class only * wip: add support for xrefs * chore: run linter * chore: add changeset * fix: use tighter check for buttons * fix: revert previous rel * Update packages/myst-to-react/src/links/index.tsx * Add buttonRole to parser * Add buttonRole * Add myst-ext-button package --------- Co-authored-by: Angus Hollands Co-authored-by: Angus Hollands Co-authored-by: Rowan Cockett --- .changeset/serious-grapes-punch.md | 6 +++ packages/myst-demo/package.json | 1 + packages/myst-demo/src/index.tsx | 15 ++++---- packages/myst-to-react/src/basic.tsx | 2 +- packages/myst-to-react/src/crossReference.tsx | 27 ++++++++++--- packages/myst-to-react/src/links/github.tsx | 14 +++++-- packages/myst-to-react/src/links/index.tsx | 38 +++++++++++++------ packages/myst-to-react/src/links/ror.tsx | 17 ++++++++- packages/myst-to-react/src/links/rrid.tsx | 9 ++++- packages/myst-to-react/src/links/wiki.tsx | 5 ++- styles/app.css | 1 + styles/button.css | 9 +++++ 12 files changed, 111 insertions(+), 33 deletions(-) create mode 100644 .changeset/serious-grapes-punch.md create mode 100644 styles/button.css diff --git a/.changeset/serious-grapes-punch.md b/.changeset/serious-grapes-punch.md new file mode 100644 index 000000000..8bd6d0843 --- /dev/null +++ b/.changeset/serious-grapes-punch.md @@ -0,0 +1,6 @@ +--- +'myst-to-react': patch +'@myst-theme/styles': patch +--- + +Render links with `button` class as buttons diff --git a/packages/myst-demo/package.json b/packages/myst-demo/package.json index 07df13e48..6cb098874 100644 --- a/packages/myst-demo/package.json +++ b/packages/myst-demo/package.json @@ -26,6 +26,7 @@ "myst-common": "^1.7.3", "myst-config": "^1.7.3", "myst-directives": "^1.5.7", + "myst-ext-button": "^0.0.0", "myst-ext-card": "^1.0.9", "myst-ext-exercise": "^1.0.8", "myst-ext-grid": "^1.0.8", diff --git a/packages/myst-demo/src/index.tsx b/packages/myst-demo/src/index.tsx index 75bd5646b..7ac0ae22d 100644 --- a/packages/myst-demo/src/index.tsx +++ b/packages/myst-demo/src/index.tsx @@ -115,6 +115,7 @@ async function parse( const { default: mystToTypst } = await import('myst-to-typst'); const { default: mystToJats } = await import('myst-to-jats').catch(() => ({ default: null })); const { mystToHtml } = await import('myst-to-html'); + const { buttonRole } = await import('myst-ext-button'); const { cardDirective } = await import('myst-ext-card'); const { gridDirective } = await import('myst-ext-grid'); const { tabDirectives } = await import('myst-ext-tabs'); @@ -131,7 +132,7 @@ async function parse( proofDirective, ...exerciseDirectives, ], - // roles: [reactiveRole], + roles: [buttonRole], vfile, }); const mdast = parseMyst(text); @@ -397,19 +398,19 @@ export function MySTRenderer({ 'relative', { 'grid grid-cols-2 gap-0 grid-rows-[3rem_1fr]': column, - 'shadow-lg rounded': !fullscreen, + 'rounded shadow-lg': !fullscreen, 'm-0': fullscreen, }, className, )} > {column && ( -
+
{demoMenu}
)} -
+
{/* The `exclude-from-outline` class is excluded from the document outline */}
@@ -464,7 +465,7 @@ export function MySTRenderer({ {previewType === 'DOCX' && (