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

Create templates in script editors #151

Merged
merged 7 commits into from
Jul 25, 2024

Conversation

magland
Copy link
Collaborator

@magland magland commented Jul 24, 2024

This builds on #150

In data.py, data.R, analysis.py... if the editor is empty, there is a LINK text hint inviting click to generate template code.

We'll want to think about what the template code should be, and whether we want to somehow link to more thorough documentation.

image

Copy link
Collaborator

@jsoules jsoules left a comment

Choose a reason for hiding this comment

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

Overall looks good, question about the hint-text content

gui/src/app/FileEditor/TextEditor.tsx Outdated Show resolved Hide resolved
Comment on lines +90 to +103
const contentOnEmpty = useMemo(() => {
const spanElement = document.createElement("span");
const t1 = document.createTextNode(
"Define a dictionary called data to update the data.json. ",
);
const a1 = document.createElement("a");
a1.onclick = () => {
setEditedFileContent(dataPyTemplate);
};
a1.textContent = "Click here to generate an example";
spanElement.appendChild(t1);
spanElement.appendChild(a1);
return spanElement;
}, [setEditedFileContent]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to do this as a React component? No worries if not, it just seems like it'd be more straightforward than having to assemble it manually.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would be nice, but I don't think it's possible.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just looked into a few options, all the supported ways of turning a JSX element into a actual DOM element are in react-dom/server and therefore don't persist the onClick in a meaningful way. Too bad

gui/src/app/pyodide/AnalysisPyFileEditor.tsx Show resolved Hide resolved
Copy link
Collaborator

@WardBrian WardBrian left a comment

Choose a reason for hiding this comment

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

I think this is great! A few wording suggestions/suggestions about the template content.

gui/src/app/pyodide/AnalysisPyFileEditor.tsx Show resolved Hide resolved
gui/src/app/pyodide/AnalysisPyFileEditor.tsx Outdated Show resolved Hide resolved
@WardBrian WardBrian linked an issue Jul 25, 2024 that may be closed by this pull request
@WardBrian WardBrian merged commit 4943eb8 into main Jul 25, 2024
2 checks passed
@WardBrian WardBrian deleted the create-templates-in-script-editors branch July 25, 2024 16:34
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.

data and analysis script examples available to user
3 participants