Words by Tobias Ahlin

@tobiasahlin @tobiasahlin

CSS Trick

Animating Link Underlines

I recently added a simple visual effect to this blog that I quickly fell in love with: when you hover blog headers, the link's underline is revealed by animating it out from the center. You can try it in the banner above.

Creating this effect is surprisingly easy, doesn't require any additional DOM elements to be added through HTML, and falls back nicely for browsers that don't support CSS animations (it will just show up as a regular underline).

The first thing we need to do is turn off text-decoration, and set the link's position to relative. For simplicitiy's sake, we'll also make sure the link doesn't change color on hover. Here we're applying the effect to all link elements inside h2s:

h2 > a {
  position: relative;
  color: #000;
  text-decoration: none;
}

h2 > a:hover {
  color: #000;
}

Next, we want to add the border, and hide it through a transformation. We do this by inserting it with :before, and setting its X scale to 0. As a fallback, we hide it with visibility: hidden for browsers that don't support CSS animations.

h2 > a:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #000;
  visibility: hidden;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transition: all 0.3s ease-in-out 0s;
  transition: all 0.3s ease-in-out 0s;
}

At the very bottom we tell the element to animate all changes applied to it, with a duration of 0.3 seconds. For the animation to appear, now we just need to make the element visible again on hover, and set its X scale back to 1:

h2 > a:hover:before {
  visibility: visible;
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}

And that's it! Firefox has had support for animation and transform without the moz prefix since version 16.0 (for over a year), so I've left out the prefix in the code. If you want to be safe, you should add -o and -moz to all animations and transforms.

Caught up in a race for money and fame, we lost our focus on the important. We talk of venture capital, recruiting tactics, dreams of disrupting industries, stock options, growth hacks, and the superiority of our tools. We do not talk of the bugs, the quirks, the difficulties of using our creations, the exploitation of the public, or the worst secret of all: software is broken, we are responsible, and we’re making a lot of money off it.

We’ve become obsessed with process and tools. We’ve stopped caring about the product.

Kyle Neath, in "Product"

The Jekyll Butler

Poole

Mark Otto:

Poole is the Jekyll butler. It's a fully furnished Jekyll setup, designed to be a consistent and flexible starting point for Jekyll projects.

I wish I would've had Poole when I made the transition to GitHub Pages and Jekyll. Out of the box, it offers layouts, a custom 404 page, RSS feeds, posts, and an example page.

Along with Poole, Mark released two excellent Jekyll themes today: Hyde 2 and Lanyon.

An Open Sourced Design Guide

Master Your Typographic Adventures

Benedikt Lehnert:

Typography is the craft of arranging type with the goal to make language visible. We’re arranging type multiple times throughout the day; whether it be writing essays, summarizing meeting minutes or creating slides for a presentation. What usually happens is, we end up thinking more about what we write than how we write it.

The guide is beautifully illustrated. If you want to contribute, it's available on GitHub.

It’s easy to design something attractive that’s not very usable, and it’s easy to design something usable that’s unattractive. The challenge is striking a balance, and iOS 7 made too many usability sacrifices to achieve attractiveness.

Marco Arment

When Things Are Not Like They Seem

Illusions (Part One)

Simple CSS Spinners

SpinKit

While hacking away at Infinite Jekyll the other week, I needed to show a loading indicator while fetching new posts. It had to be open-sourced though, and available in retina resolution. I couldn't find any decent spinners, so instead of sitting down in Photoshop and creating two GIFs, I turned to CSS animations and created a simple, repeatable, loading animation.

Turns out, that was a ton of fun. I created a couple more, and have collected them in a set called SpinKit. They are all available on GitHub, and as a separate showcase, where it's easier to preview them and grab the source (pro tip: press S to show the source, ESC to close the popover.)

They're easy to customize, animated with CSS transforms (they don't trigger redraws), and should run smoothly at 60fps on most setups, including iOS.

Happy spinning!

Bending GitHub Pages

Infinite Scroll With Jekyll

If you want to use Jekyll but don't want to settle with a list of links to your blog posts, I just open sourced the parts that drives this blog's infinite scroll. As I mentioned in Moving from WordPress to Jekyll, the implementation is built around collecting the links to all blog posts in a JSON file, and using that to load more posts as you scroll.

If you'd like to add this juicy feature to your Jekyll site, head over to GitHub and grab the source, and let's get started.

Adding the files

Add the js folder and all-posts.json to the root of your Jekyll site. If you're not already using jQuery, open _layouts/default.html and include it:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

In _layouts/default.html, include infinite-jekyll.js after jQuery:

<script src="/js/infinite-jekyll.js"></script>

Render posts, not links

How fun is it to only see links? Open up index.html. Find this line:

<li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>

Remove everything within the li. Open up _layouts/post.html and copy the markup for single posts. Paste it within the li, and replace every instance of page. with post.. This is how it should look using the default markup:

<li>
    <h2>{{ post.title }}</h2>
    <p class="meta">{{ post.date | date_to_string }}</p>
    
    <div class="post">
    {{ post.content }}
    </div>
</li>

Limit the number of posts

Per default, Jekyll will render all posts in your entire archive. For lazy loading to make sense, we need to set a limit. Open up index.html and find this line:

{% for post in site.posts %}

Change it to:

{% for post in site.posts limit: 10 %}

You can change 10 to whatever number you like. The same number will be used for lazy loading new posts, so 10 will render 10 static post, and then fetch another 10 posts every time you get near the bottom of the page.

Add the spinner

You should see your 10 latest posts on the front page, but no infinite scroll yet. Infinite Jekyll will only try to lazy load posts if there's a spinner present. At the very end of index.html, add the spinner:

<div class="infinite-spinner"></div>

spinner.css contains a simple CSS spinner that works in most modern browsers. Open up css/main.css, and at the bottom, paste everything from spinner.css.

And that should be it. If you're having any issues, ping me on twitter, or create an issue in the repo. Happy scrolling!

There’s this belief that we must do a bunch of market research before we start making games. We have all these clever guys and we do all these focus groups. We get this perfect target audience, this guy, and then we build our games especially for him. But really at Blizzard we build the games we want to play. We build games that get us excited and are aesthetically pleasing to us.

— Dustin Browder of Blizzard, in an interview about their new game, Heroes of the Storm, answering the question "What sort of crowd are you aiming to pull in?"

CSS Performance Hack

Turn Off Pointer Events While Scrolling

Ryan at The CSS Ninja explores a simple idea by Christian Schaefer:

Apply "pointer-events: none" to the on scrollstart and remove it on scrollend.

You'll be able to scroll without triggering any redraws. Clever.