Skip to content

Instantly share code, notes, and snippets.

@geckotang
Last active December 31, 2015 06:29
Show Gist options
  • Save geckotang/7948358 to your computer and use it in GitHub Desktop.
Save geckotang/7948358 to your computer and use it in GitHub Desktop.
https://github.com/csswizardry/inuit.css/blob/7dbc892f8d298795e19aeb64d1369ae3271561d1/generic/_helper.scss のflushとか書きだすようなmixinだけど要らない気がする。 たぶんいらない。
//@mixin _prop_with_direction
//@description いろんな方向のプロパティを弄るための何か。
//@refs https://github.com/csswizardry/inuit.css/blob/7dbc892f8d298795e19aeb64d1369ae3271561d1/generic/_helper.scss
//
//@param $prefix {String} 生成するclassに付与するprefix。.は必要
//@param $classname {String} 生成するclass名(+方向)
//@param $property {Property} 各方向に指定したいCSSのproperty
//@param $value {Value} 各方向に指定したいCSSのvalue
//@param $direction-list {List} 方向。デフォは('', '-top', '-right', '-bottom', '-left')
//
//@usage
//```
//@include _prop_with_direction(
// '.ex',
// 'push',
// margin,
// 24px !important
//);
//```
//
//以下のように出力される
//
//```
//.ex-push {
// margin: 24px !important;
//}
//.ex-push--top {
// margin-top: 24px !important;
//}
//.ex-push--right {
// margin-right: 24px !important;
//}
//.ex-push--left {
// margin-left: 24px !important;
//}
//.ex-push--right {
// margin-right: 24px !important;
//}
//```
@mixin _prop_with_direction(
$prefix,
$classname,
$property,
$value,
$direction-list: ('', '-top', '-right', '-bottom', '-left')
) {
@each $key in $direction-list {
$chain: if($key!='', '-', '');
#{$prefix + $classname + $chain + $key} {
#{$property + $key}: $value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment