# justify-self()

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

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

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

`justify-self()` 믹스인에 정렬 키워드를 전달합니다. (`flex` 모드 옵션 설정 가능)

> justify-self($valu&#x65;**:string**, $mod&#x65;**:string**)

```ruby
.usage {
  @include justify-self(stretch);
}
```

| 매개변수(parameter) | 유형(type) | 필수(required) | 기본 값(default) |
| :-------------: | :------: | :----------: | :-----------: |
|      $value     |  string  |      ✔︎      |               |
|      $mode      |  string  |              |     `grid`    |

위 예시 코드는 아래의 CSS로 컴파일 되어 출력됩니다.

```css
.usage {
  justify-self: stretch;
}
```

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

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

```ruby
@mixin justify-self($value, $mode: grid) {
  @if $value == 'auto' {
    justify-self: auto;
  }
  @if $value == 'normal' {
    justify-self: normal;
  }
  @if $value == 'stretch' {
    justify-self: stretch;
  }

  @if $value == 'start' {
    justify-self: if($mode == grid, start, flex-start);
  }
  @if $value == 'end' {
    justify-self: if($mode == grid, end, flex-end);
  }
  @if $value == 'center' {
    justify-self: center;
  }
  @if $value == 'left' {
    justify-self: left;
  }
  @if $value == 'right' {
    justify-self: right;
  }

  @if $value == 'baseline' {
    justify-self: baseline;
  }
  @if $value == 'first-baseline' {
    justify-self: first baseline;
  }
  @if $value == 'last-baseline' {
    justify-self: last baseline;
  }

  @if $value == 'safe' {
    justify-self: safe center;
  }
  @if $value == 'unsafe' {
    justify-self: unsafe center;
  }

  @if $value == 'inherit' {
    justify-self: inherit;
  }
  @if $value == 'initial' {
    justify-self: initial;
  }
  @if $value == 'unset' {
    justify-self: unset;
  }
}
```

1. 전달 받은 인자 값을 분석해 내부적으로 조건 처리
2. 조건과 일치하는 경우, 코드 출력

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

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

* [@mixin / @include](https://sass-lang.com/documentation/at-rules/mixin)
* [if()](https://sass-lang.com/documentation/modules#if)
