SlideShare a Scribd company logo
FRONT-END COMPONENTS IN DRUPAL THEME. "KAIZEN" -
DRUPAL 8 THEME FROM SKILLD
DRUPALCAMP KYIV'19
Sergiy Borodylin
Skilld - Drupal front-end developer
DevCompany - Co-founder
● https://www.facebook.com/hog.seruj
● https://www.drupal.org/u/hog
Problem with Implementation BEM
components to Drupal render
Components + BEM
Patternlab
● Atoms
● Molecules
● Organisms
● Helpers
● Layouts
BEM
● Block
● Element
● Modifier
block-name__elem-name_mod-name_m
od-val
Block - main rules
● Block is fully independent
● Block can be placed in any place of the page
● Block shouldn't influence its environment, meaning you shouldn't set the
external geometry (margin) or positioning for the block.
● You also shouldn't use CSS tag or ID selectors when using BEM.
Yarn + webpack
Gulp removed
"scripts": {
"build": "cross-env ./node_modules/.bin/webpack",
"dev": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --config
webpack.config.dev.js",
"debug": "cross-env NODE_ENV=debug ./node_modules/.bin/webpack --config
webpack.config.dev.js",
"lint": "cross-env ./node_modules/.bin/run-p lint:*",
"lint-fix": "cross-env ./node_modules/.bin/run-p "lint:* --fix"",
"lint:js": "node ./node_modules/eslint/bin/eslint.js .",
"lint:css": "cross-env ./node_modules/.bin/stylelint "**/*.css"",
"lint:sass": "cross-env ./node_modules/.bin/stylelint "**/*.scss" --config
./.stylelintrc.sass.json",
"browsersync": "yarn run browser-sync start --proxy '127.0.0.1:8888' --files ./dist",
"watch": "cross-env ./node_modules/.bin/webpack -w",
"watch:bs": "cross-env NODE_ENV=development ./node_modules/.bin/run-p browsersync watch",
"icons": "svg-sprite --config ./scripts/icons/svg-sprite.json ./images/svg/*.svg",
"cc": "node ./scripts/create-component.js"
}
package.json
webpack.config.js
const glob = require('glob');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const breakpointsImporter = require('./scripts/importers/breakpoints-importer');
const options = require('./kaizen-options');
const mapFilenamesToEntries = (pattern, globOptions) =>
glob.sync(pattern, globOptions).reduce((entries, filename) => {
const [, name] = filename.match(/([^/]+) .scss$/);
return {
...entries,
[name]: filename,
};
}, {});
Stylelint
Stylelint replacing csslint in core - https://www.drupal.org/node/2868114
.stylelintrc.sass.json
{
"extends": [
"./.stylelintrc.json",
"stylelint-config-recommended-scss"
],
"rules": {
"plugin/no-browser-hacks": null,
"order/order": [
"custom-properties",
"dollar-variables",
{
"type": "at-rule",
"hasBlock": false
},
We create front-end components from
console
node ./scripts/create-component.js
? Please enter component name test_example
? What type of component? (Use arrow keys)
❯ Atom
Molecule
Organism
Template
Helper
? Create elements instead default COMPONENT__content? (y/N)
? (QUESTION PLACEHOLDER. NOT WORKING YET)Create record in *.libraries.yml?
(y/N)
? Create twig template? (y/N)
? Enter element name content
? Want to enter another element (just hit enter for YES)? No
@import '../../../init';
$name: 'a-test-example';
.#{$name},
%#{$name} {
display: inherit;
}
<div class="a-test-example">
<div class"a-test-example__content">{{ content.content }}</div>
</div>
@import 'a-test-example';
// .DRUPAL-SELECTOR {
// @extend %a-test-example;
// }
Module color and css vars
:root {
--color-1: #000;
--color-2: #b9bab9;
--color-3: #fff;
--color-4: #37B480;
--color-5: #52C998;
--color-6: #353535;
--color-7: #1b1464;
}
:root {
--color-bg: var(--color-7);
--color-text: var(--color-6);
--color-link: var(--color-3);
--color-link--hover: var(--color-4);
}
Breakpoints
theme_name.breakpoints.yml
theme_name.mobile:
label: mobile
mediaQuery: 'all and (max-width: 639px)'
weight: 0
group: name
multipliers:
- 1x
- 2x
theme_name.narrow:
label: narrow
mediaQuery: 'all and (min-width: 640px) and (max-width: 1023px)'
weight: 1
group: name
multipliers:
- 1x
- 2x
theme_name.wide:
label: wide
mediaQuery: 'all and (min-width: 1024px)'
weight: 2
group: name
multipliers:
- 1x
- 2x
@include respond-to(wide_1x) {}
Migrate from scss to post css - causes
and disadvantages
Done
● Removed sass and its dependencies.
● Moved variables to custom css props.
● Added nested plugin to make css sass like
● Added import plugin
● Added drupal custom plugin breakpoints
● Added test examples of variables/colors/breakpoints/components/nested
Things to do
● Fix linter issues After compiling.
● Rework create component task
● Check watcher and other tasks.
● Test with docker.
● Check sourcemaps generation
FRONT-END COMPONENTS IN DRUPAL THEME. "KAIZEN" - DRUPAL 8 THEME FROM SKILLD
No jQuery. ES6
You don’t need jQuery
Style guide integration
FRONT-END COMPONENTS IN DRUPAL THEME. "KAIZEN" - DRUPAL 8 THEME FROM SKILLD
FRONT-END COMPONENTS IN DRUPAL THEME. "KAIZEN" - DRUPAL 8 THEME FROM SKILLD
theme_name.components.yml
info-box:
label: Info Box
type: twig
description: Info Box
group: 02 Theme Molecules
content:
items:
- <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field
title</div><div class="m-info-box__field-content">Field content</div></div>
- <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field
title</div><div class="m-info-box__field-content">Field content</div></div>
- <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field
title</div><div class="m-info-box__field-content">Field content</div></div>
- <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field
title</div><div class="m-info-box__field-content">Field content</div></div>
modifiers:
background-one: m-info-box__title--background-1
template: /src/sass/components/molecules/info-box/m-info-box.twig
Theme for developer VS theme for
customer
Questions?

More Related Content

PDF
Joomla Custom Fields - the next level
PDF
AngularJS Basic Training
PPTX
8 things to know about theming in drupal 8
PDF
AngularJS introduction
PDF
Front End Development: The Important Parts
PDF
Customizing the Django Admin
KEY
AngularJS for designers and developers
PDF
Web Projects: From Theory To Practice
Joomla Custom Fields - the next level
AngularJS Basic Training
8 things to know about theming in drupal 8
AngularJS introduction
Front End Development: The Important Parts
Customizing the Django Admin
AngularJS for designers and developers
Web Projects: From Theory To Practice

Similar to FRONT-END COMPONENTS IN DRUPAL THEME. "KAIZEN" - DRUPAL 8 THEME FROM SKILLD (20)

PDF
Won't You Take Me to Chunk-y Town: Component-based theming and the future of...
PDF
World is changed. i feel it in the front end
KEY
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
PDF
Stop Coding and Start Clicking - Pragmatic site building in Drupal
PPTX
Web components
PPTX
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
PDF
Introduzione a Drupal
PDF
Drupaldelphia Shortcuts Cheats And Cheap Stunts
PDF
Tooling, theming, made easy
PDF
BEM It! for Brandwatch
ODP
Drupal Theme Development - DrupalCon Chicago 2011
PDF
Style Guide Driven Development: All Hail the Robot Overlords!
PDF
BEM it! Introduction to BEM methodology
PDF
Drupal 8 - Corso frontend development
PDF
Drupal 8: frontend development
PDF
Drupal Theming An Introduction
PDF
Drupal 7 Theming - Behind the scenes
PDF
Modern Front-End Development
PDF
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
PPTX
BEM methodology overview
Won't You Take Me to Chunk-y Town: Component-based theming and the future of...
World is changed. i feel it in the front end
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Stop Coding and Start Clicking - Pragmatic site building in Drupal
Web components
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Introduzione a Drupal
Drupaldelphia Shortcuts Cheats And Cheap Stunts
Tooling, theming, made easy
BEM It! for Brandwatch
Drupal Theme Development - DrupalCon Chicago 2011
Style Guide Driven Development: All Hail the Robot Overlords!
BEM it! Introduction to BEM methodology
Drupal 8 - Corso frontend development
Drupal 8: frontend development
Drupal Theming An Introduction
Drupal 7 Theming - Behind the scenes
Modern Front-End Development
Minimalist Theming: How to Build a Lean, Mean Drupal 8 Theme
BEM methodology overview
Ad

More from DrupalCamp Kyiv (20)

PDF
Speed up the site building with Drupal's Bootstrap Layout Builder
PDF
Performance Monitoring with Google Lighthouse
PPTX
Oleg Bogut - Decoupled Drupal: how to build stable solution with JSON:API, Re...
PDF
Acquia BLT for the Win, or How to speed up the project setup, development an...
PDF
Upgrading to Drupal 9
PDF
THE INTERNET OF THINGS IS GETTING REAL
PDF
DRUPAL AND ELASTICSEARCH
PDF
WHAT WE LEARNED FROM OPEN SOCIAL IN 3 YEARS, MOVING FROM AN AGENCY TO A PRODU...
PDF
Blackfire Workshop
PDF
DRUPAL 8 STORAGES OVERVIEW
PPTX
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
DOCX
1-1 MEETING: STEP-BY-STEP-HOW-TO
PPTX
UX DURING MODULE INSTALLATION AND CONFIGURATION
PDF
SWITCHING FROM QA ENGINEER TO PROJECT MANAGER - LEVEL UP OR DOWN?
PDF
TECHNOLOGIES-POWERED WEB AND THE POST-BROWSER ERA
PPTX
PROTECTED CONTENT: END-TO-END PGP ENCRYPTION FOR DRUPAL
PDF
DRUPAL AUDITS MADE FASTR
PDF
FROM DISTRO TO CUSTOM - HOW WE CREATE GREAT COMMUNITIES FOR EVERY ORGANIZATIO...
PDF
SEARCH API: TIPS AND TRICKS - FROM BEGINNING TO CUSTOM SOLUTIONS
PDF
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
Speed up the site building with Drupal's Bootstrap Layout Builder
Performance Monitoring with Google Lighthouse
Oleg Bogut - Decoupled Drupal: how to build stable solution with JSON:API, Re...
Acquia BLT for the Win, or How to speed up the project setup, development an...
Upgrading to Drupal 9
THE INTERNET OF THINGS IS GETTING REAL
DRUPAL AND ELASTICSEARCH
WHAT WE LEARNED FROM OPEN SOCIAL IN 3 YEARS, MOVING FROM AN AGENCY TO A PRODU...
Blackfire Workshop
DRUPAL 8 STORAGES OVERVIEW
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
1-1 MEETING: STEP-BY-STEP-HOW-TO
UX DURING MODULE INSTALLATION AND CONFIGURATION
SWITCHING FROM QA ENGINEER TO PROJECT MANAGER - LEVEL UP OR DOWN?
TECHNOLOGIES-POWERED WEB AND THE POST-BROWSER ERA
PROTECTED CONTENT: END-TO-END PGP ENCRYPTION FOR DRUPAL
DRUPAL AUDITS MADE FASTR
FROM DISTRO TO CUSTOM - HOW WE CREATE GREAT COMMUNITIES FOR EVERY ORGANIZATIO...
SEARCH API: TIPS AND TRICKS - FROM BEGINNING TO CUSTOM SOLUTIONS
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
Ad

Recently uploaded (20)

PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
PDF
English Language Teaching from Post-.pdf
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
Business Ethics Teaching Materials for college
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Anesthesia in Laparoscopic Surgery in India
Open Quiz Monsoon Mind Game Final Set.pptx
Revamp in MTO Odoo 18 Inventory - Odoo Slides
102 student loan defaulters named and shamed – Is someone you know on the list?
NOI Hackathon - Summer Edition - GreenThumber.pptx
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
English Language Teaching from Post-.pdf
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Cardiovascular Pharmacology for pharmacy students.pptx
Business Ethics Teaching Materials for college
Renaissance Architecture: A Journey from Faith to Humanism
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Pharma ospi slides which help in ospi learning
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Week 4 Term 3 Study Techniques revisited.pptx
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

FRONT-END COMPONENTS IN DRUPAL THEME. "KAIZEN" - DRUPAL 8 THEME FROM SKILLD

  • 1. FRONT-END COMPONENTS IN DRUPAL THEME. "KAIZEN" - DRUPAL 8 THEME FROM SKILLD DRUPALCAMP KYIV'19
  • 2. Sergiy Borodylin Skilld - Drupal front-end developer DevCompany - Co-founder ● https://www.facebook.com/hog.seruj ● https://www.drupal.org/u/hog
  • 3. Problem with Implementation BEM components to Drupal render
  • 5. Patternlab ● Atoms ● Molecules ● Organisms ● Helpers ● Layouts BEM ● Block ● Element ● Modifier block-name__elem-name_mod-name_m od-val
  • 6. Block - main rules ● Block is fully independent ● Block can be placed in any place of the page ● Block shouldn't influence its environment, meaning you shouldn't set the external geometry (margin) or positioning for the block. ● You also shouldn't use CSS tag or ID selectors when using BEM.
  • 8. "scripts": { "build": "cross-env ./node_modules/.bin/webpack", "dev": "cross-env NODE_ENV=development ./node_modules/.bin/webpack --config webpack.config.dev.js", "debug": "cross-env NODE_ENV=debug ./node_modules/.bin/webpack --config webpack.config.dev.js", "lint": "cross-env ./node_modules/.bin/run-p lint:*", "lint-fix": "cross-env ./node_modules/.bin/run-p "lint:* --fix"", "lint:js": "node ./node_modules/eslint/bin/eslint.js .", "lint:css": "cross-env ./node_modules/.bin/stylelint "**/*.css"", "lint:sass": "cross-env ./node_modules/.bin/stylelint "**/*.scss" --config ./.stylelintrc.sass.json", "browsersync": "yarn run browser-sync start --proxy '127.0.0.1:8888' --files ./dist", "watch": "cross-env ./node_modules/.bin/webpack -w", "watch:bs": "cross-env NODE_ENV=development ./node_modules/.bin/run-p browsersync watch", "icons": "svg-sprite --config ./scripts/icons/svg-sprite.json ./images/svg/*.svg", "cc": "node ./scripts/create-component.js" } package.json
  • 9. webpack.config.js const glob = require('glob'); const path = require('path'); const TerserPlugin = require('terser-webpack-plugin'); const breakpointsImporter = require('./scripts/importers/breakpoints-importer'); const options = require('./kaizen-options'); const mapFilenamesToEntries = (pattern, globOptions) => glob.sync(pattern, globOptions).reduce((entries, filename) => { const [, name] = filename.match(/([^/]+) .scss$/); return { ...entries, [name]: filename, }; }, {});
  • 11. Stylelint replacing csslint in core - https://www.drupal.org/node/2868114 .stylelintrc.sass.json { "extends": [ "./.stylelintrc.json", "stylelint-config-recommended-scss" ], "rules": { "plugin/no-browser-hacks": null, "order/order": [ "custom-properties", "dollar-variables", { "type": "at-rule", "hasBlock": false },
  • 12. We create front-end components from console
  • 13. node ./scripts/create-component.js ? Please enter component name test_example ? What type of component? (Use arrow keys) ❯ Atom Molecule Organism Template Helper ? Create elements instead default COMPONENT__content? (y/N) ? (QUESTION PLACEHOLDER. NOT WORKING YET)Create record in *.libraries.yml? (y/N) ? Create twig template? (y/N) ? Enter element name content ? Want to enter another element (just hit enter for YES)? No
  • 14. @import '../../../init'; $name: 'a-test-example'; .#{$name}, %#{$name} { display: inherit; } <div class="a-test-example"> <div class"a-test-example__content">{{ content.content }}</div> </div> @import 'a-test-example'; // .DRUPAL-SELECTOR { // @extend %a-test-example; // }
  • 15. Module color and css vars
  • 16. :root { --color-1: #000; --color-2: #b9bab9; --color-3: #fff; --color-4: #37B480; --color-5: #52C998; --color-6: #353535; --color-7: #1b1464; } :root { --color-bg: var(--color-7); --color-text: var(--color-6); --color-link: var(--color-3); --color-link--hover: var(--color-4); }
  • 18. theme_name.breakpoints.yml theme_name.mobile: label: mobile mediaQuery: 'all and (max-width: 639px)' weight: 0 group: name multipliers: - 1x - 2x theme_name.narrow: label: narrow mediaQuery: 'all and (min-width: 640px) and (max-width: 1023px)' weight: 1 group: name multipliers: - 1x - 2x theme_name.wide: label: wide mediaQuery: 'all and (min-width: 1024px)' weight: 2 group: name multipliers: - 1x - 2x @include respond-to(wide_1x) {}
  • 19. Migrate from scss to post css - causes and disadvantages
  • 20. Done ● Removed sass and its dependencies. ● Moved variables to custom css props. ● Added nested plugin to make css sass like ● Added import plugin ● Added drupal custom plugin breakpoints ● Added test examples of variables/colors/breakpoints/components/nested Things to do ● Fix linter issues After compiling. ● Rework create component task ● Check watcher and other tasks. ● Test with docker. ● Check sourcemaps generation
  • 22. No jQuery. ES6 You don’t need jQuery
  • 26. theme_name.components.yml info-box: label: Info Box type: twig description: Info Box group: 02 Theme Molecules content: items: - <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field title</div><div class="m-info-box__field-content">Field content</div></div> - <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field title</div><div class="m-info-box__field-content">Field content</div></div> - <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field title</div><div class="m-info-box__field-content">Field content</div></div> - <div class="m-info-box__field-wrapper"><div class="m-info-box__field-title">Field title</div><div class="m-info-box__field-content">Field content</div></div> modifiers: background-one: m-info-box__title--background-1 template: /src/sass/components/molecules/info-box/m-info-box.twig
  • 27. Theme for developer VS theme for customer