International box-sizing Awareness Day

Today, 1st Feb, is International box-sizing Awareness Day, apparently. Add it to your calendar now! :) I’m not sure how official that is, or who decided it but it’s good to have an annual reminder on some things.

The general consensus in early 2017 seems to be that the boffins got the spec wrong on this one and border-box should have been the default, so the first line in a lot of stylesheets or pre-processor files is * { box-sizing: border-box; }. The spec can’t change as it would break legacy pages’ layout so we’re stuck with this fix.

That’s fine, and I don’t believe that using the universal selector * causes any real performance issues. Browsers are fast enough and smart enough to take it in their stride. However, I do hit problems with this reset approach. Frameworks.

CSS Frameworks

I’ve recently tried moving a site which just uses custom CSS and a reset over to Bootstrap 3. Bootstrap uses box-sizing:content-box by default so you chuck in that universal selector and all hell breaks loose. I think that to work with a framework like Bootstrap you have to respect the content-box option and just apply border-box to any custom modules that need it. Basically, if you’re using the framework, use the framework, don’t half use it.

Table Cells

It’s worth noting how table cells behave. They basically have box-sizing border-box by default so padding gets applied inwards. A border between 2 cells gets centered across the cells, so if we have 2 cells with a border of width 10px between them, 5px is effectively within each cell’s width.

You can change the box-sizing property on a cell to content-box but, in short, don’t. It’s not clear how this should behave and is inconsistent across browsers.

What I Learned in 2016 (Part 2)

This is the second part of a three-part post about the new things that I picked up through the course of 2016.

I (finally) took some big steps in CSS this year, picking up some of the things I’d been putting off for a while.

Flexbox

I’d heard a lot of good things about Flexbox but having to support older browsers I’d never really bothered with it. Finally, this year, with support for older IE getting dropped I decided to dive in. It’s amazing. It can handle just about anything you would need for layouts. I’m sure there are now loads of great resources for learning it but the two I used were Wes Bos’s Flexbox.io videos and Chris Coyier’s A Complete Guide to Flexbox.

Sass

The really big one for me this year was learning Sass. I know I’ve come to this very late. I was never that keen on the idea of adding another layer of complexity for my own convenience rather than for any actual user benefit. I still don’t think it’s really needed, it’s a just a nice convenience. That said, it does make writing CSS, particularly modular CSS a lot easier. Nesting, variables and mixins make it much easier to keep things consistent and manageable. CodeSchool’s Assembling Sass course was very good.

Bootstrap

I’ve used Bootstrap on and off for a while but only recently did a course in it. It turns out that there are loads of little utility classes built in to handle all sorts of variations of the basic components. It’s well worth learning properly rather than just diving in and grabbing bits and pieces. Like with Sass I don’t think you really need a CSS framework but it can certainly speed things along nicely once you know your way around. Our friends at CodeSchool came up trumps again, Blasting Off with Bootstrap.

(Angular) Material

I didn’t go deep into this, just had a bit of a play. Angular Material is very nice and fairly easy to use but I came unstuck as I was trying to use parts of the framework within an existing page layout. It got messy pretty quickly. I think Material is a bit “all or nothing” – you use it fully or not at all.


And now for something completely different…

Being a front-end guy I rarely (never) touch the database world. Writing a request to an API is about as close as I get but recently I’ve poked about with a couple of things.

MongoDB

I liked the name. I got curious. I’ve done some stuff with SQL many moons ago so I was interested to see how a database could work without it. If you’re used to JavaScript objects and JSON it’s actually really nice to use. You just push and pull objects, query by properties, that kind of thing. I didn’t go deep into it but was very impressed. It’s very much sticking with JavaScript thinking. I think it’s got a bit of a bad reputation but I’m inclined to think that was some early teething trouble and mud sticking rather than a serious issue. Glass half full. I might be wrong.

Airtable

Another play thing. Airtable lets you build databases and views, query, filter, sort, run formulae, rollups, lookups, etc. It also gives you forms, galleries where you can show your data in a card format, calendars and a whole lot more. It’s free for the basics and is lovely to use mainly down to some very good UI design. It also has an API for sharing the data with applications.

 

More in the next part…

 

What I Learned in 2015

I thought I’d do another quick run-through of what I’ve picked up this year. It feels good to show myself that I’m still learning at a healthy pace.

SVG

I’ve started using SVG more, creating some simple charts and building dynamic graphics for use with Google Maps. I made markers or pins, which have colours and characters set dynamically according to data. I think I’ve finally got my head around the whole viewBox, which took me a while. CSS Tricks provided me with some very useful SVG tutorials and introduced me to the work of Sara Soueidan.

Angular.js

I’ve been tinkering with Angular for a while but have really got into using it day-to-day this year. I found it hard at first because it’s so different to using native JavaScript or jQuery to manipulate the DOM. In Angular you basically set conditions in the HTML, e.g. show this when the data is that, and then to make things happen you just change the data. The data changes and the UI updates. It means you’re not making data changes and UI changes – just change the data and Angular looks after the UI. Once you’ve got that it’s actually a lot easier to manage than writing an app with jQuery.

React.js

I’ve done my first project using React. This is a very clever framework for updating the UI as quickly as possible. It checks what actually needs to change on screen and only updates the HTML nodes that require a change, making the UI very fast and, well, reactive. It’s based on building components which each have their own properties and state. The component or modular approach certainly feels like the way forward for building UIs.

Jekyll

I built the previous incarnation of this website using Jekyll. It’s a static site generator. It works in much the same way as any content management system with templates and a build process but spits out static HTML so it’s faster for the user. It took a lot of setting up on Windows and involved some scary new stuff for me, like Ruby, Python and using the command line. It is an amazing bit of software for building fast sites and very flexible. Definitely worth trying. I eventually moved away from it and back to WordPress as it was just easier to update – I can update from any device anywhere without having to have the complicated local set up. As my content is mainly just text, I didn’t feel the performance gains balanced out the usability for me as an author.

Markdown

Using Jekyll also introduced me to using markdown. It’s a quick way of writing HTML without having to use tags. It keeps the content clean and easy to read, whilst containing formatting. It kind of lets you write HTML without having to break your creative flow to think about formatting. It also enables non HTML savvy authors to publish formatted content easily.

New JavaScript Syntax – EcmaScript 6

I haven’t used it yet but started reading about ES6. There are a few good introductory articles, which show off some of the new features without getting too bogged down in the details. Here’s a good basic ES6 intro. It feels like a lot to learn but it becomes evident very quickly that we’ll be able to write less code and it’ll be easier to understand. Win win.

Google Analytics Event Tracking

I’ve used Google Analytics for years but have just discovered how to use event tracking. I can now track clicks on a particular UI element to see how it’s used, check pre-defined user preferences by reading data out of the browser’s localStorage, measure download numbers for PDF documents. It’s opening the doors to a lot of previously missing data with regards to user behaviour and can help me make better decisions on designing the user experience.

Responsive Web Design

I’ve made big strides forward this year with responsive design. I’m starting, late I know, to think about it in everything I do. It’s a lot more work but leads to much more usable UIs and often forces me to keep the design simpler than I would otherwise, which is probably a good thing.

Bootstrap

I’ve actively avoided Bootstrap for the last few years. I always had 2 major concerns with it: 1) that my sites would end up looking the same as everyone else’s and 2) that I was loading up a hefty framework and then only using a fraction of it, which would be very wasteful.

A colleague reintroduced me to it and I was delighted to find that it’s now possible to create customised builds so you can choose the parts you want to include (no waste) and even set colour schemes, default padding, etc. in the build, replacing the defaults, so there’s less needed to overwrite in a custom theme.

I’ve started using it as its grid layout makes responsive design so much easier than handling each page element and I know that the ready made components and UI elements are accessible where my own might not be.

Codepen

And finally, Codepen. I’ve covered this in another post, Developing in Codepen. In short, I use it every day, it’s awesome.