aboutsummaryrefslogtreecommitdiff
path: root/sass/function/_font.sass
blob: 45f8fc399c16813204241b64b8c645236132ad22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
@use "sass:meta"
@use "sass:list"

@function font-append($base, $ext, $font-sep)
  $base-pre : ()
  $base-pos : ()
  $iFontSep : index($base, $font-sep)
  @if not $iFontSep // didn't find the font separator, return
    @debug "⚠ Failed to find '#{$font-sep}' in the list of '#{$base}'"
    @return $base

  @for $i from 1 through list.length($base)
    $iEl: list.nth($base, $i)
    @if $i <= $iFontSep
      $base-pre: list.append($base-pre, $iEl, $separator:comma)
    @else
      $base-pos: list.append($base-pos, $iEl, $separator:comma)

  @return list.join(list.join($base-pre, $ext), $base-pos)

@function font-prepend($base, $ext)
  $ext-type : meta.type-of($ext)

  @if not ($ext-type == 'string') and not ($ext-type == 'list')
    @debug "⚠ Expected a string or a list, but got '#{$ext-type}' in '#{$ext}'"
    @return $base
  @else
    @return list.join($ext,$base)