diff --git a/axis/images.styl b/axis/images.styl new file mode 100644 index 0000000..6cd9d03 --- /dev/null +++ b/axis/images.styl @@ -0,0 +1,98 @@ +// Mixin: Bg +// +// Makes background (with image) declarations a little simpler. Use this with +// the global img-path variable to set a base image path that you don't have to +// keep repeating. Also sets 'no-repeat' as the default background-repeat. +// +// ex. bg: 'test.png' +// ex. bg: 'other.jpg' center center repeat + +bg(path, args...) + args = unquote('no-repeat') unless args + background: url(img-path path) args + +// Mixin: bg-retina +// +// Make sure the image path is double the size, pass it halved numbers, and +// you're in the retina-clear. +// +// ex. bg-retina: 'test.png' 200px 100px +// ex. bg-retina: 'other.jpg' 100px 50px center center repeat + +bg-retina(path, width, height, args...) + args = unquote('no-repeat') unless args + set_size = false + + for arg in args + if arg == 'no-repeat' + set_size = true + + background: url(img-path path) args + background-size: width height + + if set_size + size: width height + +// Mixin: Image Replace +// +// Image replacement. Pass it an image path and the image's dimensions and any +// text will be hidden in the div and it will show an image instead. Uses the +// fanciest new method, props to Paul Irish. Only works when called as a +// function with parens. Do not try to do it with a colon! +// +// ex. ir('test.jpg', 200 400) + +image-replace(path, dimensions...) + dimensions = dimensions[0] + font: 0/0 a + text-shadow: none + color: transparent + bg: path if path + if length(dimensions) > 1 + width: unit(dimensions[0], 'px') + height: unit(dimensions[1], 'px') + else + warn("Make sure you also pass the image dimensions. Example: ir('/img/whatever.jpg', 200px 400px)") + +// Alias: ir +ir = image-replace + +// Function: cached-image-url +// +// An alternative to url() that stores images in a cache for use in +// cache-images(). + +background-images = null + +cached-image-url() + base = '' + s = unquote('url("' + base + join('', arguments) + '")') + push(background-images, s) unless s in background-images + url(arguments) + +// Mixin: Cache Images +// Use this at the end of all your styles outputs the image cache script. + +cache-images() + body:after + display: none + content: background-images + +// Mixin: Sprite +// +// Given a direction in which your sprites are aligned (horizontal/vertical) and +// an iteration, will measure the width/height of your first sprite frame and +// step through to the nth next one, depending on the given iteration number. +// Width/height must be defined for this to work (as is the case for any sprite) +// +// ex. sprite: 2 +// ex. sprite: 5 'horizontal' +// +// TODO: Try using image-size here if @width or @height aren't defined + +sprite(iteration, orientation='vertical') + if orientation == 'vertical' + background-position: 0 unit(@height*-1*iteration, 'px') + else if orientation == 'horizontal' + // warn(unit(@width*iteration, 'px')) + background-position: unit(@width*iteration, 'px') 0 diff --git a/axis/index.styl b/axis/index.styl index cb6cd0b..4704d80 100644 --- a/axis/index.styl +++ b/axis/index.styl @@ -7,7 +7,9 @@ @import 'vendor' @import 'utilities' @import 'gradients' +@import 'images' @import 'interaction' +@import 'layout' @import 'typography' @import 'code' @import 'ui' diff --git a/axis/layout.styl b/axis/layout.styl new file mode 100644 index 0000000..0eadb9e --- /dev/null +++ b/axis/layout.styl @@ -0,0 +1,114 @@ +// Alias: group +// Clearfix with a better name. Excellent for wrangling floats. + +group = clearfix + +// Mixin: Columns +// +// For css3 columns. Takes column count (int), column gap (px, em), column width +// (px, em), and a border-like declaration if you want a column rule. This +// follows exactly with the css3 spec, it's just quicker. +// +// ex. columns() +// ex. columns: 5 +// ex. columns(8, 15px, 200px, '1px solid red') + +columns(count=3, gap=30px, width=null, rule=null) + column-count: count + column-gap: gap + column-width: width if width + column-rule: unquote(rule) if rule + +// Mixin: Avoid Column Break +// +// If you have a list that is broken into columns, this will make sure that the +// list item is not split across columns awkwardly. Works only in webkit at the +// moment. +// +// ex. avoid-column-break() + +avoid-column-break() + column-break-inside: avoid + +// Alias: Inline Block +// Cross browser inline block display. Saves many IE headaches. + +inline-block() + display: inline-block + + if support-for-ie + display: -moz-inline-stack + vertical-align: baseline + zoom: 1 + *display: inline + *vertical-align: auto + +// Mixin: Vertically Align +// Cross browser vertical align. Works down to IE9. +// +// ex. vertically-align() or reset it with vertically-align(false) + +vertically-align(reset = null) + if reset != false + position: relative + top: 50% + transform: translateY(-50%) + else + position: relative + top: 0 + transform: translateY(0) + +// Mixin: Media +// +// Based on Nicole Sullivan's media class, made famous by Facebook +// http://www.stubbornella.org/content/2010/06/25/the-media-object-saves- +// hundreds-of-lines-of-code +// +// Put this on a parent and it will split the first two children left and right, +// like you would with perhaps a comment with an avatar to the left. Pass it a +// margin between the two. Explained fully here: +// http://carrotblog.com/css-patterns-evolved/ +// +// This mixin works right when the element you apply it to has two or three +// direct children. The first one will float to the left, the second one will be +// to the right of the first, and third will go farthest right. +// +// ex. media() +// ex. media: 15px +// ex. media: 15px 10px + +media(margin=10px) + + left-margin = margin + right-margin = margin + + if length(arguments) > 1 + left-margin = arguments[0] + right-margin = arguments[1] + + overflow: hidden + zoom: 1 + + & > * + inline-block() + overflow: hidden + & > *:first-child + float: left + margin-right: right-margin + & > *:nth-child(3) + float: right + margin-left: left-margin + +// Mixin: Ratio Box +// Set a specific width/height ratio. Useful on background images and iframes. + +ratio-box(ratio = 1/1) + ratio = remove-unit(ratio) + overflow: hidden + position: relative + + &:before + content: '' + display: block + height: 0 + padding-top: (1 / ratio) * 100% diff --git a/axis/reset.styl b/axis/reset.styl index 453c168..7e95e9e 100644 --- a/axis/reset.styl +++ b/axis/reset.styl @@ -166,3 +166,16 @@ fluid-media() border: 0 -ms-interpolation-mode: bicubic display: block + +// Mixin: Border Box HTML +// Add border box to every element in your project. Used in your project root. +// http://www.paulirish.com/2012/box-sizing-border-box-ftw/ + +border-box-html() + html + box-sizing: border-box + + *, + *:before, + *:after + box-sizing: inherit diff --git a/axis/typography.styl b/axis/typography.styl index 2ee05cf..7b264dc 100644 --- a/axis/typography.styl +++ b/axis/typography.styl @@ -2,9 +2,54 @@ // Typography // ---------- +// Alias: Bold +// It's just faster to type bold() than font-weight: bold + +bold() + font-weight: bold + +// Alias: Italic +// It's just faster to type italic() than font-style: italic + +italic() + font-style: italic + +// Alias: Normal +// Put the font-weight and style back to normal + +normal() + font-weight: normal + font-style: normal + +// Mixin: Raquo +// +// Because technically raquo is not semantic, it's better to add it like this. +// +// ex. raquo() + +raquo() + &:after + content: " \00BB" + +// Mixin: Font Face +// +// Super simple font-face declaration. Just give the name and the folder it +// lives in. Make sure the font name matches the name of the files. Uses the +// fontspring syntax: +// http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax +// +// ex. font-face(proxima-nova, '/fonts') + +font-face(name, folder, weight='normal', style='normal') + @font-face + font-family: name + src: url(folder unquote('/') name unquote('.eot') '?#iefix') format('embedded-opentype'), url(folder unquote('/') name unquote('.woff')) format('woff'), url(folder unquote('/') name unquote('.ttf')) format('truetype'), url(folder unquote('/') name unquote('.eot') unquote('#') name) format('svg'); + font-weight: unquote(weight) + font-style: unquote(style) + // Function: Line Height -// -// If there is a font-size set on the parent element, adjusts the line height to +// +// If there is a font-size set on the parent element, adjusts the line height to // match that. If not, it uses the base font-size to calculate the line-height. -line-height() @@ -15,10 +60,10 @@ line-height: 1.6rem // Mixin: Text Margin -// +// // Puts nice visually pleasing top and bottom margins on a paragraph of text. // Put a font-size on your element to have it adjust accordingly. -// +// // ex. p // font-size: 18px // text-margin() @@ -30,10 +75,10 @@ text-margin(size=font-size) margin: unit(font-size*.75, 'px') 0 // Mixin: Paragraph -// +// // Sets a nice size, line-height, and margins on a paragraph of text. Pass a // size in to customize. Toggle margins off if you don't want them. -// +// // ex. p() // ex. p: 18px // ex. p: 14px false @@ -87,9 +132,9 @@ reset-case() text-transform: none // Mixin: Small -// +// // Makes your text smaller and a little lighter. Great on tags. -// +// // ex. small() small() @@ -110,12 +155,12 @@ small() openTypeLigatures() if ligatures // Mixin Set: h1, h2, h3, h4, h5, h6 -// +// // These provide nice defaults for headings based off the default font size. // The can scale infinitely, and work best when matched to their corresponding // html elements. If you'd like to change the base size of a header, just pass // it as an option. -// +// // ex. h3() // ex. h3: 3.5 @@ -139,11 +184,11 @@ h6(size=0.9) upcase() // Mixin: Link -// +// // A nice default style for links. Accepts a color and a style. Color can be // anything, style can be underline, darken, lighten, or glow, each giving it a // different style of interaction when hovered. More suggestions here welcome. -// +// // ex. link() // ex. link: green // ex. link: #57777E 'glow' @@ -165,12 +210,12 @@ link(color=blue, style='underline') else if style == 'glow' &:hover text-shadow: 0 0 7px rgba(color, .6) - + &:visited opacity: .8 // Mixin: Reset Link -// +// // Sometimes my link mixin of the browser defaults will give you questionable // link defaults that you don't want on certain elements. This guy gets rid of // that. @@ -181,17 +226,17 @@ reset-link() border: none text-decoration: none color: initial - + &:hover border: none text-decoration: none color: initial - + &:visited opacity: 1 // Mixin: Text Selection -// +// // This guy sets the text select color intelligently based on the // highlight-color variable found in the settings file. If you really want, you // can pass it a color override too. @@ -204,17 +249,17 @@ text-selection(color=highlight-color, textColor=null) &::-moz-selection background: color color: textColor - + &::selection background: color color: textColor // Mixin: Ul -// +// // A nice default for list styles. More or less the same as browser defaults, // scales nicely. You can pass it any style that list-style-type would normally // take. Defaults to disc. Use this on a ul element por favor. -// +// // ex. ul() // ex. ul: 'square' @@ -229,11 +274,11 @@ ul(style='disc') padding: 0.125rem // Mixin: Ol -// +// // A nice default for list styles. More or less the same as browser defaults, // scales nicely. You can pass it any style that list-style-type would normally // take. Defaults to decimal. Use this on a ol element por favor. -// +// // ex. ol() // ex. ol: 'upper-roman' @@ -248,10 +293,10 @@ ol(style='decimal') padding: 0.125rem // Mixin: Inline List -// +// // For when you need your list to be horizontal. Pass it the spacing you want // between list elements, whatever units you'd like. Defaults to 20px. -// +// // ex. inline-list() // ex. inline-list: 15px @@ -269,11 +314,11 @@ inline-list(spacing=20px) margin-right: 0 // Mixin: Reset List -// +// // If you're tired of all the list shenanigans and want to get rid of them for // this special list you're working on, this is your guy. Resets the margins, // padding, and style. -// +// // ex. reset-list() reset-list() @@ -287,11 +332,11 @@ reset-list() margin: 0 // Mixin: Blockquote -// +// // Nice styles for a blockquote, and even puts a nice hyphen in before your // citation. Use with a

and ,