From ab29d725320ff8e883394aee536ea37b74018009 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 13 Dec 2021 00:51:39 +0100 Subject: chore: define Sass functions, mixins, placeholders and variables --- src/styles/abstracts/functions/_encode.scss | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/styles/abstracts/functions/_encode.scss (limited to 'src/styles/abstracts/functions/_encode.scss') diff --git a/src/styles/abstracts/functions/_encode.scss b/src/styles/abstracts/functions/_encode.scss new file mode 100644 index 0000000..4350185 --- /dev/null +++ b/src/styles/abstracts/functions/_encode.scss @@ -0,0 +1,14 @@ +@use "str-replace" as fun; + +/// Encode a SVG. +/// @param {String} $svg A complete svg (`...`). +/// @return The encoded svg, ready to use for background-image. +@function encode-svg($svg) { + $svg-encoding: (("<", "%3C"), (">", "%3E"), ("#", "%23")); + + @each $char, $encoded in $svg-encoding { + $svg: fun.str-replace($svg, $char, $encoded); + } + + @return "data:image/svg+xml;utf8," + $svg; +} -- cgit v1.2.3