Sha256: c89c412963b432f49c7343221682dbd11f3f494eddad9d36b85a3b83123eab40

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

/// Convert any string to a "safe" string that can be used anywhere in CSS (as class or keyframe name for example).
/// Unsupported characters are replaced by the given `$delimiter` ("-").
/// Several unsupported characters following each others are replaced by a single delimiter.
///
/// @param {*} $str - String to convert. If not a string, it will be converted to with `quote()`.
/// @param {String} $delimiter ['-'] - Character to use instead of unsupported characters.
/// @return {String} - Safe string usable everywhere in CSS.
@function -mui-string-safe(
  $str,
  $delimiter: '-'
) {
  $str: quote($str);
  $length: str_length($str);
  $safe-chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';

  $ret: '';
  $delimited: false;

  @for $i from 1 through $length {
    $c: str_slice($str, $i, $i);

    @if (str_index($safe-chars, $c) != null) {
      $ret: '#{$ret}#{$c}';
      $delimited: false;
    }
    @else if (($delimited == false)
      and (str_length($ret) > 0)
      and ($i < $length))
    {
      $ret: '#{$ret}#{$delimiter}';
      $delimited: true;
    }
  }

  @return $ret;
}

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
foundation-rails-6.9.0.0 vendor/assets/scss/motion-ui/util/_string.scss
foundation-rails-6.6.2.0 vendor/assets/scss/motion-ui/util/_string.scss
bedrock_sass-0.2.2 assets/_vendor/motion-ui/util/_string.scss
foundation-rails-6.6.1.0 vendor/assets/scss/motion-ui/util/_string.scss
foundation-rails-6.5.3.0 vendor/assets/scss/motion-ui/util/_string.scss
bedrock_sass-0.2.1 assets/_vendor/motion-ui/util/_string.scss
foundation-rails-6.5.1.0 vendor/assets/scss/motion-ui/util/_string.scss
bedrock_sass-0.2.0 assets/_vendor/motion-ui/util/_string.scss