> For the complete documentation index, see [llms.txt](https://yamoo9.gitbook.io/scss-mixins/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yamoo9.gitbook.io/scss-mixins/mixins/css-grid/grid-container/grid-container-append/grid-rows.md).

# grid-rows()

## 용도 <a href="#use" id="use"></a>

[grid-template-rows](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows) 속성을 빠르고 효율적으로 처리할 때 사용하는 믹스인입니다.

| 믹스인에서 사용되는 값                                        | 컴파일 되는 표준 속성       |
| --------------------------------------------------- | ------------------ |
| `2` 또는 `none` 또는 `auto` 또는 `1fr repeat(2, 2fr) 1fr` | grid-template-rows |

{% hint style="info" %}
grid-rows() 믹스인은 [grid-container-append()](/scss-mixins/mixins/css-grid/grid-container/grid-container-append.md) 믹스인 내부에서 활용되는 작은 모듈입니다.
{% endhint %}

## 사용법 <a href="#usage" id="usage"></a>

`grid-rows()` 믹스인에 설정 가능한 값을 전달합니다.

> grid-rows($value:**\[string, number]**)

```javascript
.usage {
  @include grid-rows(2); 
  // CSS 컴파일 결과
  // grid-template-rows: repeat(2, minmax(0, 1fr));
}
```

| 매개변수(parameter) |      유형(type)     | 필수(required) | 기본 값(default) |
| :-------------: | :---------------: | :----------: | :-----------: |
|      $value     | \[string, number] |      ✔︎      |               |

## 로직 <a href="#logic" id="logic"></a>

`grid-rows()` 믹스인은 다음의 로직에 의해 작성되었습니다.&#x20;

```javascript
@mixin grid-rows($value: null) {
  // 아무런 값을 전달 받지 않은 경우
  @if $value == null {
    @error 'grid-rows() 믹스인 사용 시, 숫자 또는 none, 단위 있는 숫자, 리스트 값을 전달해야 합니다.';
  }

  // none 값을 전달 받은 경우
  @if $value == 'none' {
    grid-template-rows: none;
  }

  $type: type-of($value);
  $unitless-value: unitless($value);

  // 단위 없는 숫자 값만 전달받은 경우
  @if $type == 'number' and $unitless-value {
    grid-template-rows: repeat($value, minmax(0, 1fr));
  }

  // 단위가 있는 숫자 또는 리스트 값을 전달받은 경우
  @if $type == 'number' and not $unitless-value or $type == 'list' {
    grid-template-rows: $value;
  }
}
```

1. 전달 받은 인자 값이 `none` 키워드 또는 숫자, 리스트 유형일 경우, 개별 조건 처리
2. 조건 유형에 맞지 않을 경우, 오류 메시지 출력

## 참고 <a href="#reference" id="reference"></a>

믹스인에 사용된 Sass의 빌트인 모듈은 다음과 같습니다.

* [@mixin / @include](https://sass-lang.com/documentation/at-rules/mixin)
* [@if / @else](https://sass-lang.com/documentation/at-rules/control/if)
* [type-of()](https://sass-lang.com/documentation/modules/meta#type-of)
* [unitless()](https://sass-lang.com/documentation/modules/math#is-unitless)
