mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
Add color-adjustable SVG string support
This commit is contained in:
@@ -40,3 +40,24 @@ sort_time_asc = '\uf0de'
|
||||
sort_time_dsc = '\uf0dd'
|
||||
style_apply = '↶'
|
||||
style_save = '↷'
|
||||
|
||||
class SVGSymbol:
|
||||
def __init__(self, svg: str):
|
||||
self.svg = svg
|
||||
self.before = ""
|
||||
self.after = ""
|
||||
self.supports_color = False
|
||||
if "currentColor" in self.svg:
|
||||
self.supports_color = True
|
||||
self.before, self.after = self.svg.split("currentColor", maxsplit=1)
|
||||
|
||||
def color(self, color: str):
|
||||
if self.supports_color:
|
||||
return self.before + color + self.after
|
||||
else:
|
||||
return self.svg
|
||||
|
||||
def __str__(self):
|
||||
return self.svg
|
||||
|
||||
svg_bullet = SVGSymbol("<svg style='stroke:currentColor;fill:none;stroke-width:2;' viewBox='0 0 16 16'><circle cx='8' cy='8' r='7'/></svg>")
|
||||
|
||||
Reference in New Issue
Block a user