SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
COMMER CE & MOBILE SOLUTIONS
Magento 2 Community Project
Improving state of M2 front-end
BARTEK IGIELSKI

LEAD FRONT-END DEVELOPER
„Front-end devs should
make front-end using

front-end oriented tools”
…
Yeah, that’s my „wisdom”
LESS to SASS
LESS to SASS
Enno Stuurman @SpaarneTweet
• How to simplify code and refactoring?
• How to get self-documenting code?
• How to start reusing code without letting
components influence each other?
Frontend Development Methodology
Naming convention + Styles achitecture
BEM
Block + Element + Modifier
What is BEM?
Component-based approach to web
development. The idea behind it is to divide the
user interface into independent blocks.
BEM naming convention
.block-name
.block-name__element-name
.block-name--block-modifier
.block-name__element-name--element-modifier
Block
Element
Modifier
Independent positioning
<ul>
<li>
<a>
<span></span>
</a>
</li>
</ul>
.ul {}
.ul > li {}
.ul > li > a {}
.ul > li > a > span {}
<ul class="menu">
<li class="menu__item">
<a class="menu__link">
<span class="menu__text"></span>
</a>
</li>
</ul>
.menu {}
.menu__item {}
.menu__link {}
.menu__text {}
Typical code BEMed code
Real life example
Yey, more code!
https://goo.gl/BFJwHR
magento/module-contact/view/frontend/templates/form.phtml
Our patient:
<form class="form contact"
action="<?php echo $block->escapeUrl($block->getFormAction()); ?>"
id="contact-form"
method="post"
data-hasrequired="<?php echo $block->escapeHtmlAttr(__('* Required Fields')) ?>"
data-mage-init='{"validation":{}}'>
<fieldset class="fieldset">
<legend class="legend"><span><?php echo $block->escapeHtml(__('Write Us')) ?></span></legend><br />
<div class="field note no-label"><?php echo $block->escapeHtml(__('Jot us a note and we’ll get back to you as quickly as possible.')) ?></div>
<div class="field name required">
<label class="label" for="name"><span><?php echo $block->escapeHtml(__('Name')) ?></span></label>
<div class="control">
<input name="name" id="name" title="<?php echo $block->escapeHtmlAttr(__('Name')) ?>" value="<?php echo $block->escapeHtmlAttr($this->helper('MagentoContactHelperData')->getPostValue('name') ?: $this->hel
HelperData')->getUserName()) ?>" class="input-text" type="text" data-validate="{required:true}"/>
</div>
</div>
<div class="field email required">
<label class="label" for="email"><span><?php echo $block->escapeHtml(__('Email')) ?></span></label>
<div class="control">
<input name="email" id="email" title="<?php echo $block->escapeHtmlAttr(__('Email')) ?>" value="<?php echo $block->escapeHtmlAttr($this->helper('MagentoContactHelperData')->getPostValue('email') ?: $this-
ContactHelperData')->getUserEmail()) ?>" class="input-text" type="email" data-validate="{required:true, 'validate-email':true}"/>
</div>
</div>
<div class="field telephone">
<label class="label" for="telephone"><span><?php echo $block->escapeHtml(__('Phone Number')) ?></span></label>
<div class="control">
<input name="telephone" id="telephone" title="<?php echo $block->escapeHtmlAttr(__('Phone Number')) ?>" value="<?php echo $block->escapeHtmlAttr($this->helper('MagentoContactHelperData')->getPostValue('te
class="input-text" type="text" />
</div>
</div>
<div class="field comment required">
<label class="label" for="comment"><span><?php echo $block->escapeHtml(__('What’s on your mind?')) ?></span></label>
<div class="control">
<textarea name="comment" id="comment" title="<?php echo $block->escapeHtmlAttr(__('What’s on your mind?')) ?>" class="input-text" cols="5" rows="3" data-validate="{required:true}"><?php echo $block->escapeHt
>helper('MagentoContactHelperData')->getPostValue('comment')) ?></textarea>
</div>
</div>
<?php echo $block->getChildHtml('form.additional.info'); ?>
</fieldset>
<div class="actions-toolbar">
<div class="primary">
<input type="hidden" name="hideit" id="hideit" value="" />
<button type="submit" title="<?php echo $block->escapeHtmlAttr(__('Submit')) ?>" class="action submit primary">
<span><?php echo $block->escapeHtml(__('Submit')) ?></span>
</button>
</div>
</div>
</form>
Source
<?php
$_helper = $this->helper('MagentoContactHelperData');
?>
<form class="form"
id="contact-form"
action="<?= $block->escapeUrl($block->getFormAction()); ?>"
method="post"
data-hasrequired="<?= $block->escapeHtmlAttr(__('* Required Fields')) ?>"
data-mage-init='{ "validation":{} }'
>
<h2 class="form__header">
<?= $block->escapeHtml(__('Write Us')) ?>
</h2>
<p class="form__description">
<?= $block->escapeHtml(__('Jot us a note and we’ll get back to you as quickly as possible.')) ?>
</p>
<div class="form__field field">
<label class="field__label" for="name">
<?= $block->escapeHtml(__('Name')) ?>
</label>
<input class="field__input"
name="name"
id="name"
title="<?= $block->escapeHtmlAttr(__('Name')) ?>"
value="<?= $block->escapeHtmlAttr($_helper->getPostValue('name') ?: $_helper->getUserName()) ?>"
type="text"
data-validate="{ required:true }"
>
</div>
<div class="form__field field">
<label class="field__label" for="email">
<?= $block->escapeHtml(__('Email')) ?>
</label>
<input class="field__input"
id="email"
type="email"
name="email"
title="<?= $block->escapeHtmlAttr(__('Email')) ?>"
value="<?= $block->escapeHtmlAttr($_helper->getPostValue('email') ?: $_helper->getUserEmail()) ?>"
data-validate="{ required:true, 'validate-email':true }"
>
</div>
Refactored + formatted + BEM
<div class="form__field field">
<label class="field__label" for="telephone">
<?= $block->escapeHtml(__('Phone Number')) ?>
</label>
<input class="field__input"
name="telephone"
id="telephone"
title="<?= $block->escapeHtmlAttr(__('Phone Number')) ?>"
value="<?= $block->escapeHtmlAttr($_helper->getPostValue('telephone')) ?>"
type="text"
>
</div>
<div class="form__field field">
<label class="field__label" for="comment">
<?= $block->escapeHtml(__('What’s on your mind?')) ?>
</label>
<textarea class="field__input field__input--textarea"
id="comment"
name="comment"
title="<?= $block->escapeHtmlAttr(__('What’s on your mind?')) ?>"
cols="5"
rows="3"
data-validate="{ required:true }"
><?= $block->escapeHtml($_helper->getPostValue('comment')) ?></textarea>
</div>
<?= $block->getChildHtml('form.additional.info'); ?>
<div class="form__actions actions-toolbar">
<div class="actions-toolbar__primary">
<input class="form__hidden"
type="hidden"
name="hideit"
value=""
>
<button class="actions-toolbar__button button"
title="<?= $block->escapeHtmlAttr(__('Submit')) ?>"
type="submit"
>
<?= $block->escapeHtml(__('Submit')) ?>
</button>
</div>
</div>
</form>
Source - Refactored
HTML elements count
31 - 19
CSS Class count
36 (20 unique) - 27 (15 unique)
<form class="form contact">
<fieldset class="fieldset">
<legend class="legend">
<span></span>
</legend>
<br />
<div class="field note no-label"></div>
<div class="field name required">
<label class="label">
<span></span>
</label>
<div class="control">
<input class="input-text"/>
</div>
</div>
<div class="field email required">
<label class="label">
<span></span>
</label>
<div class="control">
<input class="input-text"/>
</div>
</div>
<div class="field telephone">
<label class="label">
<span></span>
</label>
<div class="control">
<input class="input-text" />
</div>
</div>
<div class="field comment required">
<label class="label" for="comment">
<span></span>
</label>
<div class="control">
<textarea class="input-text"></textarea>
</div>
</div>
</fieldset>
<div class="actions-toolbar">
<div class="primary">
<input />
<button class="action submit primary">
<span></span>
</button>
</div>
</div>
</form>
<form class="form">
<h2 class="form__header"></h2>
<p class="form__description"></p>
<div class="form__field field">
<label class="field__label"></label>
<input class="field__input">
</div>
<div class="form__field field">
<label class="field__label"></label>
<input class="field__input">
</div>
<div class="form__field field">
<label class="field__label"></label>
<input class="field__input">
</div>
<div class="form__field field">
<label class="field__label"></label>
<textarea class="field__input field__input--textarea"></textarea>
</div>
<div class="form__actions actions-toolbar">
<div class="actions-toolbar__primary">
<input class="form__hidden">
<button class="actions-toolbar__button button"></button>
</div>
</div>
</form>
<form class="form contact">
<fieldset class="fieldset">
<legend class="legend">
<span></span>
</legend>
<br />
<div class="field note no-label"></div>
<div class="field name required">
<label class="label">
<span></span>
</label>
<div class="control">
<input class="input-text"/>
</div>
</div>
<div class="field email required">
<label class="label">
<span></span>
</label>
<div class="control">
<input class="input-text"/>
</div>
</div>
<div class="field telephone">
<label class="label">
<span></span>
</label>
<div class="control">
<input class="input-text" />
</div>
</div>
<div class="field comment required">
<label class="label" for="comment">
<span></span>
</label>
<div class="control">
<textarea class="input-text"></textarea>
</div>
</div>
</fieldset>
<div class="actions-toolbar">
<div class="primary">
<input />
<button class="action submit primary">
<span></span>
</button>
</div>
</div>
</form>
<form class="form">
<h2 class="form__header"></h2>
<p class="form__description"></p>
<div class="form__field field">
<label class="field__label"></label>
<input class="field__input">
</div>
<div class="form__field field">
<label class="field__label"></label>
<input class="field__input">
</div>
<div class="form__field field">
<label class="field__label"></label>
<input class="field__input">
</div>
<div class="form__field field">
<label class="field__label"></label>
<textarea class="field__input field__input--textarea"></textarea>
</div>
<div class="form__actions actions-toolbar">
<div class="actions-toolbar__primary">
<input class="form__hidden">
<button class="actions-toolbar__button button"></button>
</div>
</div>
</form>
Sort of…
Roadmap
Magento UI

It should to provide ready to use
components, not only set of (little bit
overcomplicated) mixins.
Rebuild „Blank” theme

Using Magento UI and our
development methodology
Improve Frontools
100% replacement of CLI methods
related to front-end work
Estimated release time…
We need some help!
Specify 3 points of pain in M2
and send them at
bartek.igielski@snow.dog
Plase be specifyc! I.e. saying just
„lack of documentation” sucks.
Specify what part of app need
(better) docs.
How to stay updated?
Twitter
@Igloczek <- it’s me :)
@SnowdogApps <- Snowdog (you don’t say!)
GitHub
https://github.com/SnowdogApps/magento2-theme-blank-sass
https://github.com/SnowdogApps/magento2-frontools
Magento Forums
https://community.magento.com/t5/Less-to-Sass-Community-Project/bd-p/less-to-sass
Q & A Time!
Let’s stay in touch:
Twitter: @igloczek
Blog: iglo.tech
bartek.igielski@snow.dog

Contenu connexe

Tendances

Tendances (20)

[ WrocLoveRb 2012] user perspective testing using ruby
[ WrocLoveRb 2012] user perspective testing using ruby[ WrocLoveRb 2012] user perspective testing using ruby
[ WrocLoveRb 2012] user perspective testing using ruby
 
Hacking Your Way to Better Security - PHP South Africa 2016
Hacking Your Way to Better Security - PHP South Africa 2016Hacking Your Way to Better Security - PHP South Africa 2016
Hacking Your Way to Better Security - PHP South Africa 2016
 
Web Security - Hands-on
Web Security - Hands-onWeb Security - Hands-on
Web Security - Hands-on
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용날로 먹는 Django admin 활용
날로 먹는 Django admin 활용
 
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
 
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
 
Hacking Your Way To Better Security
Hacking Your Way To Better SecurityHacking Your Way To Better Security
Hacking Your Way To Better Security
 
[ HackFest.pl 2012] Testing - what for and how
[ HackFest.pl 2012] Testing - what for and how[ HackFest.pl 2012] Testing - what for and how
[ HackFest.pl 2012] Testing - what for and how
 
Dig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup CairoDig Deeper into WordPress - WD Meetup Cairo
Dig Deeper into WordPress - WD Meetup Cairo
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Design strategies for AngularJS
Design strategies for AngularJSDesign strategies for AngularJS
Design strategies for AngularJS
 
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
 
Intro to Haml
Intro to HamlIntro to Haml
Intro to Haml
 
Sins Against Drupal 2
Sins Against Drupal 2Sins Against Drupal 2
Sins Against Drupal 2
 
Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web components
 
Drupal sins 2016 10-06
Drupal sins 2016 10-06Drupal sins 2016 10-06
Drupal sins 2016 10-06
 
Start your app the better way with Styled System
Start your app the better way with Styled SystemStart your app the better way with Styled System
Start your app the better way with Styled System
 
How to dynamically add remove input fields in php with jquery ajax
How to dynamically add  remove input fields in php with jquery ajaxHow to dynamically add  remove input fields in php with jquery ajax
How to dynamically add remove input fields in php with jquery ajax
 
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016
 
Hacking Your Way To Better Security - php[tek] 2016
Hacking Your Way To Better Security - php[tek] 2016Hacking Your Way To Better Security - php[tek] 2016
Hacking Your Way To Better Security - php[tek] 2016
 

Similaire à Improving state of M2 front-end - Magento 2 Community Project

Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
Anthony Montalbano
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
RORLAB
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
James Pearce
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
references
 
Who Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterWho Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniter
ciconf
 
Angular js quickstart
Angular js quickstartAngular js quickstart
Angular js quickstart
LinkMe Srl
 

Similaire à Improving state of M2 front-end - Magento 2 Community Project (20)

Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Emmet cheat-sheet
Emmet cheat-sheetEmmet cheat-sheet
Emmet cheat-sheet
 
Magento2&amp;java script (2)
Magento2&amp;java script (2)Magento2&amp;java script (2)
Magento2&amp;java script (2)
 
iWebkit
iWebkitiWebkit
iWebkit
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
 
Who Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniterWho Needs Ruby When You've Got CodeIgniter
Who Needs Ruby When You've Got CodeIgniter
 
WordCamp Praga 2015
WordCamp Praga 2015WordCamp Praga 2015
WordCamp Praga 2015
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Angular js quickstart
Angular js quickstartAngular js quickstart
Angular js quickstart
 
Vue.js - zastosowanie i budowa komponentów
Vue.js - zastosowanie i budowa komponentówVue.js - zastosowanie i budowa komponentów
Vue.js - zastosowanie i budowa komponentów
 
Slimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en TruuksSlimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en Truuks
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Improving state of M2 front-end - Magento 2 Community Project

  • 1. COMMER CE & MOBILE SOLUTIONS Magento 2 Community Project Improving state of M2 front-end BARTEK IGIELSKI
 LEAD FRONT-END DEVELOPER
  • 2. „Front-end devs should make front-end using
 front-end oriented tools” … Yeah, that’s my „wisdom”
  • 4. LESS to SASS Enno Stuurman @SpaarneTweet
  • 5. • How to simplify code and refactoring? • How to get self-documenting code? • How to start reusing code without letting components influence each other?
  • 6. Frontend Development Methodology Naming convention + Styles achitecture
  • 7. BEM Block + Element + Modifier
  • 8. What is BEM? Component-based approach to web development. The idea behind it is to divide the user interface into independent blocks.
  • 10. Block
  • 14. <ul> <li> <a> <span></span> </a> </li> </ul> .ul {} .ul > li {} .ul > li > a {} .ul > li > a > span {} <ul class="menu"> <li class="menu__item"> <a class="menu__link"> <span class="menu__text"></span> </a> </li> </ul> .menu {} .menu__item {} .menu__link {} .menu__text {} Typical code BEMed code
  • 17. <form class="form contact" action="<?php echo $block->escapeUrl($block->getFormAction()); ?>" id="contact-form" method="post" data-hasrequired="<?php echo $block->escapeHtmlAttr(__('* Required Fields')) ?>" data-mage-init='{"validation":{}}'> <fieldset class="fieldset"> <legend class="legend"><span><?php echo $block->escapeHtml(__('Write Us')) ?></span></legend><br /> <div class="field note no-label"><?php echo $block->escapeHtml(__('Jot us a note and we’ll get back to you as quickly as possible.')) ?></div> <div class="field name required"> <label class="label" for="name"><span><?php echo $block->escapeHtml(__('Name')) ?></span></label> <div class="control"> <input name="name" id="name" title="<?php echo $block->escapeHtmlAttr(__('Name')) ?>" value="<?php echo $block->escapeHtmlAttr($this->helper('MagentoContactHelperData')->getPostValue('name') ?: $this->hel HelperData')->getUserName()) ?>" class="input-text" type="text" data-validate="{required:true}"/> </div> </div> <div class="field email required"> <label class="label" for="email"><span><?php echo $block->escapeHtml(__('Email')) ?></span></label> <div class="control"> <input name="email" id="email" title="<?php echo $block->escapeHtmlAttr(__('Email')) ?>" value="<?php echo $block->escapeHtmlAttr($this->helper('MagentoContactHelperData')->getPostValue('email') ?: $this- ContactHelperData')->getUserEmail()) ?>" class="input-text" type="email" data-validate="{required:true, 'validate-email':true}"/> </div> </div> <div class="field telephone"> <label class="label" for="telephone"><span><?php echo $block->escapeHtml(__('Phone Number')) ?></span></label> <div class="control"> <input name="telephone" id="telephone" title="<?php echo $block->escapeHtmlAttr(__('Phone Number')) ?>" value="<?php echo $block->escapeHtmlAttr($this->helper('MagentoContactHelperData')->getPostValue('te class="input-text" type="text" /> </div> </div> <div class="field comment required"> <label class="label" for="comment"><span><?php echo $block->escapeHtml(__('What’s on your mind?')) ?></span></label> <div class="control"> <textarea name="comment" id="comment" title="<?php echo $block->escapeHtmlAttr(__('What’s on your mind?')) ?>" class="input-text" cols="5" rows="3" data-validate="{required:true}"><?php echo $block->escapeHt >helper('MagentoContactHelperData')->getPostValue('comment')) ?></textarea> </div> </div> <?php echo $block->getChildHtml('form.additional.info'); ?> </fieldset> <div class="actions-toolbar"> <div class="primary"> <input type="hidden" name="hideit" id="hideit" value="" /> <button type="submit" title="<?php echo $block->escapeHtmlAttr(__('Submit')) ?>" class="action submit primary"> <span><?php echo $block->escapeHtml(__('Submit')) ?></span> </button> </div> </div> </form> Source
  • 18. <?php $_helper = $this->helper('MagentoContactHelperData'); ?> <form class="form" id="contact-form" action="<?= $block->escapeUrl($block->getFormAction()); ?>" method="post" data-hasrequired="<?= $block->escapeHtmlAttr(__('* Required Fields')) ?>" data-mage-init='{ "validation":{} }' > <h2 class="form__header"> <?= $block->escapeHtml(__('Write Us')) ?> </h2> <p class="form__description"> <?= $block->escapeHtml(__('Jot us a note and we’ll get back to you as quickly as possible.')) ?> </p> <div class="form__field field"> <label class="field__label" for="name"> <?= $block->escapeHtml(__('Name')) ?> </label> <input class="field__input" name="name" id="name" title="<?= $block->escapeHtmlAttr(__('Name')) ?>" value="<?= $block->escapeHtmlAttr($_helper->getPostValue('name') ?: $_helper->getUserName()) ?>" type="text" data-validate="{ required:true }" > </div> <div class="form__field field"> <label class="field__label" for="email"> <?= $block->escapeHtml(__('Email')) ?> </label> <input class="field__input" id="email" type="email" name="email" title="<?= $block->escapeHtmlAttr(__('Email')) ?>" value="<?= $block->escapeHtmlAttr($_helper->getPostValue('email') ?: $_helper->getUserEmail()) ?>" data-validate="{ required:true, 'validate-email':true }" > </div> Refactored + formatted + BEM <div class="form__field field"> <label class="field__label" for="telephone"> <?= $block->escapeHtml(__('Phone Number')) ?> </label> <input class="field__input" name="telephone" id="telephone" title="<?= $block->escapeHtmlAttr(__('Phone Number')) ?>" value="<?= $block->escapeHtmlAttr($_helper->getPostValue('telephone')) ?>" type="text" > </div> <div class="form__field field"> <label class="field__label" for="comment"> <?= $block->escapeHtml(__('What’s on your mind?')) ?> </label> <textarea class="field__input field__input--textarea" id="comment" name="comment" title="<?= $block->escapeHtmlAttr(__('What’s on your mind?')) ?>" cols="5" rows="3" data-validate="{ required:true }" ><?= $block->escapeHtml($_helper->getPostValue('comment')) ?></textarea> </div> <?= $block->getChildHtml('form.additional.info'); ?> <div class="form__actions actions-toolbar"> <div class="actions-toolbar__primary"> <input class="form__hidden" type="hidden" name="hideit" value="" > <button class="actions-toolbar__button button" title="<?= $block->escapeHtmlAttr(__('Submit')) ?>" type="submit" > <?= $block->escapeHtml(__('Submit')) ?> </button> </div> </div> </form>
  • 19. Source - Refactored HTML elements count 31 - 19 CSS Class count 36 (20 unique) - 27 (15 unique)
  • 20. <form class="form contact"> <fieldset class="fieldset"> <legend class="legend"> <span></span> </legend> <br /> <div class="field note no-label"></div> <div class="field name required"> <label class="label"> <span></span> </label> <div class="control"> <input class="input-text"/> </div> </div> <div class="field email required"> <label class="label"> <span></span> </label> <div class="control"> <input class="input-text"/> </div> </div> <div class="field telephone"> <label class="label"> <span></span> </label> <div class="control"> <input class="input-text" /> </div> </div> <div class="field comment required"> <label class="label" for="comment"> <span></span> </label> <div class="control"> <textarea class="input-text"></textarea> </div> </div> </fieldset> <div class="actions-toolbar"> <div class="primary"> <input /> <button class="action submit primary"> <span></span> </button> </div> </div> </form> <form class="form"> <h2 class="form__header"></h2> <p class="form__description"></p> <div class="form__field field"> <label class="field__label"></label> <input class="field__input"> </div> <div class="form__field field"> <label class="field__label"></label> <input class="field__input"> </div> <div class="form__field field"> <label class="field__label"></label> <input class="field__input"> </div> <div class="form__field field"> <label class="field__label"></label> <textarea class="field__input field__input--textarea"></textarea> </div> <div class="form__actions actions-toolbar"> <div class="actions-toolbar__primary"> <input class="form__hidden"> <button class="actions-toolbar__button button"></button> </div> </div> </form>
  • 21. <form class="form contact"> <fieldset class="fieldset"> <legend class="legend"> <span></span> </legend> <br /> <div class="field note no-label"></div> <div class="field name required"> <label class="label"> <span></span> </label> <div class="control"> <input class="input-text"/> </div> </div> <div class="field email required"> <label class="label"> <span></span> </label> <div class="control"> <input class="input-text"/> </div> </div>
  • 22. <div class="field telephone"> <label class="label"> <span></span> </label> <div class="control"> <input class="input-text" /> </div> </div> <div class="field comment required"> <label class="label" for="comment"> <span></span> </label> <div class="control"> <textarea class="input-text"></textarea> </div> </div> </fieldset> <div class="actions-toolbar"> <div class="primary"> <input /> <button class="action submit primary"> <span></span> </button> </div> </div> </form>
  • 23. <form class="form"> <h2 class="form__header"></h2> <p class="form__description"></p> <div class="form__field field"> <label class="field__label"></label> <input class="field__input"> </div> <div class="form__field field"> <label class="field__label"></label> <input class="field__input"> </div> <div class="form__field field"> <label class="field__label"></label> <input class="field__input"> </div> <div class="form__field field"> <label class="field__label"></label> <textarea class="field__input field__input--textarea"></textarea> </div> <div class="form__actions actions-toolbar"> <div class="actions-toolbar__primary"> <input class="form__hidden"> <button class="actions-toolbar__button button"></button> </div> </div> </form>
  • 25. Magento UI
 It should to provide ready to use components, not only set of (little bit overcomplicated) mixins.
  • 26. Rebuild „Blank” theme
 Using Magento UI and our development methodology
  • 27. Improve Frontools 100% replacement of CLI methods related to front-end work
  • 29.
  • 30. We need some help! Specify 3 points of pain in M2 and send them at bartek.igielski@snow.dog Plase be specifyc! I.e. saying just „lack of documentation” sucks. Specify what part of app need (better) docs.
  • 31. How to stay updated? Twitter @Igloczek <- it’s me :) @SnowdogApps <- Snowdog (you don’t say!) GitHub https://github.com/SnowdogApps/magento2-theme-blank-sass https://github.com/SnowdogApps/magento2-frontools Magento Forums https://community.magento.com/t5/Less-to-Sass-Community-Project/bd-p/less-to-sass
  • 32. Q & A Time! Let’s stay in touch: Twitter: @igloczek Blog: iglo.tech bartek.igielski@snow.dog