Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextra codeblocks for displaying doenet code and rendered results #228

Merged
merged 9 commits into from
Aug 5, 2024

Conversation

dqnykamp
Copy link
Member

@dqnykamp dqnykamp commented Aug 1, 2024

This PR adds the codeblocks for doenet-viewer, doenet-editor, and doenet-example to the Doenet documentation.

The codeblocks are short hand for calling <DoenetViewer>, <DoenetEditor>, and <DoenetExample>.

console.log("source for editor", JSON.stringify(source));
return (
<div className="doenet-editor-container">
<DoenetEditorOrig doenetML={source} showFormatter={showFormatter} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default view should be editor on top and rendered below, rather than side-by-side

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check with Virginia, as I thought she wanted side-by-side. At least side-by-side does switch to top-to-bottom on mobile devices/narrow screens. We can make different versions or parametrized versions to allow the author to specify.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up making a doenet-editor that is vertical and a doenet-editor-horiz that is side-by-side.

@@ -15,8 +15,7 @@ This tutorial covers a sample project in 5 parts; each part is about 5-10 minute

# Part 1: Creating a Doenet Account & Starting an Activity

<DoenetML>
{`
<DoenetViewer source={`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this isn't a triple blacktic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just being lazy as I think Virginia is going to delete this.

console.log(
"value for wrapped editor",
JSON.stringify(node.value),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to make the logs look really ugly as hundreds of examples get integrated into the docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is only there until I figure out why the newlines are disappearing. They are still here with this console.log, but then they are gone in the console.log on line 21 of packages/docs-nextra/components/doenet.tsx. It's mysterious and basically makes triple backtick doenet-editor non-functional. I'm not sure where to look for this removal of whitespace and am hoping you have ideas!

visit(tree, (node) => {
type MdxJsxFlowElement = typeof node & {
type: "mdxJsxFlowElement";
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is used in several files. I think we can put it in a types.ts and import it (that file can also import "mdast-util-mdx-jsx"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reused the original type name MdxJsxFlowElement like the previous code did. Not sure if that is a good idea.

@@ -259,7 +259,7 @@ export function DoenetViewer({
boxSizing: "border-box",
overflow: "hidden",
border: "none",
minHeight: 200,
minHeight: 50,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think the min-height was to accommodate the virtual keyboard at some point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was making the short examples take a lot of space. The virtual keyboard is outside the iframe now, so the space shouldn't be needed for that.

@siefkenj
Copy link
Contributor

siefkenj commented Aug 5, 2024

Looks good.

@dqnykamp dqnykamp merged commit f12809c into Doenet:main Aug 5, 2024
3 checks passed
@dqnykamp dqnykamp deleted the nextra-doenet-wrappers branch August 5, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants