$screen-sm: 768px;
$screen-md: 992px;
$screen-lg: 1200px;
$screen-xl: 1920px;
$cell-num: 24;
$flexs: (
  start:(justify-content:flex-start),
  center:(justify-content:center),
  end:(justify-content:flex-end),
  space-between:(justify-content:space-between),
  space-around:(justify-content:space-around),
  top:(align-items:flex-start),
  middle:(align-items:center),
  bottom:(align-items:flex-end),
);
$screens: (
  xs:(max-width:$screen-sm),
  sm:(min-width:$screen-sm),
  md:(min-width:$screen-md),
  lg:(min-width:$screen-lg),
  xl:(min-width:$screen-xl),
);

@mixin res($key, $map: $screens) {
  // 循环断点Map，如果存在则返回
  @if map-has-key($map, $key) {
    @media only screen and #{inspect(map-get($map, $key))} {
      @content;
    }
  } @else {
    @warn "Undefeined points: `#{$map}`";
  }
}

@include prefix(grid-row) {
  height: auto;
  position: relative;
  margin-right: 0 !important;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;

  &:last-child {
    margin-bottom: 0 !important;
  }

  &, & * {
    box-sizing: border-box;
  }

  /*flex布局*/
  &:before,
  &:after {
    display: flex;
  }

  /*flex布局*/
  @each $flexType, $flexValue in $flexs {
    &.grid-row-flex-#{$flexType} {
      @each $key, $value in $flexValue {
        #{$key}: #{$value}
      }
    }
  }

  /*响应式*/
  @include prefix(grid-col) {
    display: block;
    float: left;

    @for $i from 1 through $cell-num {
      &.grid-col-span-#{$i} {
        width: (1 / $cell-num * $i * 100) * 1%;
      }
      &.grid-col-offset-#{$i} {
        margin-left: (1 / $cell-num * $i * 100) * 1%;
      }
      &.grid-col-pull-#{$i} {
        position: relative;
        right: (1 / $cell-num * $i * 100) * 1%;
      }
      &.grid-col-push-#{$i} {
        position: relative;
        left: (1 / $cell-num * $i * 100) * 1%;
      }
      &.grid-col-order-#{$i} {
        order: $i;
      }
    }

    @each $size, $px in $screens {
      @include res(inspect($size)) {
        @for $i from 1 through $cell-num {
          &.grid-col-#{$size}-#{$i} {
            width: (1 / $cell-num * $i * 100) * 1%;
          }
        }
      }
    }
  }
}

@each $size, $px in $screens {
  @include res(inspect($size)) {
    .hidden-#{$size}-only {
      display: none;
    }
  }
}
