Skip to content

Instantly share code, notes, and snippets.

@Undistraction
Last active August 29, 2015 14:07
Show Gist options
  • Save Undistraction/38c63daae90d397095ff to your computer and use it in GitHub Desktop.
Save Undistraction/38c63daae90d397095ff to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.5)
// Compass (v1.0.1)
// ----
// TEST
$debug:null;
@function compress($value) {
$top: nth($value, 1);
$right: nth($value, 2);
$bottom: nth($value, 3);
$left: nth($value, 4);
$debug: #{$top}#{$right}#{$bottom}#{$left} !global;
$result: null;
// All same
@if $top == $right and $right == $bottom and $bottom == $left {
$result: $top;
// top + bottom same
} @else if $top == $bottom {
@if $right == $left {
// left + right same
$result: #{$top} #{$right};
}
}@else if $right == $left {
$result: #{$top} #{$right} #{$bottom};
} @else {
$result: $value;
}
@return $result;
}
.all-different {
padding: compress(1px 2px 3px 4px);
}
.vertical-horizontal {
padding: compress(1px 2px 1px 2px);
}
.top-horizontal-bottom {
padding: compress(1px 2px 3px 2px);
}
.all-different {
padding: 1px 2px 3px 4px;
}
.vertical-horizontal {
padding: 1px 2px;
}
.top-horizontal-bottom {
padding: 1px 2px 3px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment