-
Notifications
You must be signed in to change notification settings - Fork 556
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
lightweight dartpad embedding #2702
Comments
(cc @johnpryan) |
Yeah sorry I hadn't gotten around to this yet. I'll add some more details and background here tomorrow. |
BackgroundEmbedded DartPads were avoided or just not explored in many of the cases they would be beneficial because of a few reasons:
However being able to run snippets helps users visualize the flow of a program and can be an important pedagogical tool, or just useful to visualize the output of a collection of Flutter code. I think it would however be most helpful when learning Dart code, such as in the language documentation/tour. My discussion is focused on the One exception to this discussion are codelabs (https://dart.dev/codelabs), which are meant to be edited in most situations and use additional features such as tests, solutions, etc. This issue does not cover those use cases, as I still think they are important but best served in an integrated feature more similar to DartPad workshops. I will open a separate issue discussing this and update this with the link once that is ready. SuggestionI propose we implement lighter weight tooling that does not use the DartPad/SketchPad user interface and a library that any website can integrate with its code snippets. FunctionalityI'm not exactly sure where the cut-off should be yet, but I believe this functionality is best split into two separate pieces, with the core being a library. It would however be nice to implement further UI functionality so that each website doesn't have to hook up the library themselves. LibraryI would hope the core library has the following functionality:
User interfaceI'm not sure how much of the UI and hook-up functionality can be shared, or if any should, but I imagine a UI for this would benefit from the following functionality:
Extra: Editable snippetsWhile not necessary for this project, when learning coding it is important to be able to experiment and make changes, and understand how that affects app behavior. It would be nice to optionally enable a simple editing functionality (just syntax highlighting). If we can open a snippet in a full DartPad this wouldn't be necessary though. While I don't think this is necessary for this project if we can open the code in a full DartPad
Implementation notesThe UI portions could be implemented by each website using the built library. That may make sense as a good first step, but I worry it be a lot of repetitive work when we could share. So we could maybe introduce a customizable standard HTML web component that could be used by dart.dev, docs.flutter.dev, api.flutter.dev, and anyone in the community that wants to easily embed runnable Dart code :D
There are other options to share some of the functionality as well. Expand for an example of how this might be written.```dart runnable run-on-load lazy service="beta.api.dartpad.dev"
void main() {
print('Hello, I'm Dash!');
}
``` Might be converted to something like the following when generating the site. <dartpad-block run-on-load lazy service="beta.api.dartpad.dev">
<pre><code>
void main() {
print('Hello, I'm Dash!');
}
</pre></code>
</dartpad-block> PreviewA rough example of what this could look if integrated into dart.dev: lightweight-dartpad.movRelated worksThe following are links to an example of similar functionality in other language documentation. |
@rekire this feature is only a change to how the UI works, supporting arbitrary packages isn't something on our roadmap. |
I know I am waaay late to the party here, but is this initiative still ongoing? I am in the process of rebuilding my personal website, and would love a more "minimal" UI, for embedding/sharing my Dartpad projects. |
@devoncarew I'm taking an interest in spending more time on DartPad work. I'm not too familiar with the internals yet but if you have any concrete pointers I can take a look |
@xdega, this is not actively being working on. It is something we would generally like but I'm uncertain how it fits into our general priorities (something we'd do ourselves, something we could take the bandwidth to review, whether we could take on any maintenance costs associated with a solution here, ...).
@Levi-Lesches - great! Looking at our issues here, it doesn't look like we're tagging anything with 'good first issue' or similar. I am aware of some work we do need - we had to remove the UI we had to show dartdoc help (#3034); we would like to restore that, likely as more of a tooltips style help (tracked in #3032). I'd suggest that if you are interested in picking up anything from the issue tracker - or todos from the code? - that you start w/ a conversation in an issue. cc'ing @johnpryan and @parlough as well |
Opening this issue after a discussion with @parlough. He noted that DartPad embeddings (an embedded version of DartPad running in an iframe in another web page) is effective but heavy weight; many such embedding can slow a page down.
@parlough - can you sketch out what you were thinking wrt but a lighter-weight embedding might look like? Just a div, styled dart text, and a 'run' button that called the dartpad backend to compile?
The text was updated successfully, but these errors were encountered: