<?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>Tony Stuck (toekneestuck)</title> <atom:link href="https://www.toekneestuck.com/feed/" rel="self" type="application/rss+xml" /><link>https://www.toekneestuck.com</link> <description>Live a little.</description> <lastBuildDate>Tue, 25 Jun 2013 21:59:23 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>https://wordpress.org/?v=4.4.2</generator> <item><title>CSS Toggle Switch</title><link>https://www.toekneestuck.com/blog/2013/04/09/css-toggle-switch/</link> <comments>https://www.toekneestuck.com/blog/2013/04/09/css-toggle-switch/#respond</comments> <pubDate>Tue, 09 Apr 2013 15:29:30 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[User Interface]]></category> <category><![CDATA[checkboxes]]></category> <category><![CDATA[css3]]></category> <category><![CDATA[toggles]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=496</guid> <description><![CDATA[It&#8217;s been a busy past few months at CloudFlare and now that we&#8217;ve recently begun a full-on overhaul of the website I thought I&#8217;d start sharing some little pieces I&#8217;ve been building. The Toggle Many of CloudFlare&#8217;s settings are literally &#8230;]]></description> <content:encoded><![CDATA[<p>It&#8217;s been a busy past few months at CloudFlare and now that we&#8217;ve recently begun a full-on overhaul of the website I thought I&#8217;d start sharing some little pieces I&#8217;ve been building.</p><h2>The Toggle</h2><p>Many of CloudFlare&#8217;s settings are literally turning features and services on or off, so <a href="http://kevinwilsondesign.com" target="_blank">Kevin</a> (our designer), wanted to preserve the toggle concept (considering that it&#8217;s heavily used in our current UI). Stylistic changes aside, I wanted to make sure the toggle buttons were built and functioned significantly better than the existing ones; every one of the old toggles had to be instantiated via javascript, transitioned with jQuery animations, and were composed of 8 DOM elements each (!!).</p><p>The first toggle I came up with was built entirely from a <code>&lt;input type="checkbox" /&gt;</code> element, but sadly I came to find out that Firefox&#8217;s <code>-moz-appearance: none</code> <a href="https://coderwall.com/p/a7tbrq" target="_blank">doesn&#8217;t actually do anything</a>, so you&#8217;re left with nothing but an oversized checkbox. It works wonderfully in WebKit, however. Chrome has also implemented CSS3 transitions for pseudo elements, which makes me wish even more that this solution worked.</p><h3>The Final Markup</h3><p>Once I got over the fact that I needed more than one DOM element to produce a toggle switch, I came up with the following snippet, which is composed of a label, the checkbox, and a span. I used the label to build the two states of the switch (using <code>:before</code> and <code>:after</code>) and the <code>&lt;span class="knob"&gt;</code> to control the toggle element. Basic CSS3 transitions work nicely across all (modern) browsers here, as the span is being transitioned, so there&#8217;s no need to worry about support for pseudo element transitions.</p><p><iframe src="http://jsfiddle.net/toekneestuck/ARaR9/embedded/result,css,html" height="300" width="100%" allowfullscreen="allowfullscreen" frameborder="0"></iframe></p><h3>Downsides</h3><p>One small gripe I have with this is hard coding the text into the CSS, which could cause some annoyances if you&#8217;re working with a multi-lingual site, but a simple solution is using CSS&#8217;s <code>attr()</code> function to pull the text from data attributes on the DOM element.</p><p>Unfortunately &lt;=IE8 doesn&#8217;t support the :checked pseudo selector, so a small bit of JS is needed to detect the checked state for these browsers, if you plan to support them.</p><h4>Original Code</h4><p>The code above has been modified to allow it to be compiled in JSFiddle, but the original code I&#8217;ve written is below. I&#8217;m a big believer in ems/rems, so that is being used heavily across my projects. Maybe I&#8217;ll have to write up another post about how the units below are converted..</p><pre class="prettyprint linenums">.switch{
	/* Hack to make Chrome round to .33334 */
	$switchWidth: 80.01px;

	background-color: $formBg;
	border: 1px solid $formBorderColor;
	color: $white;
	cursor: pointer;
	font-size: 0;
	height: $formInputHeight;
	overflow: hidden;
	margin: 0;
	padding: 0;
	position: relative;
	width: $switchWidth/$rem;

	@include user-select(none);
	@include appearance(none);

	&amp;:after,
	&amp;:before{
		background-color: $green;
		color: $white;
		content : 'On';
		font-size: $inputFontSize/$rem;
		line-height: $lineHeight;
		height: 100%;
		left: 0;
		padding: 6.75px/$rem 0;
		position: absolute;
		text-align: center;
		top: 0;
		width: 51%; /* This is so the rounded corners of the knob doesn't make things wierd */
	}

	&amp;:before{
		background-color: $formBorderColor;
		content : 'Off';
		left: auto;
		right: 0;
		width: 50%;
	}

	.knob{
		background: darken($formBg, 3%);
		border: 1px solid $formBorderColor;
		border-bottom: none;
		border-top: none;
		display: block;
		font-size: $inputFontSize/$rem;
		height: 100%;
		left: -1px;
		position: relative;
		top: 0;
		width: ($switchWidth/2)/$rem;
		z-index: 2;

		@include border-radius($baseBorderRadius);
		@include transition(all 0.15s linear);

		&amp;:before,
		&amp;:after{
			border: 4px solid transparent;
			border-left-color: inherit;
			content : '';
			display: block;
			height: 0;
			left: 50%;
			margin-left: 2px;
			margin-top: -3px;
			position: absolute;
			top: 50%;
			width: 0;
		}

		&amp;:before{
			border-left-color: transparent;
			border-right-color: inherit;
			margin-left: -10px;
		}
	}

	input{
		position: absolute;
		visibility: hidden;
	}

	input.checked + .knob,
	input:checked + .knob{
		left: 50%;
	}
}</pre>]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2013/04/09/css-toggle-switch/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Adobe Edge Fonts Previewer, Updated</title><link>https://www.toekneestuck.com/blog/2012/12/03/adobe-edge-fonts-previewer-updated/</link> <comments>https://www.toekneestuck.com/blog/2012/12/03/adobe-edge-fonts-previewer-updated/#comments</comments> <pubDate>Tue, 04 Dec 2012 02:16:10 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[APIs]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[User Interface]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=482</guid> <description><![CDATA[I&#8217;ve been getting a few feature requests for the Edge Fonts Previewer, but between switching jobs and moving across the country, finding time to update it has been minimal. Finally, however, I just added the most requested feature on my &#8230;]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been getting a few feature requests for the Edge Fonts Previewer, but between switching jobs and moving across the country, finding time to update it has been minimal. Finally, however, I just added the most requested feature on my flight back to San Francisco: <strong>font size adjustment</strong>.</p><p>I wanted to write/add the fewest lines of code possible, so I went the input[type=&#8221;range&#8221;] route, which made implementation extremely simple. No jQuery slider or equivalent to implement, so that alone cut down on large amounts of javascript. The trade off is that it <a href="http://caniuse.com/input-range" target="_blank">basically just doesn&#8217;t work in Firefox</a>. Oh well. Since the input field just falls back to a text field, you can technically just type a valid number and it will still function; just no fancy slider.</p><p>So, slide away!</p><p class="notice"><strong>Update</strong>: I added an input[type=&#8221;range&#8221;] polyfill, so the range slider does now work in Firefox.</p><p class="center"><a class="button important" href="http://edgefonts.toekneestuck.com">Edge Font Previewer</a> <a class="button important" href="https://github.com/toekneestuck/edgefonts-preview">Github Repo</a></p> ]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/12/03/adobe-edge-fonts-previewer-updated/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>California.</title><link>https://www.toekneestuck.com/blog/2012/11/19/moving-to-california/</link> <comments>https://www.toekneestuck.com/blog/2012/11/19/moving-to-california/#respond</comments> <pubDate>Mon, 19 Nov 2012 16:39:23 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[Random]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=476</guid> <description><![CDATA[I&#8217;m a week late on this, but I&#8217;m happy to announce that I&#8217;ve started a new job at CloudFlare! It will be a fun and awesome journey. Now it&#8217;s full-time apartment searching in San Francisco.]]></description> <content:encoded><![CDATA[<p>I&#8217;m a week late on this, but I&#8217;m happy to announce that I&#8217;ve started a new job at CloudFlare! It will be a fun and awesome journey. Now it&#8217;s full-time apartment searching in San Francisco.</p> ]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/11/19/moving-to-california/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Adobe Edge Fonts Previewer</title><link>https://www.toekneestuck.com/blog/2012/09/27/adobe-edge-fonts-previewer/</link> <comments>https://www.toekneestuck.com/blog/2012/09/27/adobe-edge-fonts-previewer/#comments</comments> <pubDate>Thu, 27 Sep 2012 16:47:49 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[APIs]]></category> <category><![CDATA[Javascript]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=461</guid> <description><![CDATA[<p><img width="663" height="366" src="https://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-663x366.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="My Edge Fonts Previewer" srcset="http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-663x366.png 663w, http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-1000x552.png 1000w, http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-844x466.png 844w, http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer.png 1040w" sizes="(max-width: 663px) 100vw, 663px" /></p>Adobe recently released their Edge Fonts service, which contains over 500 freely available fonts for (unlimited) use, running all on the back of Typekit. If you&#8217;re interested in reading more about the situation, see here, here, or here. The fact that &#8230;]]></description> <content:encoded><![CDATA[<p><img width="663" height="366" src="https://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-663x366.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="My Edge Fonts Previewer" srcset="http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-663x366.png 663w, http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-1000x552.png 1000w, http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer-844x466.png 844w, http://www.toekneestuck.com/content/uploads/2012/09/my-edge-fonts-previewer.png 1040w" sizes="(max-width: 663px) 100vw, 663px" /></p><p>Adobe recently released their Edge Fonts service, which contains over 500 freely available fonts for (unlimited) use, running all on the back of Typekit. If you&#8217;re interested in reading more about the situation, see <a title="Adobe Edge Fonts" href="http://html.adobe.com/edge/webfonts/" target="_blank">here</a>, <a title="Typekit Blog - Introducing Adobe Edge Web Fonts" href="http://blog.typekit.com/2012/09/24/introducing-adobe-edge-web-fonts/" target="_blank">here</a>, or <a title="Edge Fonts" href="http://www.edgefonts.com/" target="_blank">here</a>.</p><p>The fact that they did this at all is a big leap forward for Adobe, so that&#8217;s awesome. BUT, the <a href="http://www.edgefonts.com" target="_blank">edgefonts.com</a> site is weak in making it easy for people to browse all of the available fonts. As of writing this, the only place to preview the fonts is at the bottom of <a href="http://html.adobe.com/edge/webfonts/" target="_blank">Adobe&#8217;s Edge Web Fonts page</a>, which is displayed in a very unnatural, select-one-and-hope-it&#8217;s-cool kind of way:</p><p><img class="alignnone size-full wp-image-462" title="Adobe Edge Fonts, Sad Preview :(" src="http://www.toekneestuck.com/content/uploads/2012/09/adobe-edge-fonts-sad-previewer.png" alt="" width="617" height="445" /></p><h2>A Solution (well, a start)</h2><p>I wanted a way to browse many fonts at a time (like on typekit.com for instance), so I made a small project out of it and experimented with creating my own <a title="Edge Fonts Previewer" href="http://edgefonts.toekneestuck.com">Edge Fonts previewer</a>. Yeoman was also recently released, so I used this opportunity to try it out. Below are a list of the tools/frameworks I used:</p><ul><li><a href="http://yeoman.io" target="_blank">Yeoman</a> (and all that comes with it)</li><li><a href="http://requirejs.org" target="_blank">RequireJS</a></li><li><a href="http://lodash.com/" target="_blank">Lodash</a> (an extension of <a href="http://documentcloud.github.com/underscore/" target="_blank">Underscore.js</a>)</li><li><a href="http://documentcloud.github.com/backbone/" target="_blank">Backbone.js</a></li><li><a href="https://github.com/marionettejs/backbone.marionette" target="_blank">Backbone.Marionette</a></li><li><a href="https://github.com/addyosmani/backbone.paginator" target="_blank">Backbone.Paginator</a></li><li><a href="http://jquery.com" target="_blank">jQuery</a></li><li><a href="http://sass-lang.com" target="_blank">Sass</a> &amp; <a href="http://compass-style.org" target="_blank">Compass</a></li></ul><p>If you&#8217;re interested in taking a gander at the code, head on over to the <a href="https://github.com/toekneestuck/edgefonts-preview" target="_blank">github repo</a>. This is an early release just to get something out the door and I plan to add some more features and refine it overall.</p><p class="center"><a class="button important" href="http://edgefonts.toekneestuck.com">Edge Font Previewer</a> <a class="button important" href="https://github.com/toekneestuck/edgefonts-preview">Github Repo</a></p> ]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/09/27/adobe-edge-fonts-previewer/feed/</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>Responsive Columns With LESS/SCSS</title><link>https://www.toekneestuck.com/blog/2012/09/06/responsive-columns-with-less-scss/</link> <comments>https://www.toekneestuck.com/blog/2012/09/06/responsive-columns-with-less-scss/#respond</comments> <pubDate>Thu, 06 Sep 2012 18:00:06 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Responsive]]></category> <category><![CDATA[LESS]]></category> <category><![CDATA[responsive design]]></category> <category><![CDATA[sass]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=451</guid> <description><![CDATA[A simple and reusable set of CSS (less/sass) for responsive columns, so content flows nicely from mobile to desktop. <a href="https://www.toekneestuck.com/blog/2012/09/06/responsive-columns-with-less-scss/" class="more">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;m just now getting around to publishing some of the helpers I&#8217;ve created recently that I found useful (and maybe you will, too).</p><p>So, to start: <strong>Columns</strong>. Almost all of my projects end up needing some combination of columns (without the hassle of grid frameworks), and since I&#8217;ve been building responsive sites, I needed to create something simple and reusable to solve my responsive column problem so that content would flow nicely from mobile to desktop.</p><p>I found that I rarely used anything above 4 columns, so if you need more than that you&#8217;ll see a method to the madness below. I&#8217;ve based my media query breakpoints on the <a href="http://framelessgrid.com/" rel="external">Frameless grid</a> (mobile, wide mobile, tablet, widescreen) and I keep my column-collapsing relative to the number of columns (i.e., I don&#8217;t flow a 3 column layout into 2, but I do flow 4 into 2).</p><p>Having variable gutter spacing between projects was always necessary, so simple set <code>columnGutter</code> to whatever spacing size/unit you prefer and have at it.</p><p>Below is the Sass syntax, but for those interested in LESS, see <a href="https://gist.github.com/3656609" rel="external">this gist</a> for both options.</p><h3>Sass Syntax</h3><pre class="prettyprint linenums">/* Media Queries Assume: 1em = 16px */

/* ================================================= */
/* Helpers
/* ================================================= */
.clearfix{*zoom: 1;&amp;:before,&amp;:after{display:table;content:"";}&amp;:after{clear:both;}}

@mixin box-sizing( $boxmodel ) {
	-webkit-box-sizing: $boxmodel;
	   -moz-box-sizing: $boxmodel;
	    -ms-box-sizing: $boxmodel;
	        box-sizing: $boxmodel;
}

/* ================================================= */
/* Columns
/* ================================================= */
$columnGutter : 20px;

.columns{
	list-style: none;
	margin:0;
	padding:0;
	width:100%;
	@extend .clearfix;

	img,
	input,
	select,
	textarea{
		max-width: 100%;
	}

	&amp; &gt; .column{
		float:left;
		width:100%;
		@include box-sizing(border-box);
	}
	&amp;.two &gt; .column,
	&amp;.col-2 &gt; .column{
		&amp;:nth-child(odd){
			clear: left;
		}
	}
	&amp;.three &gt; .column,
	&amp;.col-3 &gt; .column{
		&amp;:nth-child(3n+1){
			clear: left;
		}
	}
	&amp;.four &gt; .column,
	&amp;.col-4 &gt; .column{
		&amp;:nth-child(4n+1){
			clear: left;
		}
	}
}

/* ================================================= */
/* Mobile layout
/* 240–479 px
/* ================================================= */
@media screen and (min-width: 15em) { /** 16px * 15 = 240px **/
	.columns{
		&amp; &gt; .column{
			margin-bottom: $columnGutter;
		}
	}
}

/* ================================================= */
/* Wide mobile layout
/* 480-599 px
/* ================================================= */
@media screen and (min-width: 30em) { /** 16px * 30 = 480px **/ }

/* ================================================= */
/* Tablet layout
/* 600-959 px
/* ================================================= */
@media screen and (min-width: 37.5em) { /** 16px * 37.5 = 600px **/
	.columns{
		&amp; &gt; .column{
			margin-bottom: $columnGutter * 1.5;
		}
		&amp;.two &gt; .column,
		&amp;.col-2 &gt; .column,
		&amp;.four &gt; .column,
		&amp;.col-4 &gt; .column{
			padding-left: 0;
			padding-right: $columnGutter * (1/2);
			width: 50%;

			&amp;:nth-child(even){
				padding-left: $columnGutter * (1/2);
				padding-right: 0;
			}
		}
	}
}

/* ================================================= */
/* Widescreen layout
/* 960-1079 px
/* ================================================= */
@media screen and (min-width: 60em ) { /** 16px * 60 = 960px **/
	.columns{
		&amp;.three &gt; .column,
		&amp;.col-3 &gt; .column{
			padding-left: $columnGutter * (2/3);
			width: 33.3333333333333%;

			&amp;:first-child,
			&amp;:nth-child(3n+1){
				padding-left: 0;
				padding-right: $columnGutter * (2/3);
			}
			&amp;:nth-child(3n+2){
				padding-left: $columnGutter * (1/3);
				padding-right: $columnGutter * (1/3);
			}
		}

		&amp;.four &gt; .column,
		&amp;.col-4 &gt; .column{
			padding-left: $columnGutter * (3/4);
			width: 25%;

			&amp;:first-child,
			&amp;:nth-child(4n+1){
				padding-left: 0;
				padding-right: $columnGutter * (3/4);
			}
			&amp;:nth-child(4n+2){
				padding-left: $columnGutter * (1/4);
				padding-right: $columnGutter * (2/4);
			}
			&amp;:nth-child(4n+3){
				padding-left: $columnGutter * (2/4);
				padding-right: $columnGutter * (1/4);
			}
		}
	}
}</pre>]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/09/06/responsive-columns-with-less-scss/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>The Science of Hangovers</title><link>https://www.toekneestuck.com/blog/2012/06/30/the-science-of-hangovers/</link> <comments>https://www.toekneestuck.com/blog/2012/06/30/the-science-of-hangovers/#respond</comments> <pubDate>Sat, 30 Jun 2012 15:22:47 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[Random]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=442</guid> <description><![CDATA[A nice simple video that explains what you should and shouldn&#8217;t do to avoid a hangover. Eat fatty food and carbs. Take Advil before you go to bed (not Tylenol). Eat eggs and bananas, and drink juice in the morning. &#8230;]]></description> <content:encoded><![CDATA[<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='663' height='403' src='https://www.youtube.com/embed/Soo4f6e1zCs?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0' allowfullscreen='true'></iframe></span></p><p>A nice simple video that explains what you should and shouldn&#8217;t do to avoid a hangover. Eat fatty food and carbs. Take Advil before you go to bed (not Tylenol). Eat eggs and bananas, and drink juice in the morning. Check.</p> ]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/06/30/the-science-of-hangovers/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>LESS and the @arguments Variable</title><link>https://www.toekneestuck.com/blog/2012/05/15/less-css-arguments-variable/</link> <comments>https://www.toekneestuck.com/blog/2012/05/15/less-css-arguments-variable/#comments</comments> <pubDate>Wed, 16 May 2012 02:27:11 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[LESS]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=417</guid> <description><![CDATA[I&#8217;ve converted all of my CSS workflows into LESS over the past few months and haven&#8217;t looked back. By far one of the best features is parametric mixins, which, in its most common use, takes the pain out of making &#8230;]]></description> <content:encoded><![CDATA[<p>I&#8217;ve converted all of my CSS workflows into <a href="http://lesscss.org" target="_blank">LESS</a> over the past few months and haven&#8217;t looked back. By far one of the best features is <a href="http://lesscss.org/#-parametric-mixins" target="_blank">parametric mixins</a>, which, in its most common use, takes the pain out of making sure you&#8217;ve added all of those pesky browser prefixes for CSS3 properties.</p><p>The one annoyance I&#8217;ve been facing recently is the way the <code>@arguments</code> variable is concatenated with spaces as opposed to commas. This may make sense for most mixins, but there are a few CSS properties where concatenating all of the given arguments with commas makes much more sense, as there can be multiple values for each property—<code>box-shadow</code> and <code>text-shadow</code> for instance. Take a look at <a href="https://gist.github.com/1933613#gistcomment-187472" target="_blank">this Gist comment</a> for an example of what happens.</p><p>There&#8217;s a relatively simple fix of just string escaping your declaration:</p><pre class="prettyprint">.box-shadow(~"1px 1px 2px rgba(0,0,0,0.5), inset -1px -1px 0 rgba(255,255,255,0.5)");</pre><p>However, the nitpicky problem I have with that is: I either have to manually write out my color value or create multiple scoped variables and interpolate them into the string (e.g., <code>~"@{color1}"</code>). What I prefer to do is this:</p><pre class="prettyprint">.box-shadow(1px 1px 2px fadeout(@black, 50%), inset -1px -1px 0 fadeout(@white, 50%));</pre><p>This keeps things easier to read, especially if I were to use a more complex color, and makes less work for me as I don&#8217;t have to think about writing out the <code>rgba()</code> format.</p><p>The example above is what I wanted, so I found a nice little regex that I plopped into a few of my mixins that makes this happen exactly as I needed:</p><pre class="prettyprint linenums">.box-shadow(@shadow, ...) {
  @props: ~`"@{arguments}".replace(/[\[\]]/g, '')`;
  -webkit-box-shadow: @props;
     -moz-box-shadow: @props;
          box-shadow: @props;
}</pre><p>What this does is uses javascript to interpolate the arguments variable and wipes out all brackets, leaving only the commas. To demonstrate more visually, it&#8217;s doing this:</p><pre class="prettyprint">"[1,2,3]".replace(/[\[\]]/g, ''); // returns: "1,2,3"</pre><p>In the end, I understand why it was decided to concat <code>@arguments</code> with spaces instead of commas, part of me just wishes there was a less-hacky way to specify the concatenation options either on a global or scoped level.</p><h5 class="notice">Update: 05/16/2012</h5><p>I just realized when only passing one argument to the mixin (e.g., <code>.box-shadow(1px 1px 2px fadeout(@black, 50%))</code>), LESS builds the arguments variable using space-delimitation in the parameter block instead of commas, so the output looks like this:</p><pre class="prettyprint">box-shadow: 1px, 1px, 2px, rgba(0,0,0,0.5)</pre><p>So, obviously that doesn&#8217;t work. Lame. In the interim I just have two mixins: one for a single property value, and one for multiple values:</p><pre class="prettyprint linenums">.box-shadow(@shadow) {
  -webkit-box-shadow: @shadow;
     -moz-box-shadow: @shadow;
          box-shadow: @shadow;
}
.multi-box-shadow(...) {
  @props: ~`"@{arguments}".replace(/[\[\]]/g, '')`;
  -webkit-box-shadow: @props;
     -moz-box-shadow: @props;
          box-shadow: @props;
}</pre><h5 class="notice" id="the-solution">Update 5/31/12: The Solution!</h5><p>Commenter Vicente created an interesting solution by supplying two arguments (followed by the ellipses), with the second argument having a default value so the <code>@arguments</code> array will always be interpreted correctly:</p><pre class="prettyprint linenums">.box-shadow(@shadowA,@shadowB:transparent 0 0 0, ...) {
    @props: ~`"@{arguments}".replace(/[\[\]]/g, '')`;
    -moz-box-shadow:@props;
    -o-box-shadow:@props;
    -webkit-box-shadow:@props;
    box-shadow:@props;
}</pre><p>The problem I had with this implementation was the mixin creating unnecessary code when passing only one shadow. The output would end up looking like this (shortened for brevity):</p><pre class="prettyprint">box-shadow: 1px, 1px, 2px, rgba(0,0,0,0.5), transparent 0 0 0;</pre><p>In the end it&#8217;s a good idea, so I took it one step further to prevent generating any unnecessary code, finally solving my dilemma with these CSS properties: I used an &#8220;X&#8221; as the default for the second variable and added a little extra to my regex, which will filter out the X (and trailing comma) from the stringified array:</p><pre class="prettyprint linenums">.box-shadow(@shadowA, @shadowB:X, ...){
    @props: ~`"@{arguments}".replace(/[\[\]]|\,\sX/g, '')`;
    -webkit-box-shadow: @props;
       -moz-box-shadow: @props;
         -o-box-shadow: @props;
            box-shadow: @props;
}</pre><p>At last, you can finally add an infinite numbers of box shadows (or any other complex comma separated properties for that matter) via mixins!</p><h5 class="notice" id="part-of-core">Note: 06/25/13, This solution is no longer needed.</h5><p>As commenter Matthew points out, as of the <a href="https://github.com/less/less.js/blob/master/CHANGELOG.md#132">1.3.2</a> release, this solution is no longer needed. LESS now has built-in support for comma-separated values, via semicolon (;) delimiters. An example is below:</p><pre class="prettyprint">.box-shadow(1px 1px 2px fadeout(@black, 50%); inset -1px -1px 0 fadeout(@white, 50%));</pre>]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/05/15/less-css-arguments-variable/feed/</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>Integrating Picturefill.js with WordPress</title><link>https://www.toekneestuck.com/blog/2012/04/22/picturefill-js-wordpress/</link> <comments>https://www.toekneestuck.com/blog/2012/04/22/picturefill-js-wordpress/#comments</comments> <pubDate>Sun, 22 Apr 2012 22:24:07 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[HTML5]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[responsive design]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=402</guid> <description><![CDATA[I recently implemented Scott Jehl&#8217;s picturefill.js into my site and it turned out to be relatively easy with WordPress. This currently only works when using post thumbnails, so it won&#8217;t work for inline images in posts, but maybe I&#8217;ll get to &#8230;]]></description> <content:encoded><![CDATA[<p>I recently implemented <a href="https://github.com/scottjehl/picturefill">Scott Jehl&#8217;s picturefill.js</a> into my site and it turned out to be relatively easy with WordPress.</p><p>This currently only works when using post thumbnails, so it won&#8217;t work for inline images in posts, but maybe I&#8217;ll get to that later. For now, here&#8217;s the small filter I created to convert post thumbnails into <code>&lt;picture&gt;</code> elements:</p><pre class="prettyprint linenums">
/**
* Replace normal &lt;img&gt; tag with custom &lt;picture&gt; polyfill element for responsive images
*
* @uses wp_get_attachment_image_src
*/
function post_thumbnail_picturefill( $html, $post_id, $post_thumbnail_id, $size, $attr ){

    $alt = preg_match('/alt="(.*)"/', $html, $matches);
    $picture_fill_html = '&lt;picture alt="'. $matches[1] .'"&gt;';

    $small = wp_get_attachment_image_src( $post_thumbnail_id, 'thumbnail' );
    $picture_fill_html .= '&lt;!-- &lt;source src="' . $small[0] . '"&gt; --&gt;';
    $picture_fill_html .= '&lt;source src="' . $small[0] . '"&gt;';

    $normal = wp_get_attachment_image_src( $post_thumbnail_id, $size );
    $picture_fill_html .= '&lt;!-- &lt;source src="' . $normal[0] . '" media="(min-width:480px)"&gt; --&gt;';
    $picture_fill_html .= '&lt;source src="' . $normal[0] . '" media="(min-width:480px)"&gt;';

    $large = wp_get_attachment_image_src( $post_thumbnail_id, 'large' );
    $picture_fill_html .= '&lt;!-- &lt;source src="' . $large[0] . '" media="(-webkit-min-device-pixel-ratio:2 and min-width:480px)"&gt; --&gt;';
    $picture_fill_html .= '&lt;source src="' . $large[0] . '" media="(-webkit-min-device-pixel-ratio:2 and min-width:480px)"&gt;';

    $picture_fill_html .= '&lt;noscript&gt;' . $html . '&lt;/noscript&gt;';
    $picture_fill_html .= '&lt;/picture&gt;';

    return $picture_fill_html;
}

