Drupal 8: Twig and Component Libraries

Slides:



Advertisements
Similar presentations
Castafiore platform Consists or intend to consist of 1.Advanced Web framework 2.Advanced Graph database 3.Designer studio (something like visual basic)
Advertisements

Become a Panels Rockstar. Audience Survey Have you tried Panels? Are you a …. –Themer / Designer? –Developer / Code Junkie? –Information Architect?
DOMINATE THE THEME LAYER August 21st.. Jesper Wøldiche Rahkonen Themer / architect at Bysted. Markup Marine / Journalist / Frontend United
CSS Chained classes Julien BRAURE –
INTRO TO WEB DEVELOPMENT
The Easiest Way to Write Web Applications Jordi Sastre IT Architect, PSC May 2012.
Shows the entire path to the file, including the scheme, server name, the complete path, and the file name itself. Same idea of stating your full name,
WDV 331 Dreamweaver Applications Snippets and Libraries Items Dreamweaver CS6 Chapter 18.
Essentials of HTML Class 4 Instructor: Jeanne Hart
| imodules.com HTML Best Practices: The Key to a Successful Starts with the Template Presented by Chris Smith, Manager of Design.
Writing a Web Page. Using Frontpage FrontPage is a user-friendly WYSIWYG html editor. To begin, open the program and a new page. FrontPage is a user-friendly.
Pitch Deck Template & Assets
Model View ViewModel Architecture. MVVM Architecture components.
Panels 3 Deborah Fuzetto. Panels Allows you to create customized layouts Drag & Drop content into Panes.
From Template To Online Business Quick Build, Quick Delivery.
EGI NA3 – Web site training services University of Edinburgh (0.25 funded FTE)
Layers Data from IBM-Rational and Craig Larman’s text integrated into these slides. These are great references… Slides from these sources have been modified.
>> Introduction to CSS
TITLE GOES HERE Your Subtitle Lorem Ipsum Dolor Lorem Ipsum Dolor
TITLE GOES HERE Lorem Ipsum Dolor Your Subtitle
Google Web Toolkit Tutorial
TITLE GOES HERE Your Subtitle LOREM IPSUM LOREM IPSUM LOREM IPSUM
Slide Title LOREM IPSUM DOLOR LOREM IPSUM DOLOR LOREM IPSUM DOLOR 76%
Content Management System
Styles with Cascading Style Sheets (CSS)
TITLE GOES HERE Your Subtitle Lorem Ipsum Dolor Lorem Ipsum Dolor
IS1500: Introduction to Web Development
TITLE GOES HERE Your Subtitle LOREM IPSUM LOREM IPSUM LOREM IPSUM
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JQuery with ASP.NET.
Lecture 1: Multi-tier Architecture Overview
Objective Understand web-based digital media production methods, software, and hardware. Course Weight : 10%
TITLE GOES HERE Your Subtitle LOREM IPSUM LOREM IPSUM
TITLE GOES HERE Your Subtitle LOREM IPSUM LOREM IPSUM LOREM IPSUM
Presentation Cover Title
TITLE GOES HERE Your Subtitle STEP STEP STEP STEP
TITLE GOES HERE Your Subtitle
INFO/CSE 100, Spring 2006 Fluency in Information Technology
TITLE GOES HERE Your Subtitle LOREM IPSUM DOLOR
Pattern Libraries Leveraging Atomic Design and Pattern Lab to Develop a Living Visual Style Guide Jayson Jaynes, ITS Web Services Web Developer Mark Miller,
TITLE GOES HERE Your Subtitle Lorem Ipsum Lorem Ipsum Lorem Ipsum
Building ASP.NET Applications 2
TITLE GOES HERE Your Subtitle LOREM IPSUM DOLOR
TITLE GOES HERE Your Subtitle LOREM IPSUM DOLOR LOREM IPSUM DOLOR
Presentation Cover Title
TITLE GOES HERE YOUR TITLE Your Subtitle LOREM IPSUM DOLOR
TITLE GOES HERE C D A F B E Your Subtitle STEP STEP STEP STEP STEP
5.00 Apply procedures to organize content by using Dreamweaver. (22%)
TITLE GOES HERE Your Subtitle
TITLE GOES HERE Your Subtitle
Bootstrap Direct quote from source: bootstrap/
TITLE GOES HERE Your Subtitle
Web Programming and Design
TITLE GOES HERE Lorem Ipsum Lorem Ipsum Lorem Ipsum Your Subtitle
TITLE GOES HERE Your Subtitle LOREM IPSUM LOREM IPSUM
TITLE GOES HERE % 28% Your Subtitle
Web Programming and Design
TITLE GOES HERE 61% 76% Your Subtitle LOREM IPSUM DOLOR
A B C D TITLE GOES HERE Your Subtitle LOREM IPSUM DOLOR LOREM IPSUM
TITLE GOES HERE Your Subtitle LOREM IPSUM DOLOR
Business Flat General Ppt Template LOGO
TITLE GOES HERE Your Subtitle LOREM IPSUM LOREM IPSUM LOREM IPSUM
Include your personal presentation if necessary.
SageFox PowerPoint Slide
Lorem ipsum NAME OF PRESENTATION Click to add subtitle
PRESENTATION TITLE Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ultrices posuere sapien
TITLE GOES HERE Your Subtitle LOREM IPSUM DOLOR
CUSTOMER JOURNEY MAP FOR POWERPOINT
TITLE GOES HERE Your Subtitle Lorem Ipsum Lorem Ipsum Lorem Ipsum
TITLE GOES HERE Your Subtitle $12,832 $13,832
Presentation transcript:

Drupal 8: Twig and Component Libraries Making Frontend developer lives’ better.

Justin Langley Senior Developer at Code Koalas. Drupal ⅞ sites. I could talk with you about D&D 5e for 8 hours straight.

The Problem Front end developer waiting on the back end architect.

The Hero Utilizing the Components Library and UI Patterns!

Component Libraries A “component library” is essentially a repository of reusable pieces of HTML. In Drupal 8, these are just small Twig templates. With a component library you have a self documenting repository of all the design elements on your site. You can break a design down into “components” and then after implementing those components; you are nearly done styling your entire site. And then in the future, when adding new content types/views/blocks to your site you can reuse these components. Or even create new components! No need to apply a entirely new suite of styles for particular pages, you can simply reuse what you already made!

Component Libraries - The Good and the Bad

Component Libraries - The Good Defined set of components reusable throughout the site. Styles and javascript are co-located with components - makes it easy for new developer to find code. CSS styles are loaded on a component-based need; no more 10000+ line CSS file that gets loaded for every page. Changing/updating components easily applies changes across the entire site; notice the background color of the Card is wrong? Update the component itself and all pages using it get the changes.

Component Libraries - The Bad Takes more time at the beginning of the project to define the “components” from designs; some are easier than others. Requires time for a developer to learn/understand. If the component architecture is not clearly defined it can become a “time suck”. Some of the “cons” of component libraries aren’t necessarily tied to the actual implementation of the component library; more or less tied to the idea of doing something new/different. New structures/libraries/technology always requires time to use effectively, think of it like a time-based deposit with huge returns!

Why use a component library? Concurrent work Self documenting Updates are consistent Less time spent styling Less prone to visual regression Easier testability An example of a Drupalism a front-end developer might benefit from know is regarding images: in their component they can simply expect an image “element” and render it. They won’t need to map values for image URLs, image alts, etc etc.

The module that makes this all possible! Components The module that makes this all possible!

Components Module You can get the module at https://www.drupal.org/project/components It add a simple functionality; you can define new Twig namespaces that Drupal is aware of.

Lorem ipsum dolor sit consectetur amet adipiscing donec my_theme_name.info.yml Lorem ipsum dolor sit consectetur amet adipiscing donec Inside the theme *.info.yml file is where you can define the directories where Drupal is aware of *.twig files. This is powerful because you use any directory structure you want inside your theme.

card.twig

node--event--card.html.twig

Drupal Templates as “Data Mappers” The principle is to treat Drupal entity templates as a data repository which you then map to values in a component. This helps separate the “logic” from the “display” of an entity.

Bonus Round!

UI Patterns Module

UI Patterns with Components From the module page: “Define and expose self-contained UI patterns as Drupal plugins and use them seamlessly as drop-in templates for panels, field groups, views, Display Suite field templates, paragraphs, nodes or any other entity types. The module generates a pattern library page to be used as documentation for content editors or as a showcase for business and clients.” For Drupal 8.2 or lower: Use UI Patterns 1.0-beta6. For Drupal 8.3 or higher: Use UI Patterns 1.0-beta7 or higher.

card.ui_patterns.yml

Here is an example of the patterns page with some patterns I created Here is an example of the patterns page with some patterns I created. Obviously a little styling was added.

Thanks! Questions?