X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=blobdiff_plain;f=stylus-helpers.styl;h=b3769a7db939cfd15d2c4eba233b8da8af12fbb2;hp=15bebc44c959a551f266237cefa34b95fa357e6e;hb=15459c86d0996ab3037b1738a8be6efd378c1258;hpb=9c8566f495179ab2b56aeae0c4ee0222dffd0210 diff --git a/stylus-helpers.styl b/stylus-helpers.styl index 15bebc4..b3769a7 100644 --- a/stylus-helpers.styl +++ b/stylus-helpers.styl @@ -3,7 +3,7 @@ // This file contains helpers for using stylus in your project. // // Put something like this in your styl.styl: -// @require 'code/wfpl/stylus-helpers.styl' +// @require 'inc/wfpl/stylus-helpers.styl' // set units to px if it doesn't have a unit already @@ -21,6 +21,11 @@ box-sizing() -webkit-box-sizing: arguments -moz-box-sizing: arguments box-sizing: arguments +user-select() + -webkit-user-select: arguments + -moz-user-select: arguments + -ms-user-select: arguments + user-select: arguments // map "whitespace:" to "white-space:" whitespace() @@ -44,12 +49,17 @@ fixed() relative() _pos('relative', arguments) +// Specify width and height on the same line +dimensions(w, h) + width: _px(w) + height: _px(h) + // Make children of this element inline-blocks that are spaced evenly accross. // // To create a minimum distance between: don't use word-spacing, it's broken in // firefox. Instead, try padding on the children and negative margin on the // parent. -space_evenly(line_height = 1.2em) +space-evenly(line_height = 1.2em) text-align justify & > * display inline-block @@ -75,25 +85,35 @@ space_evenly(line_height = 1.2em) // html: // // styl: // nav li // sprite-rollover "images/nav.png" 150 35 2 -sprite-rollover(image, width, height, count) - width = unit(width, px) - height = unit(width, px) - width width - height height - background: transparent url(image) top left no-repeat; - for n in (1..count) +sprites-rollover(image, width, height, count, v-offset = 0, h-offset = 0) + width: unit(width, px) + height: unit(height, px) + background-image: url(image) + background-position: top left + background-repeat: no-repeat; + for n in (0...count) &.n{n} - y = (2px - n * 35px) - background-position 0 y + y = - (@height * n) - unit(v-offset, px) + background-position (0 - unit(h-offset, px)) y &:hover - background-position -(width) y + background-position (0 - unit(h-offset, px) - @width) y +// see sprites-rollover +sprites(image, height, count, v-offset = 0, h-offset = 0) + height: unit(height, px) + background-image: url(image) + background-position: top left + background-repeat: no-repeat; + for n in (0...count) + &.n{n} + y = - (@height * n) - unit(v-offset, px) + background-position (0 - unit(h-offset, px)) y // Styling for a variable height element with an image background where the // middle repeats vertically. You must split your image into three images, and @@ -158,3 +178,28 @@ li-reset() margin 0 padding 0 list-style none + +// Example: +// input +// +placeholder() +// color: red +placeholder() + &::-webkit-input-placeholder + {block} + &:-moz-placeholder // firefox 4-18 + {block} + &::-moz-placeholder // firefox 19+ + {block} + &:-ms-input-placeholder // ie + {block} + +// Example: +// div.button +// noselect() +noselect() + -webkit-touch-callout: none + -webkit-user-select: none + -khtml-user-select: none + -moz-user-select: none + -ms-user-select: none + user-select: none