all repos — h3rald @ 2905fa880540f1196c748436b66a9d57ccf83bb0

The sources of https://h3rald.com

content/articles/h3rald-83.glyph

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
-----
:permalink: h3rald-83
:title: H3RALD.com v8.3 Released
:subtitle: A new minimalist design, powered by Twitter Bootstrap
:type: article
:intro: |
  One of the many things that really bothered me about my web site was the fact that it didn't look good on my iPhone, or any small screen for that matter.

  Years ago I "read about":http://www.alistapart.com/articles/responsive-web-design/ responsive web design, media queries, etc., but I never had the will or the time to dive into the subject. Then "Twitter Bootstrap":http://twitter.github.com/bootstrap/ came out, and it changed _everything_. 
:extended_intro: |
  Not only Bootstrap provides a very solid HTML boilerplate and grid system, it also comes with some very nice and complete styles for every HTML element, a few Javascript-enhanced UI components, and  best of all it is fully responsive.  
:tags:
- website
- webdevelopment
:date: 2012-12-27 23:41:34.376991000 +01:00
:pdf: false
-----
$[document.intro]

§txt[
  @title[Getting to know Bootstrap & its CSS wizardry]

Redesigning H3RALD.com using Twitter Bootstrap turned out to be fairly easy. I headed up to the "Customize and Download":http://twitter.github.com/bootstrap/customize.html page and set a few variables like the font to use (the beautiful "Crimson text":http://aldusleaf.org/crimson.php), the link color and so on, and downloaded the lot.

I more or less completely forgot about my old CSS stylesheets and went with Bootstrap all the way. I was happy with a lot of the defaults, but I had to add a few rules and overrides for:
* headings
* line heights
* A few custom classes I use extensively, like add a @text-align: justify;@ for the @hyphenate@ class.

Now, one of the cool things of Bootstrap is that it comes with smart defaults, and that it lets you add specific features to elements simply by adding a CSS class to them. Take a look at how "buttons":http://twitter.github.com/bootstrap/base-css.html#buttons are constructed, for instance. Normal button? Sure:

table[
  tr[
    td[codeblock[<button class="btn">Click Me!</button>]]td[<button class="btn">Click Me!</button>]
  ]
]

That's grey with black text. Boring. Want it red? Sure, add the @.btn-danger@ class:

table[
  tr[
    td[codeblock[<button class="btn btn-danger">Click Me!</button>]]td[<button class="btn btn-danger">Click Me!</button>]
  ]
]

Too big? No problem, make it smaller with @.btn-sm@, so we have:

table[
  tr[
    td[codeblock[<button class="btn btn-danger btn-small">Click Me!</button>]]td[<button class="btn btn-danger btn-small">Click Me!</button>]
  ]
]


Wouldn't it be nice to have a nice icon in it? Add an empty @<i>@ element with a suitable class and there you have a nice "Glyphicon":http://twitter.github.com/bootstrap/base-css.html#icons before the button text (or you can use other icon fonts, like "FontAwesome":http://fontawesome.io/).

table[
  tr[
    td[codeblock[<button class="btn btn-danger btn-sm"><i class="fa fa-check"></i> Click Me!</button>]]td[<button class="btn btn-danger btn-sm"><i class="fa fa-check"></i> Click Me!</button>]
  ]
]

...You get the picture. And it works surprisingly well -- if you embrace its philosophy, that is. Just like Rails & Co.: an _opinionated_ framework.

The only thing that bugged me about all this was that by adding smart CSS classes to elements you're actually specifying how something looks like by polluting HTML code. Granted, if your stylesheet doesn't include a @.btn-inverse@ your buttons won't automagically become black, but you know what I mean. Although in a very nice way, by following Bootstrap's way of doing things you are no longer separating content from presentation. And in the next six months, when I'll ditch Bootstrap for something better, all the previews of the code snippets above won't work unless I keep using the Bootstrap stylesheet or at least some of its button classes.

The real problems arise for the stylesheets provided for general elements. By default, Bootstrap styles tables with no borders or colors. What if I wanted just ordinary tables to be striped and bordered? Sure, I can add the @.table-striped@ and @.table-bordered@ classes to all tables, and that's it. In EVERY table. Or of course undo bootstrap's magic by overriding the CSS rules for ordinary tables, to include the rules specified for @.table-striped@ and @.table-bordered@. Copy & paste someone else's code? Not nice. 

Luckily, using "SASS":http://sass-lang.com/ finally paid off, and here's how to do it in a nice and tidy way:

<notextile>
  codeblock[=@import "_bootstrap.scss"; 
/* The bootstrap stylesheet - just changed its extension and prepended an underscore, nothing more */

table {
  @extend .table;
  @extend .table-striped;
  @extend .table-bordered;
}
  =]
</notextile>

There you go. All tables (ordinary @<table>@ elements with no silly classes attached) are now bordered and striped.

]


§txt[
  @title[Header & navigation bar]

As far as the main site header goes, I decided to use the same one for all pages, containing:
* The site logo
* The search input box (powered by "Google Custom Search Engine":http://www.google.com/cse/
* A _responsive_ navigation bar with links to all the main sections of the site

As far as the navigation bar goes, that's pure Bootstrap goodness, nothing new there (except the serif font), "look it up":http://twitter.github.com/bootstrap/components.html#navbar. 

For the logo... Well, I had this nice plan of using just plain CSS and web fonts to make it (hell, it's basically the word "H3RALD", with the 3 slightly bigger and moved a bit). It worked mostly fine (in webkit browser and in Opera), but Firefox didn't like it much, and IE... well, some old versions of IE don't play nice with web fonts, so I decided to make a nice PNG image and stick it there instead. Less hassle, it works everywhere, job done.

The search input box was a bit more of a challenge. I read up on the new "Custom Search Element Control API":https://developers.google.com/custom-search/docs/element, discovered that Google decided that web designers don't know Javascript or CSS nowadays and proposed a new API that has numerous advantages like:

blockquote[
* Easy to use syntax—no JavaScript knowledge required.
* Custom Search elements (search boxes and results pages) are rendered based on settings stored on the CSE servers (along with any client-side customization). Server-side changes don't require you to copy and paste any new code into your site
]

Thanks Google. Now every time I change my stylesheet I have to remember to go back to your page and change the link colors etc. And if I decide to hide the page URL underneath the link in the results? I can't. And that's why I decided to reverse engineer their CSS and provide my overrides. Nasty, but at least I have some control! They're all "here":https://github.com/h3rald/h3rald/blob/master/content/styles/_vendor.scss, if you are curious.  
]

§txt[
  @title[Other minor changes & tweaks]

Other changes from the previous design were relatively minimal:
* No more newspaper-style home page with five columns, two will suffice.
* A brand new "Tags":/tags/ page, listing... well, all the site tags that were previously in the "Archives":/archives/ pages (now only listing articles by month of publication)
* No more Links page. No need for it.
* A new, minimalist "Contact":/contact/ page, featuring some of the nice "Zocial":http://zocial.smcllns.com/ font icons.
* No more social buttons on pages. If you use social networks like Twitter, Facebook or Google+ you already know how to share items using bookmarklets or browser extensions. No need to plague my web site with their nasty buttons, badges, ribbons & alike.
* No ads! I have a full-time job, my site uses free and open source technologies, and I write because I like to do so, not to make money. And I can afford the few bucks necessary to pay the hosting provider. That's why there are NO ADS on H3RALD.com anymore ^(*)^.

^(*)^: For now, that is. Then I'll probably change my mind, but until then enjoy the true no-ads experience!
]