add_filter( 'post_thumbnail_html', 'post_thumbnail_picturefill', 10, 5 );</pre><p>What&#8217;s happening here is rather simple: the &#8216;thumbnail&#8217; size I&#8217;ve configured in WordPress is served as the default (no media query), thus the smallest image. Any screen 480px wide and above is served whatever the requested thumbnail size was, followed by loading the WordPress configured &#8216;large&#8217; image for retina displays. You can read more about how the picturefill.js script works on the Github page, but the <code>noscript</code> tag will serve as a fallback and thus I&#8217;m just sending whatever image was going to be printed in the first place.</p><p>This could be extended with better support by adding some more specific image sizes in WordPress that could added here for various breakpoints. I kept it simple here by just providing three options: A small version (the thumbnail), the intended size (whatever the requested thumbnail size was), and a large version (for retina displays).</p> ]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/04/22/picturefill-js-wordpress/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Review: ModKat</title><link>https://www.toekneestuck.com/blog/2012/03/29/modkat-litter-box-review/</link> <comments>https://www.toekneestuck.com/blog/2012/03/29/modkat-litter-box-review/#respond</comments> <pubDate>Thu, 29 Mar 2012 12:35:06 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[Reviews]]></category> <category><![CDATA[modkat]]></category> <category><![CDATA[review]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=384</guid> <description><![CDATA[<p><img width="663" height="495" src="https://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-663x495.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="ModKat - Top View" srcset="http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-602x450.jpg 602w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-1000x746.jpg 1000w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-663x495.jpg 663w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-844x630.jpg 844w" sizes="(max-width: 663px) 100vw, 663px" /></p>April and I bought a ModKat back in January. Soon after, I gave in and we adopted a cat. Okay, not really—she convinced me to adopt the cat first. But anyway, after 2+ months of use and answering questions from &#8230;]]></description> <content:encoded><![CDATA[<p><img width="663" height="495" src="https://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-663x495.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="ModKat - Top View" srcset="http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-602x450.jpg 602w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-1000x746.jpg 1000w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-663x495.jpg 663w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8644-844x630.jpg 844w" sizes="(max-width: 663px) 100vw, 663px" /></p><p><a href="http://twitter.com/aprilmo" target="_blank">April</a> and I bought a <a href="http://www.modko.com/" target="_blank">ModKat</a> back in January. Soon after, I gave in and we adopted a cat. Okay, not really—she convinced me to adopt the cat first. But anyway, after 2+ months of use and answering questions from friends, here are my thoughts:</p><h2>Design</h2><p><img class="alignright size-medium wp-image-388" title="ModKat" src="http://www.toekneestuck.com/content/uploads/2012/03/IMG_8642-336x450.jpg" alt="" width="336" height="450" srcset="http://www.toekneestuck.com/content/uploads/2012/03/IMG_8642-336x450.jpg 336w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8642-597x800.jpg 597w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8642-663x887.jpg 663w, http://www.toekneestuck.com/content/uploads/2012/03/IMG_8642-844x1129.jpg 844w" sizes="(max-width: 336px) 100vw, 336px" />This was one of the primary reasons we bought the ModKat, because let&#8217;s face it—it&#8217;s an expensive litter box. We live in a relatively small apartment, so if we were gonna clutter things up, it had to be in style. Upon first opening, we were slightly intimidated by its physical size—we knew it was gonna be bigger, but when you&#8217;re switching from a &#8220;normal&#8221; box, it&#8217;s a big upgrade. Mostly because of its height. After about 30 seconds though, the feeling goes away.</p><p>The design itself is pretty ingenious. The scooper can be hooked on either side of the hinge to fit in any space you have while keeping the design as clean and minimal as possible. Next is the reusable liner, which is smart because, well.. That just makes sense. The bin itself comes in some sweet (and bright) colors, so it quickly becomes a piece of decor instead of an eyesore.</p><h2>Function</h2><p>Simply put, the thing works. The lid is by far the best feature; we went from sweeping the floor of litter almost daily to nearly no mess at all. Every time the cat jumps out of the box, it&#8217;s inevitable that he lands on the lid first, filtering the litter from his paws. It also helps that cats can&#8217;t kick litter out of the box.</p><p><em>Sidebar—We once found a pile of litter outside of the old litter box because the damn cat (somehow?) MISSED THE ENTIRE LITTER BOX. But at least he had the decency to cover it up..</em></p><p>We got the ModKat when our cat was only 4 months old, so there was literally no break in period—he jumped right in and went about his business.</p><p>Overall, I love it. Yeah, it&#8217;s expensive, but maintenance is easy and it eases the pain of knowing there&#8217;s a bunch of cat poop in your house.</p> ]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/03/29/modkat-litter-box-review/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Rails 3: Empty ActiveRecord Object on Output</title><link>https://www.toekneestuck.com/blog/2012/03/10/rails-empty-object/</link> <comments>https://www.toekneestuck.com/blog/2012/03/10/rails-empty-object/#comments</comments> <pubDate>Sat, 10 Mar 2012 16:35:00 +0000</pubDate> <dc:creator><![CDATA[Tony Stuck]]></dc:creator> <category><![CDATA[Rails]]></category> <category><![CDATA[ActiveRecord]]></category> <category><![CDATA[JSON]]></category><guid isPermaLink="false">http://www.toekneestuck.com/?p=372</guid> <description><![CDATA[I&#8217;ve tried to debug a weird Rails issue I&#8217;ve had with no luck. The Situation When I output a nested relationship object with to_json , I have one association where Rails will output a blank object instead of just an empty &#8230;]]></description> <content:encoded><![CDATA[<p>I&#8217;ve tried to debug a weird Rails issue I&#8217;ve had with no luck.</p><h3>The Situation</h3><p>When I output a nested relationship object with <code>to_json</code> , I have one association where Rails will output a blank object instead of just an empty array. However, if I output the same thing in the Rails console, it&#8217;s an empty array.</p><p>For example: I have a job object, which can have many changes associated with it. So, in a shortened version of my code I have this:</p><pre class="prettyprint linenums">window.job = &lt;% @job.to_json( :include =&gt; {
    :changes =&gt; {
        :include =&gt; [:user]
    }
} ).html_safe %&gt;</pre><h3 class="prettyprint linenums">The Result</h3><p>What this will do is output my Job JSON object, but instead of <code>job.changes &gt;&gt; []</code>, it will be: <code>job.changes &gt;&gt; [{attr_1: null, attr_2: null, attr_3: null}]</code>. Even if I just try to say <code>&lt;%= @job.changes %&gt;</code> it will output:</p><pre class="prettyprint">[#&lt;Change id: nil, job_id: 47, description: "", completed: false, round: nil, completed_by: nil, user_id: nil, created_at: nil, updated_at: nil&gt;]</pre><p>What&#8217;s even more confusing is that even when there <em>are</em> changes, Rails will output an array of those changes with an empty change object in the array.</p><p>The weirder part is when I try to duplicate it in the Rails Console, it doesn&#8217;t happen:</p><pre class="prettyprint">$ &gt; @job = Job.find(47)
  Job Load (0.5ms)  SELECT `jobs`.* FROM `jobs` WHERE `jobs`.`id` = 47 ORDER BY jobs.created_at DESC LIMIT 1
 =&gt; #
$ &gt; @job.changes
Creating scope :page. Overwriting existing method Change.page.
  Change Load (0.3ms)  SELECT `changes`.* FROM `changes` WHERE `changes`.`job_id` = 47 ORDER BY changes.created_at ASC
 =&gt; []
$ &gt; @job.changes
 =&gt; "[]"</pre><p>I&#8217;m not sure if I&#8217;m doing something wrong or if this is a bug in Rails 3.1.3. It doesn&#8217;t seem to happen with any of my other associations. Has anyone else run across this at all?</p> ]]></content:encoded> <wfw:commentRss>https://www.toekneestuck.com/blog/2012/03/10/rails-empty-object/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>