Top Banner
41

Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

Apr 09, 2017

Download

Software

Nuvole
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 2: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

Page 3: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 4: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

Page 5: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 6: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

Page 12: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

./templates/views-view-fields--articles--page.html.twig

{% embed "@molecules/cards/card.twig"

with {

"url": fields.path.content,

"title": fields.title.content,

"read_more": "Read more"|t,

"card_header": fields.created.content,

}

%}

Page 13: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 14: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 15: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 16: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 17: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 18: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

Page 19: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 20: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

YAML

MY_MODULE.ui_patterns.yml MY_THEME.ui_patterns.yml

pattern

media

pattern_media

pattern-media.html.twig

Page 21: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

./themes/custom/MY_THEME/MY_THEME.ui_patterns.yml

blockquote: label: Blockquote description: Display a quote with attribution information fields: quote: type: text label: Quote preview: Life is like riding a bicycle. To keep your balance, you must keep moving. attribution: type: text label: Attribution preview: Albert Einstein

./themes/custom/MY_THEME/templates/pattern-blockquote.html.twig

<blockquote> <p>{{ quote }}</p> <footer>{{ attribution }}</footer> </blockquote>

Page 22: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 23: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

id

label description

fieldstype label description preview

blockquote:

label: Blockquote

description: Display a quote with attribution information

fields:

quote:

type: text

label: Quote

preview: Life is like riding a bicycle. To keep your balance, you must keep moving.

Page 24: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

preview

id: image

fields:

image_field:

...

preview:

theme: image

uri: http://lorempixel.com/350/250/nature/1

id: gallery

fields:

gallery_field:

...

preview:

type: pattern_preview

id: image

Page 25: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

theme hookpattern_[id]

templatepattern_[id]

use

use: "@my_module/templates/my-template.html.twig"

use: "@molecules/media/media.html.twig"

Page 26: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

.

├── templates │ └── patterns │ ├── button │ │ ├── button.ui_patterns.yml │ │ └── pattern-button.html.twig │ ├── media │ │ ├── media.ui_patterns.yml │ │ └── pattern-media.html.twig ...

│ └── pattern-jumbotron.html.twig ├── MY_THEME.info.yml └── MY_THEME.ui_patterns.yml

Page 27: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

media:

label: Media object

...

libraries:

- core/jquery.ui.autocomplete

- my_module/my_library

- local_library:

css:

component:

media1.css: {}

http://example.com/style.css: { type: external }

...

└── patterns └── media ├── media1.css ├── media.ui_patterns.yml └── pattern-media.html.twig

Page 28: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

Page 29: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 30: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 31: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

/**

* The YAML UI Pattern plugin.

*

* @UiPattern(

* id = "yaml",

* label = @Translation("YAML Pattern"),

* description = @Translation("Pattern defined using a YAML file."),

* deriver = "\Drupal\ui_patterns\Plugin\Deriver\YamlDeriver"

* )

*/

class YamlPattern extends UiPatternBase implements UiPatternInterface

...

}

Page 32: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

/**

* The Fractal UI Pattern plugin.

*

* @UiPattern(

* id = "fractal",

* label = @Translation("Fractal"),

* description = @Translation("Pattern defined using Fractal."),

* deriver = "\Drupal\ui_patterns\Plugin\Deriver\FractalDeriver"

* )

*/

class FractalPattern extends UiPatternBase implements UiPatternInterface

...

}

Page 33: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

/**

* The PatternLab plugin.

*

* @UiPattern(

* id = "pattern_lab",

* label = @Translation("PatternLab"),

* description = @Translation("Pattern defined using PatternLab."),

* deriver = "\Drupal\ui_patterns\Plugin\Deriver\PatternLabDeriver"

* )

*/

class PatternLabPattern extends UiPatternBase implements UiPatternInterface

...

}

Page 34: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

COMPONENT.ui_patterns.yml

Page 35: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 36: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

Page 37: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8
Page 38: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

ui_patterns_layouts

ui_patterns_views

ui_patterns_ds

ui_patterns_field_group

Page 39: Introducing the UI Patterns module: use atomic UI components everywhere in Drupal 8

/articles