Skip to content

Using patterns in a block

Stephen Mustgrave edited this page Aug 6, 2024 · 1 revision

A new feature of UI Patterns 2.x is the ability to utilize patterns/components directly with Drupal's block interface.

Example

In this example we are going to create a block component creating a hero banner. See https://designsystem.digital.gov/templates/landing/ for example.

Starting on the Block layout page, select the region to place your block in. In this example we are going to place into the "hero" region.

Screenshot 2024-08-06 at 12 54 03 PM
  1. Clicking "Place block" we can see that all site components are available as individual items.
Screenshot 2024-08-06 at 12 55 25 PM
  1. Select "Hero" component
  2. The next form that loads will show all the slots and properties of the component. See https://git.drupalcode.org/project/ui_suite_uswds/-/blob/4.0.x/components/hero/hero.component.yml for reference.
Screenshot 2024-08-06 at 12 58 22 PM
  1. For this example we will use static test, so in the "Title" and "Body" field select "Wysiwyg" option and add some text.
Screenshot 2024-08-06 at 1 07 33 PM
  1. For hero banner image added https://federalist-3b6ba08e-0df4-44c9-ac73-6fc193b0e19c.sites.pages.cloud.gov/preview/uswds/uswds/develop/hero.jpg

  2. In this example I configured the block to only appear on /hero-banner-example page, which has been pre-created. So go to https://drupal-govcon-2024-ui-patterns.ddev.site/hero-banner-example and see the hero banner.

Screenshot 2024-08-06 at 1 11 14 PM

Assignment

  1. Create a "Summary box" component block
  2. Place in the "Content" region on the same page as the hero banner.