WTFE?! What the Front End

A presentation at Umbraco UK Festival in November 2019 in London, UK by Karl Tynan

Slide 1

Slide 1

  • ! > / b < # karl tynan. @karltynan wtfe?! what the front end?!

Slide 2

Slide 2

let’s get to know each other… ● senior software developer at Rock Solid Knowledge ● 16+ years working with HTML, CSS and JS ● 7+ years working with Umbraco (since v4) ● Umbraco Certified Professional ● co-organiser of umBristol meetups

Slide 3

Slide 3

do you even front end?

Slide 4

Slide 4

2019 2018 2017 2016 2015 2014 2013 2012 2011 display: flex; border-radius: 1rem; display: grid; transform: scale(1.5); position: sticky; color: var(—primary);

Slide 5

Slide 5

2010 2009 2008 2007 2006 2005 2004 2003

Slide 6

Slide 6

2010 2009 2008 2007 2006 2005 2004 <table> <img src=”spacer.gif” /> style=”color: red” 2003

<frameset> <frame> <font size=”1”> <blink>

Slide 7

Slide 7

tables <table>…</table>

Slide 8

Slide 8

! don’t use <table> for layout…

Slide 9

Slide 9

demo…

Slide 10

Slide 10

semantic html + css… <table class=”chart”> … <tr> <th class=”title”>Q1</th> <td class=”old”>£200</td> <td class=”new”>£400</td> </tr> …

Slide 11

Slide 11

lobotomized owl but .first … . amazing pun btw..

Slide 12

Slide 12

helper classes .first .last .odd .even etc…

Slide 13

Slide 13

the problem with helper classes… <ul class=”nav-menu”> <li class=”nav-item first”>…</li> <li class=”nav-item”>…</li> <li class=”nav-item”>…</li> <li class=”nav-item last”>…</li> </ul>

Slide 14

Slide 14

the problem with helper classes… .nav-item { margin-right: 1rem; } .nav-item.last { margin-right: 0; }

Slide 15

Slide 15

pseudo classes :first-child :last-child :nth-child(odd) etc…

Slide 16

Slide 16

the problem with some pseudo classes… .nav-item { margin-right: 1rem; } .nav-item:last-child { margin-right: 0; }

Slide 17

Slide 17

internet explorer did not support :last-child until IE9 wtfe?!

Slide 18

Slide 18

can we do it better?! yes, we can :not()

Slide 19

Slide 19

why not()… .nav-item:not(:last-child) { margin-right: 1rem; }

Slide 20

Slide 20

a warning on not()… .nav-item:not(:last-child) { color: red; } .nav-item { color: green; }

Slide 21

Slide 21

a warning on not()… .nav-item.not-last { // specificity of 2 color: red; } .nav-item { // specificity of 1 color: green; }

Slide 22

Slide 22

lobotomized owl +{…} Heydon Pickering: https://alistapart.com/article/axiomatic-css-and-lobotomized-owls/

Slide 23

Slide 23

demo…

Slide 24

Slide 24

owl vs child… .side-bar * + * { margin-top: 1rem; } .module-one:not(:first-child), .module-two:not(:first-child) { margin-top: 1rem; }

Slide 25

Slide 25

so you want to be a hipster dev?

Slide 26

Slide 26

dark mode @media (prefers-color-scheme: dark) { … }

Slide 27

Slide 27

demo…

Slide 28

Slide 28

turn the lights out… .side-bar { background-color: #eee; // very light grey } @media (prefers-color-scheme: dark) { .side-bar { background-color: #222; // dark grey } }

Slide 29

Slide 29

…or turn the lights on @media (prefers-color-scheme: light) { .side-bar { background-color: #eee; // very light grey } }

Slide 30

Slide 30

…or the user doesn’t care @media (prefers-color-scheme: no-preference) { .side-bar { background-color: #c00; // vibrant red } }

Slide 31

Slide 31

so hot right now…

Slide 32

Slide 32

responsible motion @media (prefers-reduced-motion: reduce) { … } MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion

Slide 33

Slide 33

prefers-reduced-motion ● media query based on user preference ● tailor animations to be more accessible ○ sensitivity, vertigo, nausea ○ remove distractions and frustrations ● works in Chrome, Opera, Safari and Firefox ● soon to be available for Edge

Slide 34

Slide 34

html dialogs <dialog>…</dialog> MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog

Slide 35

Slide 35

<dialog> ● native modals or dialogs ● say goodbye to JS plugins ● works in Chrome, Opera and Firefox (via config) ● soon to be available for Edge ● no news for Safari or iOS Safari

Slide 36

Slide 36

html datalists <datalist>…</datalist> MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist

Slide 37

Slide 37

<datalist> ● native input options… like an autocomplete ● say goodbye (again) to JS plugins ● works in Chrome, Opera, Safari and Firefox (text inputs) ● partial, buggy support in IE10+ and Edge ● fixed in next version of Edge

Slide 38

Slide 38

thank you. karl tynan. @karltynan