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

Block examples documentation #6560

Merged
merged 53 commits into from
Jan 6, 2025
Merged

Block examples documentation #6560

merged 53 commits into from
Jan 6, 2025

Conversation

erral
Copy link
Member

@erral erral commented Dec 30, 2024


I have reviewed the block documentation, converted some code blocks from class components to functional components, and provide an example of a simple block.


📚 Documentation preview 📚: https://volto--6560.org.readthedocs.build/

@erral erral requested a review from stevepiercy December 30, 2024 16:00
Copy link

netlify bot commented Dec 30, 2024

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit 058b4b0
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/677bbb4d721c750008c4626d

@ichim-david
Copy link
Member

Thank you for writing this @erral . It's awesome when an experienced Volto developer takes some time to pass on some of this hard-earned experience and writes some documentation. You are awesome for doing this.

I plan on giving it a read sometime this week to see if there is anything that I can help with in potential suggestions. But again, thank you for doing this.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

This is great stuff. Thank you!

I created a related PR to define Glossary terms at plone/documentation#1829, which needs to be merged before this PR to pull them into this PR's docs preview.

docs/source/blocks/examples/index.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/index.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/index.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/index.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/index.md Outdated Show resolved Hide resolved
@ichim-david
Copy link
Member

@erral once you apply @stevepiercy suggestions and you feel that the work is ready for review you can add me as a reviewer if you would like, I volunteer to read the docs and give any potential suggestions if needed.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Just a bunch of nitpicky stuff, except for changing webmaster or developer to editor. I'll merge these. Over to @ichim-david!

Also move HOC comment to narrative text to allow a term
@stevepiercy
Copy link
Collaborator

Glossary terms link now.

https://volto--6560.org.readthedocs.build/blocks/examples/custom-view-and-variations.html#view-component

According to the React docs, HOC is no longer used in modern React, so should we use them anymore?

Copy link
Member

@ichim-david ichim-david left a comment

Choose a reason for hiding this comment

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

@erral thank you again for taking the time to write these examples.

I think we are missing an example where you also define a custom edit view since we have created the view component, the schema and the schema enhancer.

What we haven't shown yet to the user is how they can also create a custom edit component.
It can also come in another pull request or added by Steve or anyone else I'm not saying it's mandatory for that example to also be created in this pull request but I think it would have been useful to have that example as well.

Again thank you for your work.


## Preparations

In your Volto add-on, create a subfolder {file}`ExampleBlock02` inside the {file}`components` folder to save all the files required to create a block.
Copy link
Member

Choose a reason for hiding this comment

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

@erral this is the first document that you have created why do we have example block 02? it makes more sense for me to start with ExampleBlock01 or simply have block1

Copy link
Member Author

Choose a reason for hiding this comment

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

wrll, this comes from examples I have written for my team. There are 6 examples, but I have brought here only 3, the most relevant ones. I have copy-pasted the code, so that's why we have 2, 5 and 6.

I haven't copied the following ones:

  • Block just with schema (automatic view and edit)
  • Custom edit component (I will add this following your suggestion)
  • Block with 'manual' variations: adding the variation field manually in the schema

docs/source/blocks/examples/custom-schema-and-view.md Outdated Show resolved Hide resolved
};
```

At the top of the file, import the relevant components as follows.
Copy link
Member

Choose a reason for hiding this comment

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

To do so, open your add-on's {file}`index.js` file, and insert the following contents.

```js
const applyConfig = (config) => {
Copy link
Member

Choose a reason for hiding this comment

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

@erral I don't think this info should be here. It has nothing to do with the example given here. I would show the contents of the index file that is created whenever you create a new add-on.
From there, I would show that we can add our configuration for the block.

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 will rewrite this, saying to add the block configuration form before the return config, that will be easier to understand.

docs/source/blocks/examples/custom-schema-and-view.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-view-and-variations.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-view-and-variations.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-view-and-variations.md Outdated Show resolved Hide resolved
@erral
Copy link
Member Author

erral commented Jan 5, 2025

Thanks @ichim-david and @stevepiercy for your comments.

I have made some modifications in the docs:

  • I have included the example with a custom edit component
  • I have renamed the examples 1,2,3,4 instead of the previous 2, 5 and 6 😅
  • I have changed the block configuration settings part. I have reworded where the configuration should be included to be clearer for the reader.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

More nitpicky stuff. I'll merge these.

docs/source/blocks/examples/custom-schema-and-view.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-view-and-variations.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-schema-view-and-edit.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-schema-view-and-edit.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-schema-view-and-edit.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-schema-view-and-edit.md Outdated Show resolved Hide resolved
docs/source/blocks/examples/custom-schema-view-and-edit.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

I'm waiting for the RTD PR preview to complete building before committing these suggestions.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

This looks great. Thank you @erral for sharing your work, and @ichim-david for the suggesstions for improvement. ✋

@ichim-david one more review from you, and if you approve, please go ahead and merge.

Copy link
Member

@ichim-david ichim-david left a comment

Choose a reason for hiding this comment

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

@erral and @stevepiercy. I built locally and the code examples look good now without any extra
overflow scrollbars and the build is passing.
Again thank you erral for this work.

@ichim-david ichim-david merged commit 6d46820 into main Jan 6, 2025
73 checks passed
@ichim-david ichim-david deleted the erral-review-docs branch January 6, 2025 11:37
@davisagli
Copy link
Member

@erral @ichim-david @stevepiercy Nice work!

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.

4 participants