Top Banner
COMPONENT BASED THEMING WITH UI PATTERNS PRESENTED BY BRIAN PERRY November 18, 2017
48

component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

Jun 28, 2020

Download

Documents

dariahiddleston
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: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

COMPONENT BASED THEMING WITH UI PATTERNSPRESENTED BY BRIAN PERRYNovember 18, 2017

Page 2: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS

BRIAN PERRY

• Currently living in Chicago ‘burbs

• Interactive Developer at HS2 Solutions

• Loves style guide driven development and all things Nintendo

d.o: brianperry twitter: bricomedy nintendo: wabrian

Hi!

Page 3: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS

HS2 SOLUTIONS

Pros:

• Chicago area

• Smart Drupal folks

• Always looking for more smart Drupal Folks

• Sent me here

Cons:

• People in the Midwest say ‘Pop’ instead of ‘Soda’

• Not HS1 Solutions

Totally Unapproved Company Info Slide

Page 4: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

Component Based Theming With UI Patterns

Page 5: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 5

• Creating modular and re-usable elements

• Building a design system, not a series of pages

• Can use a living style guide for documentation and prototyping

• Tools like KSS and Pattern Lab

WHAT IS IT?

COMPONENT BASED THEMING

Page 6: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 6

• Efficient re-use

• Write once, use everywhere.

• Within a single project and even across projects (beyond Drupal even)

• Well isolated chunks of code

• Decoupling front and back end development

• Theming doesn’t have to come last

• Living style guide

• Simplifies coordination between designers and developers / developers and developers.

• Rapid prototyping

WHY TAKE A COMPONENT BASED APPROACH?

COMPONENT BASED THEMING

Page 7: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

Component Based Theming With Without UI Patterns

Page 8: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 8

OUR COMPONENT

Page 9: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 9

• Everything lives inside component directory in Pattern Library

• SASS

• Twig

• JS

• Other Assets

• Pattern Data

THE COMPONENT DIRECTORY

Page 10: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 10

MARKUP AND STYLES

Page 11: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 11

paragraph--marketing-content-section.html.twig

MAPPING TO DRUPAL

Page 12: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 12

• Requires quite a bit of debugging

• Difficult for those not familiar with Twig / Render Array Structure

• Easy to get carried away / break things Drupal depends on (Quickedit, Panels IPE)

• card.twig is a black box to Drupal

IT WORKS, BUT…

PAIN POINTS

Page 13: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

Component Based Theming With UI Patterns

Page 14: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14

Define and manage components in a way that Drupal understands

UI PATTERNS MODULE

• Define UI Patterns as Drupal Plugins

• Use defined patterns with component friendly modules

• Views, field groups, panels, display suite, paragraphs (requires field layout or display suite)

• Configure data mappings in the UI

• Optional Pattern Library page exposed in Drupal

• Also allows Drupal to:

• Preprocess patterns

• Render patterns programmatically

Page 15: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 15

Page 16: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 16

UI PATTERNS LIBRARY SUBMODULE

Page 17: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 17

marketing-site-content-section.pattern.yml

DEFINING A PATTERN

Page 18: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 18

DEFINING A PATTERN

Page 19: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 19

DEFINING A PATTERN

Page 20: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 20

DEFINING A PATTERN

Page 21: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 21

pattern-marketing-site-content-section.html.twig

CAN I GET A SUGGESTION?

• If ’use:’ doesn’t make sense for you, default template suggestions exist.

• Could add your twig markup here

• Can even include/extend/embed and map data.

• Can preprocess to add additional suggestions.

• See hook_theme_suggestions_alter()

Page 22: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 22

DRUPAL PATTERN LIBRARY

Page 23: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

EXPOSING YOUR PATTERN IN DRUPAL

And now for the part that everyone gets tripped up on…

Page 24: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 24

• In 8.3 and above:

• Enable Field Layout

• Enable UI Patterns Layouts

• Begin enjoying your patterns anywhere layouts are available.

Paragraphs are common component friendly option.

EXPOSING YOUR PATTERN IN DRUPAL

INTEGRATION MODULES LOOKING FOR A PLACE TO START?

• UI Patterns Layouts – makes patterns available via Layout Discovery

• UI Patterns Views – makes patterns available as views row style

• UI Patterns Display Suite – makes patterns available as display suite field templates

• UI Patterns Field Group – makes patterns available to field groups

Page 25: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 25

CREATE PARAGRAPH TYPE

Page 26: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 26

Select your pattern from the list.

MANAGE DISPLAY: LAYOUT SETTINGS

Page 27: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 27

MAP PARAGRAPH FIELDS TO PATTERN FIELDS

Page 28: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

Beyond the Basics

Page 29: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 29

TESTIMONIAL BLOCK PATTERN

Page 30: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 30

UI PATTERNS VIEWS

Page 31: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 31

UI PATTERNS FIELD GROUP

Page 32: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 32

UI PATTERNS FIELD GROUP

Page 33: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 33

UI PATTERNS DISPLAY SUITE

Page 34: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 34

RENDER USING TWIG FUNCTION

Page 35: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 35

RENDER PATTERN PROGRAMMATICALLY

Page 36: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 36

Not yet formally supported, but…

SUB-PATTERNS

Page 37: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 37

Can use nested paragraphs for same end result

SUB-PATTERNS

Page 38: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 38

CAN RENDER PATTERNS IN YOUR PATTERN PREVIEW

Page 39: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 39

On roadmap, but twig variables may be enough in some cases

VARIANTS

Page 40: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

Workflow

Page 41: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 41

• Components begin life in Pattern Lab

• Developing components that don’t yet exist

• Smaller sub-components

• Larger scale prototyping

• Components ‘graduate’ to a UI Pattern in Drupal

• Documented both in code and in pattern library

• Predictable re-use anywhere a UI Pattern can be rendered

UI PATTERNS WITH AN EXTERNAL PATTERN LIBRARY

Page 42: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 42

• Many possible options:

• The UI / various integration modules.

• Programmatically

• Twig functions

• Pick an approach, stick to it. Document it.

INTEGRATING WITH UI PATTERNS

Page 43: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

UI Patterns in a Contributed Theme

Page 44: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 44

Exposes foundation building blocks – not opinionated about how they are used

FOUNDATION PATTERNS THEME

Page 45: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 45

Pre-packaged paragraph types to jump start the use of the theme

FOUNDATION PATTERNS CONFIGURATION MODULE

Page 46: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

Resources

Page 47: component theming ui patterns - Drupal GovCon › sites › default › files › ... · HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 14 Define and manage components in

HS2 SOLUTIONS | COMPONENT BASED THEMING WITH UI PATTERNS 47

• https://www.drupal.org/project/ui_patterns

• Links to documentation and github repo / issue queue.

• #ui_patterns on DrupalTwig Slack

• UI Patterns Talk at DrupalCon Vienna

• https://www.drupal.org/project/foundation_patterns

• Github repo / developer sandbox

RESOURCES