<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DrieStone Design : The Portfolio of Jonathan Sweet &#187; Technique</title>
	<atom:link href="http://www.driestone.com/category/technique/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.driestone.com</link>
	<description>Design This!</description>
	<lastBuildDate>Thu, 08 May 2008 04:30:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building a Better Mousetrap</title>
		<link>http://www.driestone.com/technique/building-a-better-mousetrap/</link>
		<comments>http://www.driestone.com/technique/building-a-better-mousetrap/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 00:05:55 +0000</pubDate>
		<dc:creator>DrieStone</dc:creator>
				<category><![CDATA[Technique]]></category>

		<guid isPermaLink="false">http://www.driestone.com/2007/09/11/building-a-better-mousetrap/</guid>
		<description><![CDATA[If you&#8217;re a Web developer, you&#8217;ve probably read various methods for filling the need for a scriptable CSS style sheet. Most are a variation on a theme, here I present my preferred method, that is unlike others I&#8217;ve read (and it does some pretty cool stuff too). I&#8217;ve been using the core of my scriptable [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.driestone.com/wp-content/uploads/2007/09/mousetrap.jpg' alt='Mousetrap' class="left"/>If you&#8217;re a Web developer, you&#8217;ve probably read various methods for filling the need for a scriptable CSS style sheet. Most are a variation on a theme, here I present my preferred method, that is unlike others I&#8217;ve read (and it does some pretty cool stuff too). I&#8217;ve been using the core of my scriptable CSS system for six months now, and I have found it invaluable to the way I work.</p>
<p>The core need of a CSS scripting system is the need for a color substitution system that would streamline color selection for the web sites I&#8217;m working on. Most of the other scriptable CSS systems do exactly that, so we&#8217;re not breaking new ground here. Since many of the sites I work on are high bandwidth, heavy usage sites, I need to minimize the server hit as much as possible. Reducing external files, and limiting the calls to the database and PHP are the name of the game here. My tertiary concern is to make the editing of my scripting system as easy and transparent as possible.</p>
<p><span id="more-39"></span><br />
<h3>Avoiding the Overhead</h3>
<p>The issue with many of the other &#8220;CSS scripting&#8221; systems is that since they rely on PHP at run-time the files need to be processed through PHP each time they are loaded (which means there is additional server load, as well as additional non-CSS code buried in the file). Another (minor) issue is that all of your CSS files also end with &#8220;.php&#8221; which can make management problematic (especially because chances are your text editor is going to use its PHP syntax highlighter instead of its CSS highlighter). I wanted to avoid all of these issues. The solution here is simple, we compile to CSS once and load the &#8220;true&#8221; CSS file each time the page is loaded.</p>
<h3>How Does it Work?</h3>
<p>The core of the CSS scripting is a file I called the &#8220;FCSS&#8221; file. Because this file is not a PHP file, I can set a rule inside of BBEdit (or other editor) to use CSS syntax highlighting. I built a PHP helper function for my XHTML pages that inserts the correct XHTML code on the page to load my CSS file. I do this because my scripting system runs in two modes: &#8220;production&#8221; and &#8220;testing&#8221;. In testing mode my script attempts to compile the FCSS to a normal CSS file. In production the system circumvents the FCSS file and loads the compiled CSS file. This means that PHP is only loaded when I&#8217;m testing the CSS on the site, but when the pages get rolled out to production only the compiled CSS pages get called.</p>
<h3>Syntax</h3>
<p>The syntax inside the FCSS file is simple. I have adopted a function style syntax that allows me to use regular expressions inside my scripting engine to find data that I need to act upon. To support my primary goal, I have created a function called &#8220;color&#8221;.</p>
<h3>Color Substitution</h3>
<p>At the most basic level I wanted a system that would allow me to create a named color that I could use across all of my CSS files. For instance I may want to assign the hex color #c312F0 to the named color &#8220;background&#8221;. This would allow me to create a dictionary of color for each site that would allow me to quickly select the right color (and make global changes easily).</p>
<p>Within the config file for my web site I define an array of name/value pairs for colors I want to use for this particular site. The colors are passed off to the CSS scripting engine to be used</p>
<h3>Color Calculations</h3>
<p>Having a dictionary of colors used on a site is handy, but really not super useful (how many times will you really need to know the color of the background?) Being able to modify those colors on the fly would be very helpful. For instance perhaps I might want to make a popup box a darker version of the background color, or maybe I want to take the link color, rotate the hue and set that color to the link visited color. You can see how powerful having the ability to calculate colors would be.</p>
<p>Why stop there though? Why not give the author the ability to mix two colors together? Maybe take your background color and mix in a little bit of the link color to give the site credits a subtle look?</p>
<p>Instead of opening up Photoshop (or some other tool) and mixing the colors together, putting it into your CSS file, then testing it, you can write:</p>
<p><code>p.credits{color:color(background,m:link:25);}</code></p>
<p>&#8230;and if it&#8217;s not quite right, you can tweak the colors, and refresh the page until it&#8217;s perfect.</p>
<p>That is the power of scriptable CSS.</p>
<h3>Down Sides</h3>
<p>There are a few negative side effects of this system. The biggest issue is that you need to make sure that Apache has write access to create (or change) the compiled CSS files. Part of my script checks this and attempts to alert the user if there is an issue. A secondary issue (although only for some) is that using this compiled css, you lose the ability for run-time changes (although this can be easily overcome with a trigger on my PHP helper function). Honestly though, CSS doesn&#8217;t need real-time scripting. It&#8217;s not its job. That is what JavaScript is for.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.driestone.com/technique/building-a-better-mousetrap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing by the rules</title>
		<link>http://www.driestone.com/technique/playing-by-the-rules/</link>
		<comments>http://www.driestone.com/technique/playing-by-the-rules/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 15:04:37 +0000</pubDate>
		<dc:creator>DrieStone</dc:creator>
				<category><![CDATA[Technique]]></category>

		<guid isPermaLink="false">http://www.driestone.com/2006/12/20/playing-by-the-rules/</guid>
		<description><![CDATA[Any developer who has worked on a job for a corporate client of any reasonable size, has probably had to wade through some documentation as it pertains to the final presentation of their project. Companies want to make sure that whatever you do for them matches everything else, it&#8217;s vital to their livelihood that their [...]]]></description>
			<content:encoded><![CDATA[<p><img id="image27" src="http://www.driestone.com/wp-content/uploads/2007/01/gavel.jpg" alt="Gavel" class="left" />Any developer who has worked on a job for a corporate client of any reasonable size, has probably had to wade through some documentation as it pertains to the final presentation of their project. Companies want to make sure that whatever you do for them matches everything else, it&#8217;s vital to their livelihood that their image doesn&#8217;t get diluted by designers and developers trying to push the envelope.</p>
<p class="clear">Although it can be frustrating and annoying, it also gives a designer/developer the freedom to avoid getting mired in the details of the interface (even though many of us love designing interfaces). Taking a page from the corporate world (no pun intended), establishing a set of rules can make a developer&#8217;s life easier.</p>
<p><span id="more-15"></span>These rules should be created for two important reasons. First, working with other designers and developers becomes easier if they are all working from the same playbook. Second, by providing the rule book to the client before work begins, the client can feel better about the decisions of the developer (they will know that the process has been well thought out, and that there is a reason for the decisions of the developer).</p>
<h3>Starting Out</h3>
<p>Any developer that has been asked by their client to explain why he/she did something in particular already knows a number of the rules that should be established. I broke my own rule book into six main sections:</p>
<ul>
<li>Overview</li>
<li>Design</li>
<li>Accessibility</li>
<li>Usability</li>
<li>Browser Compatibility</li>
<li>Coding Practices</li>
</ul>
<p>Coding Practices is by far the largest section. It includes six sub-sections (General, HTML, CSS, JavaScript, Database, and PHP).</p>
<h3>Building on a bad thing</h3>
<p>Every time that I run into a conflict with a client or another developer that isn&#8217;t covered in my manual, I/we decide on a solution, and it goes into the manual for future reference.</p>
<h3>Evolve the rules</h3>
<p>Every so often (3-6 months) I read through my rule book to make sure I agree with everything in the rule book. For instance, one of my rules is minimum screen size. In my last read-through, after a little investigation, I decided that 1024&#215;768 is the new minimum size that I would begin working within.</p>
<h3>Samples</h3>
<p>Here are a few rules from my book:</p>
<ul>
<li>All code/layout for publicly accessible pages should be built so that Internet Explorer 6.0, Firefox 1.0, and Safari 1.5 all act similarly. </li>
<li>CSS styling should only be implemented using linked files.
<ul>
<li>Inline styles should not be used</li>
<li>Style definitions in the head of the document should be avoided.</li>
</ul>
</li>
<li>Forms should always be validated on the server side.
<ul>
<li>JavaScript form validation is a nice extra, but data from the client should never be trusted to be valid.</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.driestone.com/technique/playing-by-the-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reaching the Gray Area of Accessibility.</title>
		<link>http://www.driestone.com/technique/reaching-the-gray-area-of-accessibility/</link>
		<comments>http://www.driestone.com/technique/reaching-the-gray-area-of-accessibility/#comments</comments>
		<pubDate>Mon, 17 Jul 2006 19:21:01 +0000</pubDate>
		<dc:creator>DrieStone</dc:creator>
				<category><![CDATA[Technique]]></category>

		<guid isPermaLink="false">http://driestone.com/?p=10</guid>
		<description><![CDATA[
Lately I’ve been working for a unique client that understands the importance of accessibility, but they view it as a black and white issue. It’s not entirely their fault, but that’s a rant for another day. The core problem is that they equate accessibility to making a site usable by people using a screen reader. [...]]]></description>
			<content:encoded><![CDATA[<p><img id="image28" src="http://www.driestone.com/wp-content/uploads/2007/01/glasses.jpg" alt="Glasses" class="left"/>
<p>Lately I’ve been working for a unique client that understands the importance of accessibility, but they view it as a black and white issue. It’s not entirely their fault, but that’s a rant for another day. The core problem is that they equate accessibility to making a site usable by people using a screen reader. If only real accessibility were that easy.</p>
<p>Making a web site accessible for those who can’t see pixels on the screen is important, but for every blind person using a computer, there are (probably) dozens more that we also need to think about, the gray area. These are the people who may have difficulty reading the average well-designed web site. Accessibility for these people is as important as accessibility for the sightless.</p>
<p><span id="more-10"></span>
<p>These are the people who don’t need a “skip to content” link, but need high contrast, large text pages that are easy to navigate. Liquid layouts and clever design will get you part of the way there, but ultimately, to provide real accessibility you’ll probably have to create an alternate format that these users can use.</p>
<p>So, in the interest of accessibliity, you’ve carefully crafted a primary style and it’s gray area cousin. Your code is clean and accessible, so finally you can step back and admire your beautifuly accessible site right?</p>
<p>Well&#8230; almost. You’ve done the legwork, but there is still one major accessibility (and usability) problem. How do you get your gray area users to their version of the site? It’s doubtful the client is going to go for the idea of putting a big black and white button next to their logo advertising the alternate version of the site (it’s not <strong>that</strong> important to them). There’s really not a place for an accessible link in your standard site design. If only there was a way that we could detect those users that would require the alternate version of the site without the requirement of a link to initiate the switchover.</p>
<h2>Introducing Auto Style Switching.</h2>
<p>Most average users tend to keep their browsers set to the default font size because this is what most developers design for (or maybe it’s the other way around). Our gray area users have the option to increase the font size globally on all web sites. Those who need a larger font only need to tell their browser to user a larger font.</p>
<p>Using a bit of Javascript we can detect the size of 1em in pixels and judge it’s size relative to the default. This isn’t an exact science since there will always be a variation between browsers and configurations, but we don’t need to be pixel accurate here. If it is beyond a threshold we trigger our high contrast style sheet (using the script by <a href="http://www.alistapart.com/articles/alternate/">Pault Sowden</a>).</p>
<pre>
<script>
  window.onload = checkContrast;

  function checkContrast(){
    if (document.getElementById('high_contrast_check').clientHeight > 30)
      setActiveStyleSheet('high_contrast');
  }
</script>
<style type="text/css">
  div#high_contrast_check{
    height:2em;
  }
</style>
<div id="high_contrast_check"></div>
</pre>
<p><a href="/articles/gray_accessible/example1.html">See it in action</a></p>
<h2>Handling the Resize</h2>
<p>Although the majority of users will be entering our site with their font size already set to their liking, it is certainly possible that a user might change their font setting after already loading the page.</p>
<p>In Internet Explorer, changing the text size reloads the page (therefore trigering the window.onresize event). So, we could just add that to our initialization:</p>
<pre> window.onresize = window.onload = checkContrast;</pre>
<p>Of course it&#8217;s never that easy. Safari and Firefox don’t seem to trigger any DOM event so there is no way for us to find out if the text size has been changed.</p>
<p>We could call it a day and accept that we&#8217;ve provided support for the majority of users, or we could use setInterval to check our text size a few times a second as a work around. It&#8217;s not very elegant, and it almost crosses the line into what might be considered a “hack”, but the setInterval solution is the only one that works for all browsers.</p>
<p>In the end I opted to be as accessable to as many people as possible, which means using the setInterval solution. I check the test area five times a second which should be often enough to provide reasonable feedback, but not so often as to make much impact on our available processor cycles.</p>
<pre>
<script>
    var theLastSize = 0;
    window.onresize = checkContrast;

    window.onload = function(){
      window.setInterval('checkContrast();',200);
      checkContrast();
    }

    function checkContrast(){
      if (document.getElementById('high_contrast_check').clientHeight != theLastSize){
        theLastSize = document.getElementById('high_contrast_check').clientHeight;
        if (theLastSize > 30)
          setActiveStyleSheet('high_contrast');
        else
          setActiveStyleSheet('default');
      }
    }
</script>
</pre>
<p><a href="/articles/gray_accessible/example2.html">See it in action</a></p>
<h2>Allowing Users the Choice</h2>
<p>As a last step we should add a link to our site that allows the user to toggle the style that they are presented with. We can work this into our design now without too much fear that those who need it won’t be able to find it. This has been covered in <a href="http://www.alistapart.com/articles/alternate/">many places</a>, so it&#8217;s not really worth reexamining it here.</p>
<h2>Variations On a Theme</h2>
<p>You don&#8217;t need to use the text size to trigger style sheet changes, you could trigger any other interface. Perhaps instead of switching styles, you present a dialog notifying the user of the alternate style, or even send them to a different location.</p>
<p>Additionally, we don’t need to create a binary switch between normal and alternate versions of the site. We really are in the gray area of accessibility. A clever developer can use the realative size difference to adjust the site, triggering variations based on font size using different style sheets, or directly changing the styles of elements. <a href="/articles/gray_accessible/example3.html">What would you do?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.driestone.com/technique/reaching-the-gray-area-of-accessibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
