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

[BBT-111] Add preview example toggle #39

Merged
merged 8 commits into from
Nov 20, 2023

Conversation

g-elwell
Copy link
Member

@g-elwell g-elwell commented Nov 10, 2023

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:

  • Heading blocks and heading elements display all headings at once (style book also does this)
  • Link elements display a paragraph block with anchor links inside
  • Button elements display a core/button block
  • Caption elements display a core/image block
  • Cite elements display a core/quote block

Note: 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

  • Creates a blockPreviews file with utilities for generating the blocks to be used within each preview
  • Moves previewBlocks and setPreviewBlocks state into context so that it can be accessed and updated from anywhere
  • Adds resetPreviewBlocks function to reset the preview to the default state, also available on context
  • Updates BlocksItem and ElementItem` to display a preview toggle button when a preview is available

Steps to test

  • Navigate into a block, toggle the example icon on/off
  • Expect to see the preview switch between the block and default previews
  • Ensure the preview updates correctly when toggling between different blocks
  • Ensure the preview resets when navigating away from a block
  • Carry out the same testing on elements

Screenshots/Videos

Screen.Capture.on.2023-11-10.at.15-07-44.mov

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@g-elwell g-elwell requested review from spbuckle, chrishbite and Joe-Rouse and removed request for spbuckle and chrishbite November 10, 2023 10:39
@g-elwell g-elwell marked this pull request as draft November 10, 2023 11:02
@g-elwell g-elwell marked this pull request as ready for review November 10, 2023 11:10
@g-elwell g-elwell self-assigned this Nov 10, 2023
@g-elwell g-elwell added the enhancement New feature or request label Nov 10, 2023
Copy link
Contributor

@spbuckle spbuckle left a comment

Choose a reason for hiding this comment

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

Looking really good. Works as expected and see no glaring issues with the code.

@spbuckle spbuckle merged commit 8684574 into release/1.0.0 Nov 20, 2023
1 check passed
@g-elwell g-elwell mentioned this pull request Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants