feat: add CompositeIcon struct for nesting SVGs
This commit is contained in:
+2
-1
@@ -21,8 +21,9 @@ impl ColorScheme {
|
||||
.with_context(|| format!("reading {}", path.display()))?;
|
||||
|
||||
if !namespace.is_empty() {
|
||||
let class_re = Regex::new(r#"class=(['"])([^'"]*?)ColorScheme-([^'"]*?)(['"])"#).unwrap();
|
||||
content = class_re.replace_all(&content, format!("class=${{1}}${{2}}{namespace}-ColorScheme-${{3}}${{4}}").as_str()).into_owned();
|
||||
content = content.replace(".ColorScheme-", &format!(".{namespace}-ColorScheme-"));
|
||||
content = content.replace("class=\"ColorScheme-", &format!("class=\"{namespace}-ColorScheme-"));
|
||||
}
|
||||
|
||||
let colors = parse_colors(&content);
|
||||
|
||||
@@ -25,16 +25,15 @@ impl CompositeIcon {
|
||||
|
||||
pub fn render(&self) -> String {
|
||||
if let Some(emblem) = &self.emblem {
|
||||
use base64::prelude::*;
|
||||
let bg_b64 = BASE64_STANDARD.encode(&self.bg.content);
|
||||
let emblem_b64 = BASE64_STANDARD.encode(&emblem.content);
|
||||
format!(
|
||||
r#"<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg x="0" y="0" width="64" height="64" overflow="visible">
|
||||
{}
|
||||
</svg>
|
||||
<svg x="{}" y="{}" width="{}" height="{}" overflow="visible">
|
||||
{}
|
||||
</svg>
|
||||
<image x="0" y="0" width="64" height="64" href="data:image/svg+xml;base64,{}" />
|
||||
<image x="{}" y="{}" width="{}" height="{}" href="data:image/svg+xml;base64,{}" />
|
||||
</svg>"#,
|
||||
self.bg.content, self.emblem_x, self.emblem_y, self.emblem_size, self.emblem_size, emblem.content
|
||||
bg_b64, self.emblem_x, self.emblem_y, self.emblem_size, self.emblem_size, emblem_b64
|
||||
)
|
||||
} else {
|
||||
self.bg.content.clone()
|
||||
|
||||
Reference in New Issue
Block a user