From 9c38938bf4b20243fb4374c6744612966fd4e1d0 Mon Sep 17 00:00:00 2001 From: Adam Piontek Date: Sun, 25 Jul 2021 09:44:34 -0400 Subject: [PATCH] improve & simplify inline svg handling --- assets/css/_svg-icons.scss | 39 +++++++++++++++++++++++--------------- custom-functions.php | 5 +++-- header.php | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/assets/css/_svg-icons.scss b/assets/css/_svg-icons.scss index 4fdeb17..babac9e 100644 --- a/assets/css/_svg-icons.scss +++ b/assets/css/_svg-icons.scss @@ -20,20 +20,29 @@ position: relative; } -// for navbar-brand logo, could be used for other non-icon SVGs with an extra class to controll the size -.logo { - display: inline-flex; - align-self: center; -} +// // for navbar-brand logo, could be used for other non-icon SVGs with an extra class to controll the size +// .logo { +// display: inline-flex; +// align-self: center; +// } -.logo svg, -.logo img { - height: 5.3rem; - fill: currentColor; -} +// .logo svg, +// .logo img { +// height: 5.3rem; +// fill: currentColor; +// } -.logo.baseline svg, -.logo img { - top: 0.15em; - position: relative; -} +// .logo.baseline svg, +// .logo img { +// top: 0.15em; +// position: relative; +// } + +svg { + &.img { + fill: currentColor; + &.header-logo { + height: 5.3rem; + } + } +} \ No newline at end of file diff --git a/custom-functions.php b/custom-functions.php index ffa49a5..720934d 100644 --- a/custom-functions.php +++ b/custom-functions.php @@ -25,13 +25,14 @@ function inline_svg( $svg_role_img = false, $svg_aria_hidden = true) { $svg_content = file_get_contents( get_template_directory_uri() . '/dist/images/' . $svg_name . '.svg' ); - $to_replace = $svg_class == '' ? 'class="{{class-name}}"' : '{{class-name}}'; + $to_replace = $svg_class == '' ? 'class="{{class-placeholder}}"' : '{{class-placeholder}}'; $svg_content = str_replace($to_replace, $svg_class, $svg_content); $svg_content = $svg_role_img ? str_replace('
' . $svg_content . '
'; + $svg_content = $div_class == '' ? $svg_content : '
' . $svg_content . '
'; + return $svg_content; }; ?> \ No newline at end of file diff --git a/header.php b/header.php index 212028e..3ba8546 100644 --- a/header.php +++ b/header.php @@ -52,7 +52,7 @@ namespace WP_RDNYC; // esc_html( get_bloginfo( 'name' ) ) // ); // echo svg_logo_use("rdnyc-logo", "", "Recovery Dharma New York City"); - echo inline_svg( 'svg-rdnyc-logo', 'logo', '', 'Recovery Dharma New York City', true, false ); + echo inline_svg( 'svg-rdnyc-logo', '', 'img header-logo', 'Recovery Dharma New York City', true, false ); // echo ''; // echo str_replace("{{class-name}}", 'logo', // file_get_contents( get_template_directory_uri() . '/dist/images/svg-rdnyc-logo.svg' ));