@euid/scss-mixins
  • Sass 믹스인 라이브러리
  • Getting Started
    • 시작하기
    • 환경 구성
    • 변경 이력
    • VS Code 확장
  • Utilities
    • 단위 (Unit)
      • rem()
      • em()
      • unitless-px()
      • remove-unit()
      • get-number-or-string()
    • 컬러 (Color)
      • get-color()
      • get-color-name()
      • has-color()
      • alt-color()
      • a11y-color()
      • light-or-dark()
      • color-contrast()
      • most-legible-color()
    • 문자 (String)
      • str-replace()
      • str-split()
      • str-to-num()
      • str-repeat()
      • str-extract-count-keyword()
    • 리스트 (List)
      • first()
      • last()
      • copy-list()
      • merge-list()
      • get-value-after-key()
      • get-match-value-of-keys()
    • 검사 (Validation)
      • is-valid-types()
      • is-valid-keywords()
      • is-include-items()
    • 이징 (Easing)
      • ease()
      • ease-add()
      • ease-merge()
  • Mixins
    • 폰트 (Font)
      • font()
      • font-face()
      • font-size-padding()
    • 텍스트 (Text)
      • text()
      • text-ellipsis()
    • 간격 (Spacing)
      • margin()
      • m()
      • mx()
      • my()
      • padding()
      • p()
      • px()
      • py()
      • space()
      • s()
      • sx()
      • sy()
    • 디스플레이 (Display)
      • show()
      • hide()
      • order()
    • 포지션 (Position)
      • position()
      • relative()
      • absolute()
      • fixed()
      • sticky()
      • static()
    • 플렉스박스 (Flexbox)
      • Flex 컨테이너(Container)
        • flex-container()
        • flex-container-append()
      • Flex 아이템(Item)
        • flex-item()
        • flex()
    • CSS 그리드 (Grid)
      • Grid 컨테이너(Container)
        • grid-container()
        • grid-container-append()
          • grid-rows()
          • grid-cols()
          • grid-auto()
            • auto-rows()
            • auto-cols()
            • auto-flow()
          • grid-areas()
          • gap()
      • Grid 아이템(Item)
        • grid-item()
        • grid-area()
        • grid-row()
          • row-start()
          • row-end()
          • row-span()
        • grid-col()
          • col-start()
          • col-end()
          • col-span()
    • 박스 정렬 (Box Alignment)
      • box-alignment()
      • place()
        • content()
        • items()
        • self()
      • justify-content()
      • align-content()
      • justify-items()
      • align-items()
      • justify-self()
      • align-self()
    • 반응형 웹 (Rsponsive Web)
      • media()
      • rwd-img()
      • rwd-video()
      • rwd-iframe-wrapper()
    • 이니셜라이즈 (Initialize)
      • initialize()
      • normalize()
      • reset-box()
      • reset-box-sizing()
      • reset-img()
      • reset-link()
      • reset-list()
      • reset-dl()
      • reset-abbr()
      • reset-button()
    • 인터페이스 (Interface)
      • appearance()
      • selection()
      • scrollbar()
    • 접근성 (Accessibility)
      • a11y-hidden()
      • focus-visible()
    • 상속 (Inheritance)
      • inherit-box-sizing()
      • inherit-pseudo-elements()
    • 폼 (Form)
      • button()
      • input()
      • radio()
      • search()
      • checkbox()
      • placeholder()
      • textarea()
      • select()
      • select-multiple()
Powered by GitBook
On this page
  • 용도
  • 사용법
  • 로직
  • 참고

Was this helpful?

  1. Utilities
  2. 문자 (String)

str-repeat()

문자 반복 출력 유틸리티 함수

용도

문자를 특정 횟수만큼 반복해서 출력할 때 사용합니다.

사용법

str-repeat() 함수에 반복할 숫자, 반복할 문자를 전달합니다.

str-repeat($count:number, $text:string) → string

@debug str-split(".img, .button", ","); // ".img" ".button" 반환

매개변수(parameter)

유형(type)

필수(required)

기본 값(default)

$count

number

✔︎

$text

string

✔︎

로직

str-repeat() 유틸리티는 다음의 로직에 의해 작성되었습니다.

@function str-repeat($count: null, $text: null) {
  // 전달 인자 유효성 검사
  @if type-of($count) != 'number' {
    @error 'str-repeat() 믹스인은 첫번째 인자로 숫자 값만 전달 받을 수 있습니다.';
  }
  @if type-of($text) != 'string' {
    @error 'str-repeat() 믹스인은 두번째 인자로 문자 값만 전달 받을 수 있습니다.';
  }

  // 반복 텍스트 변수
  $repeat-text: '';

  // 반복 횟수만큼 문자 반복 접합 처리
  @for $i from 1 through $count {
    $repeat-text: str-insert($repeat-text, '#{$text} ', 1);
  }

  // 끝 공백 제거
  @return str-slice($repeat-text, 1, -2);
}
  1. 전달 받은 인자 값을 검사하여 요구되는 유형이 아닌 경우 오류 메시지 출력

  2. 전달 받은 반복 횟수 만큼 전달 받은 텍스트를 반복해서 접합

  3. 마지막 공백을 제거한 텍스트 반환

참고

유틸리티 함수 로직에 사용된 Sass 빌트인 모듈은 다음과 같습니다.

Previousstr-to-num()Nextstr-extract-count-keyword()

Last updated 4 years ago

Was this helpful?

@function
@if / @else
@error
@for
type-of()
str-insert()
str-slice()