[BBT-111] Add preview example toggle #39
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes BBT-111 - Adds the ability to preview the styles of a specific block or element when you have navigated to it.
The preview blocks for most blocks are created based on the "example" defined during block registration, which is the approach used in the core style book, but in some cases customised preview blocks are used:
core/button
blockcore/image
blockcore/quote
blockNote: not all core blocks have examples registered. However, I expect more to be added over time. If desired, we can populate this with our own examples to gain full coverage.
Rather than switching the preview automatically, I've added a visibility button to toggle this on/off. However, I have also ensured that the preview resets to it's default state when navigating away from a block or element into another area.
Change Log
blockPreviews
file with utilities for generating the blocks to be used within each previewpreviewBlocks
andsetPreviewBlocks
state into context so that it can be accessed and updated from anywhereresetPreviewBlocks
function to reset the preview to the default state, also available on contextBlocksItem
and ElementItem` to display a preview toggle button when a preview is availableSteps to test
Screenshots/Videos
Screen.Capture.on.2023-11-10.at.15-07-44.mov
Checklist: