SlideShare a Scribd company logo
1 of 43
Download to read offline
Build tons of multi-device JavaScript applications 
... and display them on any screen! (part 2) 
(black) Magic Sizing, Positioning, Illustrating 
by Nicolas Guerrier & Ivan Berdinsky 
UA Web Challenge Kyiv 2014 – Nov 23rd 2014
JAVASCRIPT – TEMPLATING
MUSTACHE.JS 
LOGIC-LESS TEMPLATING 
Mustache is a logic-less templating 
system with many implementations 
available : C++, PHP, Ruby, Java… 
...and Javascript
MUSTACHE.JS 
FROM THE VIEW TO THE TEMPLATE 
● Mustache parses view object :
MUSTACHE.JS - VARIABLES 
● Variables are delimited with curly brackets (mustaches!)
MUSTACHE.JS - VARIABLES 
● Mustache variables can be unescaped with 3 mustaches 
or with “&” sign :
MUSTACHE.JS – SECTIONS & LISTS 
● Sections are used to render blocks of text one or more 
time, based on variable value :
MUSTACHE.JS – SECTIONS & LISTS 
● Sections using array of strings as input variables will be 
output as lists :
MUSTACHE.JS – HELPERS (FUNCTIONS) 
● CanJS Mustache implementation comes with helpers 
registration (as we have in Handlebars) 
● Register helpers to format variables output...
MUSTACHE.JS – HELPERS (FUNCTIONS) 
● … And use the helper function in template
MUSTACHE.JS – HELPERS (FUNCTIONS) 
● Why mess up with formatting in controller if you can do it 
on template layer? Keep your data clean :-)
MUSTACHE.JS – PARTIALS 
(USE WITH CAUTION) 
● Mustache JS allow the use of partials : they are used to 
render templates.. in templates :-)
MUSTACHE.JS – PARTIALS 
(USE WITH CAUTION) 
● Take care with partials : 
○ Partial templates are called on rendering. 
More templates = more load 
○ Infinite loops could kill your app (Capt’n 
Obvious sayin’)
CSS – SIZING & POSITIONING
REM UNITS
REM UNITS - WHAT IS IT? 
● REM stands for “Root EM” 
● This unit is relative to 
Document Root font size 
(in our case : <html> tag) 
● One change on <html> tag : 
all items sizes would 
change 
● Any sizing and positioning 
dimension can be set with 
that unit
REM UNITS - WHY SHOULD I USE THAT? 
After pixels, percents, ems, you may wonder why you should 
begin to use another unit? Few ideas are here : 
● Tired of famous EM’s “infinite cascading”? 
● Did you hear about responsive design? :-P 
● Do you like to write a media query for each screen ratio? 
● Do you feel comfortable with percentage sizing respecting 
ratio of your PSD (paddings, margins, should I say more?) 
● VW & VH units are not yet here… sadly 
… and the best is to come - keep listening :-)
REM UNITS – BROWSER SUPPORT 
● Global support = 90,8% 
● From IE9 
● 2 bad boys (but still popular) : IE8 & Opera Mini
REM UNITS – REMIXIN’ REM MIXIN 
● To keep compatibility with old or lightweight browsers 
that don’t support rem units, you can use the next SASS 
mixin : 
http://hugogiraudel.com/2013/03/18/ultimate-rem-mixin/ 
● This mixin accepts inputs in px or rem on any 
size/position-related css property 
● @include rem(font-size, 18px); will output pixels & rem 
declarations to insure compatibility
...AND THE JS DOES THE MAGIC
REM UNITS – AND THE JS DOES THE 
MAGIC 
● Small improvement in SASS rem mixin + a piece of JS 
bring us a perfect sizing, whatever the screen ratio 
● How? 
○ html font-size = (screen width) / 100 
○ rem mixin now accepts “design width” parameter 
○ Max & min font-size limits can be defined
REM UNITS – AND THE JS DOES THE 
MAGIC 
Ok, but - why all this? 
○ Here are few answers : 
■ You don’t need to get lost into media queries for 
your design to fit the screen (2 are usually enough : 
portrait and landscape) 
■ Declared sizes in SCSS are exactly the same as on 
PSD - easy to slice, right? 
■ SCSS stays easily readable 
■ No human calculation = no mistakes
REM UNITS – JS FONT SIZE MAGIC 
TIPS & TRICKS 
● Cordova Webview minimum font-size on Android 
○ By default, Cordova Webview has a minimum font size 
of 8px -> it prevents our script to define the root font 
size when window size is below 800px 
○ Edit 
platforms/android/CordovaLib/src/org/apache/cordova/ 
CordovaWebView.java and add in webview 
initialization :
FLUIDITY - HOW SHOULD YOUR DESIGN 
RESPOND ?
FLUIDITY - HOW SHOULD YOUR DESIGN 
RESPOND ? 
● You should think about that before writing any css line 
● You should even discuss with designer (true story ;-)) 
● Questions that may help on that : 
○ What element should strech? 
○ What element should keep the same ratio? 
○ Maybe bigger screens owners prefer to see more 
content, not bigger content :-) 
○ To which dimension, width or height, this element 
should be proportional?
FLUIDITY – REM & % 
● REM does a lot of magic but it doesn’t do everything : 
○ Percentage sizing has a real meaning for vertical 
layout sizing (regions height especially) 
○ REM sizing has a real meaning for horizontal layout 
sizing, font sizing, paddings, margins + fixed element 
sizing (when ratio can’t be changed) 
● Combine both and you’re ready to size and position 
anything (on mobile, tablet, desktop), using just 2 media 
queries! Yes Sir.
FLEXBOX MODEL 
KICK-ASS FLEXIBILITY
FLEXBOX MODEL – WHAT IS IT ? 
Evolution of layout
I LIKE BLOCKS VERTICAL-ALIGN 
line-height: 200px; 
display: table-cell; 
transform : translateY(-50%); 
margin: -15% 0 0 -25%; 
vertical-align: middle;
FLEXBOX ALIGN 
.parent-container { 
display: flex; 
justify-content: center; 
align-items: center; 
}
FLEXBOX MODEL - FEATURES 
OVERVIEW 
Flex-directions 
.container { 
flex-direction: row | row-reverse | column | column-reverse; 
}
FLEXBOX MODEL - FEATURES 
OVERVIEW 
Main axis alignment 
.container { 
justify-content: flex-start | flex-end | center | space-between | space-around; 
}
FLEXBOX MODEL - FEATURES 
OVERVIEW 
Cross axis alignment 
.container { 
align-items: flex-start | flex-end | center | baseline | stretch; 
}
FLEXBOX MODEL SPECIFICATIONS
FLEXBOX MODEL SPECIFICATIONS
FLEXBOX MODEL BROWSER SUPPORT 
Unprefixed: 65.83% 
With prefixes: 88.45%
FLEXBOX MODEL – LAST NIGHT A MIXIN 
SAVED MY LIFE 
How to support different flexbox 
browsers implementations? 
1. SASS mixin 
2. Autoprefixer CSS-postprocessor 
3. Manually
FLEXBOX MODEL – LAST NIGHT A MIXIN 
SAVED MY LIFE 
Mixin Usage 
@mixin flex-direction($value: row) { 
@if $value == row-reverse { 
-webkit-box-direction: reverse; 
-webkit-box-orient: horizontal; 
} @else if $value == column { 
-webkit-box-direction: normal; 
-webkit-box-orient: vertical; 
} @else if $value == column-reverse { 
-webkit-box-direction: reverse; 
-webkit-box-orient: vertical; 
} @else { 
-webkit-box-direction: normal; 
-webkit-box-orient: horizontal; 
} 
-webkit-flex-direction: $value; 
-moz-flex-direction: $value; 
-ms-flex-direction: $value; 
flex-direction: $value; 
} 
.container{ 
@include flex-direction(column); 
}
CSS – ILLUSTRATING
ILLUSTRATING - PNG? BASE64? SVG? 
● One small chart means more than few words :
ILLUSTRATING - PNG? BASE64? SVG? 
● Another small chart means more than few words :
THANK YOU! 
QUESTIONS?

More Related Content

What's hot

User Interface Development with Mulberry
User Interface Development with MulberryUser Interface Development with Mulberry
User Interface Development with Mulberrymrdanimal
 
Canvas
CanvasCanvas
CanvasRajon
 
React & Radium (Colin Megill)
React & Radium (Colin Megill) React & Radium (Colin Megill)
React & Radium (Colin Megill) Future Insights
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web DesignChiheb Chebbi
 
Customizer-ing Theme Options: A Visual Playground
Customizer-ing Theme Options: A Visual PlaygroundCustomizer-ing Theme Options: A Visual Playground
Customizer-ing Theme Options: A Visual PlaygroundDrewAPicture
 
Compass VS Less
Compass VS LessCompass VS Less
Compass VS LessSarah Hick
 
Front End Development - Beyond Javascript (Robin Cannon)
Front End Development - Beyond Javascript (Robin Cannon)Front End Development - Beyond Javascript (Robin Cannon)
Front End Development - Beyond Javascript (Robin Cannon)Future Insights
 
Squishy pixels
Squishy pixelsSquishy pixels
Squishy pixelsFITC
 
Interface Styling & Scripting on WebKit Mobile
Interface Styling & Scripting on WebKit MobileInterface Styling & Scripting on WebKit Mobile
Interface Styling & Scripting on WebKit MobileDavid Aurelio
 
CSS Animations & Transitions
CSS Animations & TransitionsCSS Animations & Transitions
CSS Animations & TransitionsEdward Meehan
 
Making Your Own CSS Framework
Making Your Own CSS FrameworkMaking Your Own CSS Framework
Making Your Own CSS FrameworkDan Sagisser
 
An Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 CanvasAn Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 CanvasBen Hodgson
 
HTML5 تکنولوژی های موجود در
HTML5 تکنولوژی های موجود در HTML5 تکنولوژی های موجود در
HTML5 تکنولوژی های موجود در Shiraz LUG
 
06. session 06 css color_andlayoutpropeties
06. session 06   css color_andlayoutpropeties06. session 06   css color_andlayoutpropeties
06. session 06 css color_andlayoutpropetiesPhúc Đỗ
 
Perch, Patterns and Old Browsers
Perch, Patterns and Old BrowsersPerch, Patterns and Old Browsers
Perch, Patterns and Old BrowsersRachel Andrew
 

What's hot (18)

User Interface Development with Mulberry
User Interface Development with MulberryUser Interface Development with Mulberry
User Interface Development with Mulberry
 
Fastest css3 animations
Fastest css3 animations Fastest css3 animations
Fastest css3 animations
 
Canvas
CanvasCanvas
Canvas
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
React & Radium (Colin Megill)
React & Radium (Colin Megill) React & Radium (Colin Megill)
React & Radium (Colin Megill)
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 
Customizer-ing Theme Options: A Visual Playground
Customizer-ing Theme Options: A Visual PlaygroundCustomizer-ing Theme Options: A Visual Playground
Customizer-ing Theme Options: A Visual Playground
 
Compass VS Less
Compass VS LessCompass VS Less
Compass VS Less
 
All About Sammy
All About SammyAll About Sammy
All About Sammy
 
Front End Development - Beyond Javascript (Robin Cannon)
Front End Development - Beyond Javascript (Robin Cannon)Front End Development - Beyond Javascript (Robin Cannon)
Front End Development - Beyond Javascript (Robin Cannon)
 
Squishy pixels
Squishy pixelsSquishy pixels
Squishy pixels
 
Interface Styling & Scripting on WebKit Mobile
Interface Styling & Scripting on WebKit MobileInterface Styling & Scripting on WebKit Mobile
Interface Styling & Scripting on WebKit Mobile
 
CSS Animations & Transitions
CSS Animations & TransitionsCSS Animations & Transitions
CSS Animations & Transitions
 
Making Your Own CSS Framework
Making Your Own CSS FrameworkMaking Your Own CSS Framework
Making Your Own CSS Framework
 
An Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 CanvasAn Impromptu Introduction to HTML5 Canvas
An Impromptu Introduction to HTML5 Canvas
 
HTML5 تکنولوژی های موجود در
HTML5 تکنولوژی های موجود در HTML5 تکنولوژی های موجود در
HTML5 تکنولوژی های موجود در
 
06. session 06 css color_andlayoutpropeties
06. session 06   css color_andlayoutpropeties06. session 06   css color_andlayoutpropeties
06. session 06 css color_andlayoutpropeties
 
Perch, Patterns and Old Browsers
Perch, Patterns and Old BrowsersPerch, Patterns and Old Browsers
Perch, Patterns and Old Browsers
 

Similar to Build tons of multi-device JavaScript applications - Part 2 : (black) Magic Sizing, Positioning, Illustrating

Spectrum 2015 responsive design
Spectrum 2015   responsive designSpectrum 2015   responsive design
Spectrum 2015 responsive designNeil Perlin
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty grittyMario Noble
 
Lavacon 2014 responsive design in your hat
Lavacon 2014   responsive design in your hatLavacon 2014   responsive design in your hat
Lavacon 2014 responsive design in your hatNeil Perlin
 
HTML5 apps for iOS (and probably beyond)
HTML5 apps for iOS (and probably beyond)HTML5 apps for iOS (and probably beyond)
HTML5 apps for iOS (and probably beyond)Andi Farr
 
Great Responsive-ability Web Design
Great Responsive-ability Web DesignGreat Responsive-ability Web Design
Great Responsive-ability Web DesignMike Wilcox
 
Client side performance compromises worth making
Client side performance compromises worth makingClient side performance compromises worth making
Client side performance compromises worth makingCathy Lill
 
Responsive Web Design for Drupal, CMS Expo
Responsive Web Design for Drupal, CMS ExpoResponsive Web Design for Drupal, CMS Expo
Responsive Web Design for Drupal, CMS ExpoEmma Jane Hogbin Westby
 
Responsive Web Designed for your communication and marketing needs
Responsive Web Designed for your communication and marketing needsResponsive Web Designed for your communication and marketing needs
Responsive Web Designed for your communication and marketing needsSEGIC
 
Browser sizes - November 2000
Browser sizes - November 2000Browser sizes - November 2000
Browser sizes - November 2000William Cookson
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksAndolasoft Inc
 
Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...Andreas Bovens
 
Common Project Mistakes (And How to Avoid Them)
Common Project Mistakes (And How to Avoid Them)Common Project Mistakes (And How to Avoid Them)
Common Project Mistakes (And How to Avoid Them)Inductive Automation
 
Best Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsBest Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsRapidValue
 
Stc 2015 preparing legacy projects for responsive design - technical issues
Stc 2015   preparing legacy projects for responsive design - technical issuesStc 2015   preparing legacy projects for responsive design - technical issues
Stc 2015 preparing legacy projects for responsive design - technical issuesNeil Perlin
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryAndrea Verlicchi
 

Similar to Build tons of multi-device JavaScript applications - Part 2 : (black) Magic Sizing, Positioning, Illustrating (20)

Spectrum 2015 responsive design
Spectrum 2015   responsive designSpectrum 2015   responsive design
Spectrum 2015 responsive design
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty gritty
 
Fewd week7 slides
Fewd week7 slidesFewd week7 slides
Fewd week7 slides
 
Lavacon 2014 responsive design in your hat
Lavacon 2014   responsive design in your hatLavacon 2014   responsive design in your hat
Lavacon 2014 responsive design in your hat
 
Fewd week3 slides
Fewd week3 slidesFewd week3 slides
Fewd week3 slides
 
HTML5 apps for iOS (and probably beyond)
HTML5 apps for iOS (and probably beyond)HTML5 apps for iOS (and probably beyond)
HTML5 apps for iOS (and probably beyond)
 
Web Campaign 2.pptx
Web Campaign 2.pptxWeb Campaign 2.pptx
Web Campaign 2.pptx
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
Great Responsive-ability Web Design
Great Responsive-ability Web DesignGreat Responsive-ability Web Design
Great Responsive-ability Web Design
 
Client side performance compromises worth making
Client side performance compromises worth makingClient side performance compromises worth making
Client side performance compromises worth making
 
Responsive Web Design for Drupal, CMS Expo
Responsive Web Design for Drupal, CMS ExpoResponsive Web Design for Drupal, CMS Expo
Responsive Web Design for Drupal, CMS Expo
 
Responsive Web Designed for your communication and marketing needs
Responsive Web Designed for your communication and marketing needsResponsive Web Designed for your communication and marketing needs
Responsive Web Designed for your communication and marketing needs
 
Browser sizes - November 2000
Browser sizes - November 2000Browser sizes - November 2000
Browser sizes - November 2000
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS Tricks
 
Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...Responsive design: techniques and tricks to prepare your websites for the mul...
Responsive design: techniques and tricks to prepare your websites for the mul...
 
Common Project Mistakes (And How to Avoid Them)
Common Project Mistakes (And How to Avoid Them)Common Project Mistakes (And How to Avoid Them)
Common Project Mistakes (And How to Avoid Them)
 
Best Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue SolutionsBest Practices for Android UI by RapidValue Solutions
Best Practices for Android UI by RapidValue Solutions
 
Stc 2015 preparing legacy projects for responsive design - technical issues
Stc 2015   preparing legacy projects for responsive design - technical issuesStc 2015   preparing legacy projects for responsive design - technical issues
Stc 2015 preparing legacy projects for responsive design - technical issues
 
Volunteer.rb
Volunteer.rbVolunteer.rb
Volunteer.rb
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQuery
 

More from Skilld

201910 skilld presentation-societe
201910 skilld presentation-societe201910 skilld presentation-societe
201910 skilld presentation-societeSkilld
 
Session Drupagora 2019 - Agilité dans tous ses états
Session Drupagora 2019 - Agilité dans tous ses étatsSession Drupagora 2019 - Agilité dans tous ses états
Session Drupagora 2019 - Agilité dans tous ses étatsSkilld
 
Case study : 2 applications mobiles réalisées avec Drupal
Case study : 2 applications mobiles réalisées avec DrupalCase study : 2 applications mobiles réalisées avec Drupal
Case study : 2 applications mobiles réalisées avec DrupalSkilld
 
Lviv eurodrupalcamp 2015 - drupal contributor howto
Lviv eurodrupalcamp 2015  - drupal contributor howtoLviv eurodrupalcamp 2015  - drupal contributor howto
Lviv eurodrupalcamp 2015 - drupal contributor howtoSkilld
 
Drupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptesDrupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptesSkilld
 
Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8Skilld
 
Retrospective 2013 de Drupal !
Retrospective 2013 de Drupal !Retrospective 2013 de Drupal !
Retrospective 2013 de Drupal !Skilld
 
Retrospective 2013 de la communauté Drupal 8
Retrospective 2013 de la communauté Drupal 8Retrospective 2013 de la communauté Drupal 8
Retrospective 2013 de la communauté Drupal 8Skilld
 
Drupal Camp Kiev 2012 - High Performance Drupal Web Sites
Drupal Camp Kiev 2012 - High Performance Drupal Web SitesDrupal Camp Kiev 2012 - High Performance Drupal Web Sites
Drupal Camp Kiev 2012 - High Performance Drupal Web SitesSkilld
 
Drupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances DrupalDrupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances DrupalSkilld
 
Drupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances DrupalDrupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances DrupalSkilld
 

More from Skilld (11)

201910 skilld presentation-societe
201910 skilld presentation-societe201910 skilld presentation-societe
201910 skilld presentation-societe
 
Session Drupagora 2019 - Agilité dans tous ses états
Session Drupagora 2019 - Agilité dans tous ses étatsSession Drupagora 2019 - Agilité dans tous ses états
Session Drupagora 2019 - Agilité dans tous ses états
 
Case study : 2 applications mobiles réalisées avec Drupal
Case study : 2 applications mobiles réalisées avec DrupalCase study : 2 applications mobiles réalisées avec Drupal
Case study : 2 applications mobiles réalisées avec Drupal
 
Lviv eurodrupalcamp 2015 - drupal contributor howto
Lviv eurodrupalcamp 2015  - drupal contributor howtoLviv eurodrupalcamp 2015  - drupal contributor howto
Lviv eurodrupalcamp 2015 - drupal contributor howto
 
Drupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptesDrupal, les hackers, la sécurité & les (très) grands comptes
Drupal, les hackers, la sécurité & les (très) grands comptes
 
Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8
 
Retrospective 2013 de Drupal !
Retrospective 2013 de Drupal !Retrospective 2013 de Drupal !
Retrospective 2013 de Drupal !
 
Retrospective 2013 de la communauté Drupal 8
Retrospective 2013 de la communauté Drupal 8Retrospective 2013 de la communauté Drupal 8
Retrospective 2013 de la communauté Drupal 8
 
