Five Useful Design Techniques and Coding Solutions For Web Designers

As designers, we have to create an intuitive user experience, solve design problems and provide a beautiful and functional user interfaces. Unlike print design, we don’t have the luxury of designing in a static area; rather, our canvas is ever-changing in its content, browser width, page length and more. We do need to be able to code to some extent and be able to build a design around a structure of code. Yet, with these complications comes an opportunity for unique functionality, interactive effects and better user experience.

In this article, we’ll look at five useful coding solutions that we’ve stumble upon recently. All of these solutions enhance a website’s design, not just the code. These solutions affect the user interface and the user’s interaction with the design, and they can make for a more usable and interactive website.
1. Bar Graph Effect For Multiple Items

This effect (pictured below) can be a great way to add some oomph to a Web page, and make it more user-friendly. Its functionality goes beyond just being a cool trick, though. By organizing any set of items on a page — such as tags, categories, comments, product count — a designer can enhance user interaction, provide useful content clues and improve usability. By seeing a count of items such as tags and product types, the visitor can quickly get an idea of what the website mostly consists of. This is a great way to make quick connections with targeted visitors.

For comment counts, visitors can quickly see where the discussions are at. Highlights on highly commented posts can reinforce user-to-user interaction.

Pictured below are two examples of this design. The left organizes tags, and the second ranks the most commented posts on a blog. Be sure to visit both websites to see the full functionality and CSS effects.

Anuncios

By Kayla Knight
Full article
http://www.smashingmagazine.com/2010/10/07/5-useful-coding-solutions-for-web-designers/

As designers, we have to create an intuitive user experience, solve design problems and provide a beautiful and functional user interfaces. Unlike print design, we don’t have the luxury of designing in a static area; rather, our canvas is ever-changing in its content, browser width, page length and more. We do need to be able to code to some extent and be able to build a design around a structure of code. Yet, with these complications comes an opportunity for unique functionality, interactive effects and better user experience.

In this article, we’ll look at five useful coding solutions that we’ve stumble upon recently. All of these solutions enhance a website’s design, not just the code. These solutions affect the user interface and the user’s interaction with the design, and they can make for a more usable and interactive website.

1. Bar Graph Effect For Multiple Items

This effect (pictured below) can be a great way to add some oomph to a Web page, and make it more user-friendly. Its functionality goes beyond just being a cool trick, though. By organizing any set of items on a page — such as tags, categories, comments, product count — a designer can enhance user interaction, provide useful content clues and improve usability. By seeing a count of items such as tags and product types, the visitor can quickly get an idea of what the website mostly consists of. This is a great way to make quick connections with targeted visitors.

For comment counts, visitors can quickly see where the discussions are at. Highlights on highly commented posts can reinforce user-to-user interaction.

Pictured below are two examples of this design. The left organizes tags, and the second ranks the most commented posts on a blog. Be sure to visit both websites to see the full functionality and CSS effects.

Bargrapheffect in Five Useful Design Techniques and Coding Solutions For Web Designers
Left, Dribbble (number of tags). Right, Engadget, (most commented posts).

How Is It Done?

Recreating this solution is really quite easy. We have to do three things:

  1. Lay out the full list of features,
  2. Create the effect in plain (X)HTML and CSS,
  3. Pull in the counts dynamically and put them into our static version.

Breaking the feature down into simple, specific steps give us the beginnings of a solution. We now have a direction to follow.

List the Bar Graph’s Features

To get started with the first step, let’s lay out exactly what this design does. By laying out the steps in writing, we can sort it out into coding terms.

  1. Dynamically pull in a number count (tags, comments, category count, etc.);
  2. Determine the items with the highest count (perhaps the 10 most commented categories, as opposed to all of them);
  3. Create a horizontal bar corresponding to the count (or a vertical bar for a different look);
  4. Organize the bars in order of quantity.

Recreating the Design (Static)

Now, let’s create the design, only without any dynamic data or automation. We’ll leave out pulling in the number count from a database or other source and make up our own numbers for now. We also won’t create a way to determine the highest results or organize them in descending order; instead, we’ll make up our own numbers, manually organize them and use only 10 for now. After that, we’ll redo this in plain (X)HTML and CSS and do all that dynamic stuff.

The (X)HTML:

01 <div class="block">
02 <a href="#" style="width: 100%">Web Interface Design (27)</a>
03 <a href="#" style="width: 92.59%">Photoshop Tutorials (25)</a>
04 <a href="#" style="width: 74.07%">CSS Tricks (20)</a>
05 <a href="#" style="width: 66.66%">Showcases & Inspiration (18)</a>
06 <a href="#" style="width: 51.85%">WordPress (14)</a>
07 <a href="#" style="width: 48.15%">JavaScript (13)</a>
08 <a href="#" style="width: 37.04%">Free Resources (10)</a>
09 <a href="#" style="width: 29.63%">Reviews (8)</a>
10 <a href="#" style="width: 29.63%">Interviews (8)</a>
11 <a href="#" style="width: 25.93%">Typography (7)</a>
12 </div>

The CSS:

01 html, body {
02 background: #eee;
03 font: normal 13px/1.5em Arial, Helvetica, sans-serif;
04 }
05 * {
06 margin: 0;
07 padding: 0;
08 }
09 .block {
10 width: 400px;
11 margin: 100px auto;
12 }
13 a {
14 display: block;
15 padding: 5px;
16 margin-bottom: 2px;
17 background-color: #666;
18 color: #fff;
19 text-decoration: none;
20 }
21 a:hover {
22 background: #9764a0;
23 }

The above code will create this static mock-up:

Bargraphdemo in Five Useful Design Techniques and Coding Solutions For Web Designers

Note that we’ve added some basic styling, just to experiment with how hovers could work. For the most part, though, this version is very basic so that you can customize it as you want.

The (X)HTML and CSS should be self-explanatory, but let’s go over how we created the bars. In our style sheet, we created the basic styles and turned each link into a bar using the display: block property. In this simple example, these are the only links on the page, but to be of practical use, some of these bar links would have to be given a class, to distinguish them from the other links on the page. Alternatively, one could use the :nth-child() selector of CSS3 without defining new classes.

We then went into the (X)HTML and set each bar’s width individually with the style attribute. In the (X)HTML code above, we have specified each width as a percentage. We first assume that the highest value, “Web Interface Design (27)”, is 100%. From there, we calculate the percentages of the others relative to that.

Example: “Photoshop Tutorials (25)”
25 × 100 = 2500
2500 ÷ 27 (our 100%) = 92.59%
<a href="#" style="width: 92.59%">Photoshop Tutorials (25)</a>

Recreating the Design (Dynamically)

We have now figured out the math and the static code, and we just have to put it all together, pulling the code from a database and automatically organizing and creating the bars.

In this example, we’re working with the number of posts in each of our WordPress categories, but the same logic applies to other uses and other programming languages. The code below might seem long, but don’t worry: it’s mostly comments, which explains how to dynamically calculate the percentages and pull the content into the static (X)HTML/CSS.

01 <!-- In our example, we get a count of categories in WordPress.
02 Let's first find the category with the most posts.
03 -->
04
05 <?php
06 $highest = 0; // Initialize our “highest count” variable
07 foreach((get_the_category()) as $category) { // for each category
08 $cat_count = $category->category_count;
09
10 // If this category’s count is higher than what we have so far
11 // for the highest number…
12 if($cat_count > $highest){
13 // then re-declare our highest value according to this
14 // category’s count
15 $highest = $cat_count;
16 }
17 }
18 ?>
19
20 <!-- Below we go through an array of the categories, and for each one
21 get its name and then its count. We've saved this data in
22 the $cat_name and $cat_count variables, respectively.
23
24 (Because we will get a new category each time the loop runs,
25 we'll have to process all of our other (X)HTML/CSS code within the loop
26 for each turn.)
27 -->
28 <div class="block">
29
30 <?foreach((get_categories(‘orderby=count&order=desc’)) as $category) {
31 $cat_name = $category->cat_name;
32 $cat_count = $category->category_count;
33
34 // Let's calculate this category’s width
35 // (our “100%” is our highest category count number, $highest)
36 $width = ($cat_count * 100) / $highest;
37
38 // Finally, echo out our link HTML, including our variables
39 // to dynamically bring in the content for the width,
40 // category name and count.
41 echo '<a href="#" style="width: .'$width'.%">
42 .'$cat_name'. (.'$cat_count'.)</a>';
43 }
44 ?>
45 </div>

Demo and Download Files

You can see the demo and download the files from our servers.

2. Animation On Article Hover

Now, this is a very nice aesthetic effect, and it is original, too. Visit CSS Tricks or check out the image below. The articles have a simple clean look, with only an asterisk separating them. When one hovers over a post, we see its meta data: comments, a “Read on” link and date stamp.

What makes this effect especially dynamic is that it features a hover effect for content, not just images. It’s a cool trick and it has some practical uses, too. By hiding content until it’s needed, the designer puts more emphasis on the content and important features. A website can have the appeal of minimalism but still offer rich functionality.

This design solution also makes important content stand out. As on CSS Tricks, when users hover over a post, an action occurs, drawing the user’s eyes to links that will help them interact with the blog.

Hoveronpost in Five Useful Design Techniques and Coding Solutions For Web Designers
When you hover over a home-page post on CSS-Tricks.com, meta content is revealed.

How Is It Done?

This effect might look more complicated than a simple image roll-over, but the same principle applies. With some CSS and a bit of basic JavaScript, we can do the same thing.

Let’s first look more closely at what this effect does. Then we’ll be able to more easily come up with the solution.

  • When any part of a post is hovered over, the effect is triggered.
  • Two pieces of content are revealed, to the left and right of the original image: the date and comments section, and the “Read on” section.
  • On moving the mouse, the post returns to normal.

Seeing how this is similar to image roll-overs is now easier. For image roll-overs, we use JavaScript to change code for onMouseOver and onMouseOut. We’ll do a similar thing here, but use divs instead of images. Also with image roll-overs, we’ll usually replace one image with another. Our action here instead will be just to show and hide content.

The (X)HTML

We need to wrap a div element around the entire post, and we can manage that as a single step. We can then apply the JavaScript events to it: MouseOver and MouseOut. For each, we simply set the content’s display property (defined by a CSS id) to none or inline. Instead of using inline-attributes, it’s better to separate JavaScript and CSS, e.g. using jQuery.

01 <div class="post">
02
03 <h2>A Blog Post Title</h2>
04 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque dignissim est ultrices neque fermentum convallis. Nulla libero lacus, accumsan sed porta quis, pulvinar in lectus. Sed id justo lorem, eu ullamcorper sapien. Nullam tincidunt lorem nec nisl egestas gravida vel et massa. Donec arcu nisl, venenatis ac suscipit dignissim, egestas auctor lectus. Quisque vulputate fermentum felis sed tristique. Ut enim felis, faucibus ac fermentum rutrum, posuere id nulla. Duis lectus dolor, eleifend in tincidunt eu, sagittis sed sapien. Duis id purus id magna facilisis luctus. Mauris sodales arcu ut arcu laoreet id pulvinar ligula hendrerit.</p>
05
06 <!-- This is what appears when not hovering -->
07 <p id="postimg" class="center">
08 <img src="triangle.png" alt="Triangle" />
09 </p>
10
11 <!-- This is what appears on hover; hidden otherwise. -->
12 <p id="hiddencontent" class="center">
13 Posted on 9/15/10 | <a href="#">23 Comments</a>
14 <img src="triangle.png" alt="Triangle" />
15 <a href="#">Continue Reading…</a>
16 </p>
17
18 </div>
19
20 <script type="text/javascript">
21 $('.post').mouseover(function() {
22 $('#hiddencontent').css('display', 'inline');
23 $('#postimg').css('display', 'none');
24 });
25
26 $('.post').mouseout(function() {
27 $('#hiddencontent').css('display','none');
28 $('#postimg').css('display', 'block');
29 });
30 </script>

The CSS

Here, we’ve just done some basic styling: centered our div, styled the h2 tag, played with fonts, etc. The thing to note here is the #hiddencontent div. Because we need to hide our content on page load, we must set it in the CSS to display: none.

01 html, body {
02 background: #eee;
03 font: normal 14px/1.6em Arial, Helvetica, sans-serif;
04 }
05
06 #hiddencontent {
07 display: none;
08 }
09
10 h2 {
11 margin-bottom: .5em;
12 }
13
14 .center {
15 width: 500px;
16 text-align: center;
17 }

Below is our mock-up of the design (top is before the hover, and bottom is after). It’s just some basic CSS and JavaScript, and the code is easy enough to work around when implementing in WordPress or elsewhere.

Posthoverdemo in Five Useful Design Techniques and Coding Solutions For Web Designers

Demo and Download Files

You can see the demo and download the files from our servers.

Full article
http://www.smashingmagazine.com/2010/10/07/5-useful-coding-solutions-for-web-designers/

Autor: Gabriel Catalano - human being | (#IN).perfección®

Lo importante es el camino que recorremos, las metas son apenas el resultado de ese recorrido. Llegar generalmente significa, volver a empezar!

Un comentario en “Five Useful Design Techniques and Coding Solutions For Web Designers”

Los comentarios están cerrados.