docs: refactor getting-started codelab to be based on sample app#10074
docs: refactor getting-started codelab to be based on sample app#10074zspriggs wants to merge 10 commits into
Conversation
|
This also fixes RaspberryPiFoundation/blockly-samples#1752 |
maribethb
left a comment
There was a problem hiding this comment.
Sorry it's a lot of comments but overall the structure is great and I've mostly suggested some wording changes or minor reorganization!
| @@ -0,0 +1,35 @@ | |||
| /** | |||
| * @license | |||
| * Copyright 2023 Google LLC | |||
There was a problem hiding this comment.
Here and elsewhere, please update copyright to 2026 and Raspberry Pi Foundation
(old files stay as they are, but new files get new info)
There was a problem hiding this comment.
I wasn't sure whether to keep the old license since I just copied the exact same code from the sample app. It's a new file wrt this codelab, but not a new file for Blockly. Happy to update but just want to double check that's what I should do (since the same will be the case for all the other codelabs)
| For example: | ||
| - `scrollbars`: Whether to show scrollbars in the workspace. | ||
| - `horizontalLayout`: Whether to display the toolbox horizontally or vertically in the workspace. | ||
| - `toolboxPosition`: Whether to show the toolbox at the top or bottom of the workspace. |
There was a problem hiding this comment.
it's only top or bottom if we were using the horizontal layout. in this case, we're not, so this is kind of confusing. you also might want to explain the default values for these since it's not obvious horizontalLayout will be false, scrollbars will be true, etc.
There was a problem hiding this comment.
Yes good point, I fixed this! Also, taking a closer look at this this made me realize that some of the default options are different between flyout & category toolboxes. With the goal being consistency across codelabs, I think that not clarifying this could cause some confusion when someone moves on to the real sample app after this codelab and sees a trash can and scrollbars when those things weren't in the workspace in this codelab. There's a few ways I could address this but I ended up just adding a couple lines at the end of the codelab about the difference, lmk if that looks good
| - `maxBlocks`: The maximum number of blocks that may be created in the workspace. | ||
|
|
||
| The `options` struct gives you significant control over your Blockly instance. You can pass options to set Blockly's theme, modify scrolling behaviour, set the renderer, and more. For more information, head over to Blockly's developer site and check out the [configuration](/guides/configure/configuration_struct#the-options-dictionary) section. | ||
| You can also pass options to set Blockly's theme, modify scrolling behaviour, set the renderer, and more. For more information, see the [configuration](/guides/configure/configuration_struct#the-options-dictionary) documentation. |
There was a problem hiding this comment.
For people new to blockly, the theme and renderer probably don't mean anything. I would either link to the documentation for those topics, or make this more general and say you can control the appearance of blockly.
| /> | ||
|
|
||
| Drag and drop the available loop block to the workspace to test it out. | ||
| /> No newline at end of file |
There was a problem hiding this comment.
I would add some instructions to drag the blocks around so they can see it already works with basic interactions.
There was a problem hiding this comment.
Done, I also realized it might be helpful to give a shout to keyboard nav here so I added that as well
| alt="image" | ||
| className="codelabImage" | ||
| /> | ||
| Now, you'll add a custom block to the workspace. |
There was a problem hiding this comment.
I think I would add a sentence explaining why we're using custom blocks. Something like, Blockly ships with several basic blocks for writing numbers, strings, and loops. But the real power of a Blockly application comes from your custom blocks. You can define blocks that are related to your application, such as one that plays a song, makes a robot move on the screen, or reports the temperature from a connected sensor.
|
|
||
| addText('Hello, World!'); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Add a step here to register the block code generator with the javascript generator. be explicit that's what the object.assign is doing.
| ``` | ||
|
|
||
| ### The full code | ||
| ### Write the function |
There was a problem hiding this comment.
Set up code execution environment, or something more descriptive because it's not clear what "the function" is
|
|
||
| The end result should look like this: | ||
| The `runCode` function uses Blockly's javascriptGenerator to generate the code for the blocks on the workspace. | ||
| Then it displays the code in the codeDiv, resets the outputDiv, and evaluates the JavaScript code. |
There was a problem hiding this comment.
Make it clear that executing the code is the responsibility of the application. Blockly just turns blocks into code. What you do with that code is up to you. For this sample app, we'll display the code in a div, and we'll use eval to run it.
|
|
||
| Once the button behavior is defined by the user, it needs to be saved for later use. The saved code must be per button, since buttons can be programmed to play different sounds. | ||
| You now have a Blockly workspace. However, if you reload the page, you'll find that any blocks you've dragged into the workspace will disappear. | ||
| Your users likely won't want their blocks to vanish, but you can fix this by saving the state of the workspace in local browser storage. |
There was a problem hiding this comment.
nit: saving to local storage is just one way to handle storage and probably not the one most real apps would use.
Your users likely won't want their blocks to vanish, but you can fix this by saving the state of the workspace and loading it back in next time they visit the site. For this codelab, we'll save that state to local browser storage.
| *.komodoproject | ||
| /nbproject/private/ | ||
| tsdoc-metadata.json | ||
| .vscode No newline at end of file |
There was a problem hiding this comment.
nit: add the trailing newline
The basics
The details
Proposed Changes