Drupal Camp Kiev 2012 - High Performance Drupal Web Sites
Drupal Camp Kiev 2012 - High Performance Drupal Web SitesDrupal Camp Kiev 2012 - High Performance Drupal Web Sites
Drupal Camp Kiev 2012 - High Performance Drupal Web Sites
 
Drupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances DrupalDrupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances Drupal
 
Drupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances DrupalDrupagora 2012 Optimisation performances Drupal
Drupagora 2012 Optimisation performances Drupal
 

Recently uploaded

原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查ydyuyu
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdfMatthew Sinclair
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查ydyuyu
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtrahman018755
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样ayvbos
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsMonica Sydney
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxgalaxypingy
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdfMatthew Sinclair
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasDigicorns Technologies
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoilmeghakumariji156
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirtrahman018755
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsMonica Sydney
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制pxcywzqs
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfJOHNBEBONYAP1
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样ayvbos
 

Recently uploaded (20)

原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 

Build tons of multi-device JavaScript applications - Part 2 : (black) Magic Sizing, Positioning, Illustrating

  • 1. Build tons of multi-device JavaScript applications ... and display them on any screen! (part 2) (black) Magic Sizing, Positioning, Illustrating by Nicolas Guerrier & Ivan Berdinsky UA Web Challenge Kyiv 2014 – Nov 23rd 2014
  • 3. MUSTACHE.JS LOGIC-LESS TEMPLATING Mustache is a logic-less templating system with many implementations available : C++, PHP, Ruby, Java… ...and Javascript
  • 4. MUSTACHE.JS FROM THE VIEW TO THE TEMPLATE ● Mustache parses view object :
  • 5. MUSTACHE.JS - VARIABLES ● Variables are delimited with curly brackets (mustaches!)
  • 6. MUSTACHE.JS - VARIABLES ● Mustache variables can be unescaped with 3 mustaches or with “&” sign :
  • 7. MUSTACHE.JS – SECTIONS & LISTS ● Sections are used to render blocks of text one or more time, based on variable value :
  • 8. MUSTACHE.JS – SECTIONS & LISTS ● Sections using array of strings as input variables will be output as lists :
  • 9. MUSTACHE.JS – HELPERS (FUNCTIONS) ● CanJS Mustache implementation comes with helpers registration (as we have in Handlebars) ● Register helpers to format variables output...
  • 10. MUSTACHE.JS – HELPERS (FUNCTIONS) ● … And use the helper function in template
  • 11. MUSTACHE.JS – HELPERS (FUNCTIONS) ● Why mess up with formatting in controller if you can do it on template layer? Keep your data clean :-)
  • 12. MUSTACHE.JS – PARTIALS (USE WITH CAUTION) ● Mustache JS allow the use of partials : they are used to render templates.. in templates :-)
  • 13. MUSTACHE.JS – PARTIALS (USE WITH CAUTION) ● Take care with partials : ○ Partial templates are called on rendering. More templates = more load ○ Infinite loops could kill your app (Capt’n Obvious sayin’)
  • 14. CSS – SIZING & POSITIONING
  • 16. REM UNITS - WHAT IS IT? ● REM stands for “Root EM” ● This unit is relative to Document Root font size (in our case : <html> tag) ● One change on <html> tag : all items sizes would change ● Any sizing and positioning dimension can be set with that unit
  • 17. REM UNITS - WHY SHOULD I USE THAT? After pixels, percents, ems, you may wonder why you should begin to use another unit? Few ideas are here : ● Tired of famous EM’s “infinite cascading”? ● Did you hear about responsive design? :-P ● Do you like to write a media query for each screen ratio? ● Do you feel comfortable with percentage sizing respecting ratio of your PSD (paddings, margins, should I say more?) ● VW & VH units are not yet here… sadly … and the best is to come - keep listening :-)
  • 18. REM UNITS – BROWSER SUPPORT ● Global support = 90,8% ● From IE9 ● 2 bad boys (but still popular) : IE8 & Opera Mini
  • 19. REM UNITS – REMIXIN’ REM MIXIN ● To keep compatibility with old or lightweight browsers that don’t support rem units, you can use the next SASS mixin : http://hugogiraudel.com/2013/03/18/ultimate-rem-mixin/ ● This mixin accepts inputs in px or rem on any size/position-related css property ● @include rem(font-size, 18px); will output pixels & rem declarations to insure compatibility
  • 20. ...AND THE JS DOES THE MAGIC
  • 21. REM UNITS – AND THE JS DOES THE MAGIC ● Small improvement in SASS rem mixin + a piece of JS bring us a perfect sizing, whatever the screen ratio ● How? ○ html font-size = (screen width) / 100 ○ rem mixin now accepts “design width” parameter ○ Max & min font-size limits can be defined
  • 22. REM UNITS – AND THE JS DOES THE MAGIC Ok, but - why all this? ○ Here are few answers : ■ You don’t need to get lost into media queries for your design to fit the screen (2 are usually enough : portrait and landscape) ■ Declared sizes in SCSS are exactly the same as on PSD - easy to slice, right? ■ SCSS stays easily readable ■ No human calculation = no mistakes
  • 23. REM UNITS – JS FONT SIZE MAGIC TIPS & TRICKS ● Cordova Webview minimum font-size on Android ○ By default, Cordova Webview has a minimum font size of 8px -> it prevents our script to define the root font size when window size is below 800px ○ Edit platforms/android/CordovaLib/src/org/apache/cordova/ CordovaWebView.java and add in webview initialization :
  • 24. FLUIDITY - HOW SHOULD YOUR DESIGN RESPOND ?
  • 25. FLUIDITY - HOW SHOULD YOUR DESIGN RESPOND ? ● You should think about that before writing any css line ● You should even discuss with designer (true story ;-)) ● Questions that may help on that : ○ What element should strech? ○ What element should keep the same ratio? ○ Maybe bigger screens owners prefer to see more content, not bigger content :-) ○ To which dimension, width or height, this element should be proportional?
  • 26. FLUIDITY – REM & % ● REM does a lot of magic but it doesn’t do everything : ○ Percentage sizing has a real meaning for vertical layout sizing (regions height especially) ○ REM sizing has a real meaning for horizontal layout sizing, font sizing, paddings, margins + fixed element sizing (when ratio can’t be changed) ● Combine both and you’re ready to size and position anything (on mobile, tablet, desktop), using just 2 media queries! Yes Sir.
  • 27. FLEXBOX MODEL KICK-ASS FLEXIBILITY
  • 28. FLEXBOX MODEL – WHAT IS IT ? Evolution of layout
  • 29. I LIKE BLOCKS VERTICAL-ALIGN line-height: 200px; display: table-cell; transform : translateY(-50%); margin: -15% 0 0 -25%; vertical-align: middle;
  • 30. FLEXBOX ALIGN .parent-container { display: flex; justify-content: center; align-items: center; }
  • 31. FLEXBOX MODEL - FEATURES OVERVIEW Flex-directions .container { flex-direction: row | row-reverse | column | column-reverse; }
  • 32. FLEXBOX MODEL - FEATURES OVERVIEW Main axis alignment .container { justify-content: flex-start | flex-end | center | space-between | space-around; }
  • 33. FLEXBOX MODEL - FEATURES OVERVIEW Cross axis alignment .container { align-items: flex-start | flex-end | center | baseline | stretch; }
  • 36. FLEXBOX MODEL BROWSER SUPPORT Unprefixed: 65.83% With prefixes: 88.45%
  • 37.
  • 38. FLEXBOX MODEL – LAST NIGHT A MIXIN SAVED MY LIFE How to support different flexbox browsers implementations? 1. SASS mixin 2. Autoprefixer CSS-postprocessor 3. Manually
  • 39. FLEXBOX MODEL – LAST NIGHT A MIXIN SAVED MY LIFE Mixin Usage @mixin flex-direction($value: row) { @if $value == row-reverse { -webkit-box-direction: reverse; -webkit-box-orient: horizontal; } @else if $value == column { -webkit-box-direction: normal; -webkit-box-orient: vertical; } @else if $value == column-reverse { -webkit-box-direction: reverse; -webkit-box-orient: vertical; } @else { -webkit-box-direction: normal; -webkit-box-orient: horizontal; } -webkit-flex-direction: $value; -moz-flex-direction: $value; -ms-flex-direction: $value; flex-direction: $value; } .container{ @include flex-direction(column); }
  • 41. ILLUSTRATING - PNG? BASE64? SVG? ● One small chart means more than few words :
  • 42. ILLUSTRATING - PNG? BASE64? SVG? ● Another small chart means more than few words :