/*
	axiom-template

	helpers.styl

	Author: Sean Goresht

	Placeholders, generated through logic, and some few ones hard-coded.  Generates camelized variables too
*/

use("camelize.js")

directions = top left bottom right

properties = margin padding

proportions = none mini small normal medium large

generatePlaceholder(property, values, prefixed = false)
	if prefixed
		for value in values
			${property}-{value}
				{property} value
	else
		for value in values
			${value}
				{property} value

rules = {
	display: block inline-block inline table flex
	position: fixed absolute static relative
	box-sizing: content-box padding-box border-box
	prefixed: {
		float: left right
		flex-direction: column column-reverse row row-reverse
		text-align: center left right
		vertical-align: top middle bottom
		text-decoration: none underline
		list-style: none
		overflow: hidden ellipsis visible
	}
}

camelize(string)
	to-upper-case("" + substr(string, 0, 1)) + substr(string, 1)

// Generate basic proportion placeholders: ex. small-padding, medium-padding, etc.
for property in properties
	// generate "none" placeholders
	${property}-none
		{property} 0
	for proportion, i in proportions
		define("$" + property + camelize(proportion), unit(i / 3, "em")) // variables are known under $marginSmall, $paddingSmall, and so forth
		${proportion}-{property} // $small-margin
			{property} lookup("$" + property + camelize(proportion)) // margin $marginsmall
		for direction in directions
			${proportion}-{property}-{direction} // $small-margin-top
				{property}-{direction} lookup("$" + property + camelize(proportion)) // small-margin-top
			for direction2 in directions // $normal-margin-top-bottom, etc.
				${proportion}-{property}-{direction}-{direction2}
					{property}-{direction} lookup("$" + property + camelize(proportion))
					{property}-{direction2} lookup("$" + property + camelize(proportion))
			${property}-{$direction}-none
				${property}-{direction} 0

// generate border placeholders
$bordered
	border $borderWidth $borderStyle color-fallback($borderColour)
$bordered-none
	border 0
for direction in directions
	$bordered-{direction}
		border-{direction} $border
	$bordered-{direction}-none
		border-{direction} 0
// generate property placeholders
for property, value in rules
	if property is "prefixed"
		for nestedProperty, nestedValue in value
			generatePlaceholder(nestedProperty, nestedValue, true)
	else
		generatePlaceholder(property, value)

// generate font sizes
for proportion in proportions
	$font-size-{proportion}
		font-size lookup("$fontSize" + camelize(proportion))

$clearfix
	clearfix()

$hide-text
	hide-text()

$hidden
	display none

$transition-all
	transition all $transitionTime $transitionFunction

$hide-phone
	+media-query($breakpointMain)
		display none

$show-phone
	+media-query($breakpointMain)
		display block

$visuallyhidden
	//useful for within a media query
	border 0
	clip rect(0 0 0 0)
	height 1px
	margin -1px
	overflow hidden
	padding 0
	position absolute
	width 1px
	left -500%

/* Default animation (can be overriden) */
$defaultAnimation
	animation-duration $animationDuration
	backface-visibility visible !important
	animation-fill-mode $animationFillMode

generateAnimationPlaceholder(name)
	${name}
		@extend $defaultAnimation
		animation-name: name
// animation delay helpers
$delayed
	for index in (1..$delayElemCount)
		&:nth-child({index})
			animation-delay (($animationDuration / 7) * index)

// media query placeholders
$show-phone
	display none

+media-query($breakpointMain)
	$hide-phone
		display none
	$show-phone
		display block
	$show-phone-inline
		display inline
