nuvoleweb / ui_patterns

[NOTE] Development has moved to https://drupal.org/project/ui_patterns
https://drupal.org/project/ui_patterns
GNU General Public License v2.0
85 stars 56 forks source link

How to use an other pattern inside a pattern for the preview ? #360

Closed steveoriol closed 1 year ago

steveoriol commented 1 year ago

In order to use the "atomic design" system. example: use "Atoms" inside a "Molecule"

steveoriol commented 1 year ago

OK, I find it ! you can like this :

  fields:
    ....
    person:
      type: text
      label: Person
      description: Ref person.
      preview: 
        - type: pattern
          id: person
          variant: compact
          fields:
            nom: Shakespeare
            prenom: William
            photo: >
              <img src="http://placeimg.com/100/130/people">

What is the list of all available "types"?

FlorentTorregrosa commented 1 year ago

"type" in fields is just for info / documentation. In "preview" it is a renderable array, so "type" can be any renderable element your Drupal website knows. There is also a "pattern_preview" type to ease preview setup. See https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/templates/patterns/card_layout/card_layout.ui_patterns.yml