You might not need a framework
belen@mozilla.com
UX frameworks
- A collection of HTML, CSS and (sometimes) JS pieces to put together a website
 - Most popular: Bootstrap, Foundation, etc.
 - They provide a grid, UX components, typography, etc.
 - Ideally you can just copy&paste UX bits
 

Why people use them?
- "It's quicker" belief
 - "It's best practice" belief
 - A design already implemented for you
 
Some of the problems…
- Unsemantic, bloated HTML code
 - High % of CSS rules not being used
 - Hard to override styles (they are too specific)
 - Some questionable choices made for you
 



In summary
Hard to maintain code
Is this what you'd like for your theme users?
Layouts
Grid frameworks
- Appeared because it is painful to craft a layout with 
display:float - They make you use classes like 
mobile-grid-50 - Examples: 960, etc.
 
If you just need a grid
You don't need a whole UX framework
Today: meet flexbox!
- It is easier to create layouts
 - Holy Grail layout… solved!
 - Vertical alignment… solved!
 - Sticky footer… solved!
 
Holy Grail with flexbox
<header class="main-header">Header</header>
<div class="row">
  <aside class="primary-sidebar">Sidebar (left)</aside>
  <main class="content">Main content goes here</main>
  <aside class="secondary-sidebar">Sidebar (right)</aside>
</div>
<footer class="main-footer">Footer</footer>
body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  text-align: center;
}
.row { flex: 1 1 auto; }
.main-header, .main-footer {
  flex: 0 0 auto;
}
.row { display: flex; }
.primary-sidebar, .secondary-sidebar {
  flex: 0 0 auto;
  width: 250px;
}
.content {
  flex: 1 1 auto;
  min-width: 400px;
}
Can I use it?
Caveats
- It's 1-dimensional
 - You still might need a few wrappers (i.e. 
div.row) 
But still a great alternative!
How to use it?
Tomorrow: grid!
- Like flexbox, but 2-dimensional
 - It allows you to fully define a grid to position your elements in
 
Holy Grail with grid
<header class="main-header">Header</header>
<main class="content">Main content goes here</main>
<aside class="primary-sidebar">Sidebar (left)</aside>
<aside class="secondary-sidebar">Sidebar (right)</aside>
<footer class="main-footer">Footer</footer>
body {
  height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr 250px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "h h h"
    "l c r"
    "f f f";
}
.main-header { grid-area: h; }
.main-footer { grid-area: f; }
.primary-sidebar { grid-area: l; }
.secondary-sidebar { grid-area: r; }
.content { grid-area: c; }
How to use it?
- Lots of snippets in Grid by example
 - Article at Hacks blog
 
Components
Let's re-think this
If you have a custom design…
Wouldn't it be better to implement it from scratch?
- You don't need to overwrite existing CSS
 - You won't have unused CSS
 - You will be aware of all the values being used (i.e. margins, etc.)
 
If you just need a few UI components…
- Does it make sense to add a whole framework for this?
 - Can you just grab the components you need?
 - Can you use a single, 3rd-party component?
 
If you have a big, complex project
- You are better off crafting your own style guide
 - Must-read article by Anna Debenham
 
If you feel you need a framework…
- Can you use the mixins instead?
 - You will have a more lean codebase
 - You will make your own decisions about HTML and CSS
 

