tools/common (template): add id argument to _icon_use

This commit is contained in:
Goffi 2023-06-07 22:26:54 +02:00
commit 620f89f589

View file

@ -955,11 +955,18 @@ class Renderer(object):
defs_elt.append(icon_svg_elt)
return safe(etree.tostring(svg_elt, encoding="unicode"))
def _icon_use(self, name, cls=""):
return safe('<svg class="svg-icon{cls}" xmlns="http://www.w3.org/2000/svg" '
def _icon_use(self, name, cls="", id=""):
if id:
id = id.replace('"', '_')
return safe('<svg class="svg-icon{cls}"{id} xmlns="http://www.w3.org/2000/svg" '
'viewBox="0 0 100 100">\n'
' <use href="#{name}"/>'
'</svg>\n'.format(name=name, cls=(" " + cls) if cls else ""))
'</svg>\n'.format(
name=name,
cls=(" " + cls) if cls else "",
id=f' id="{id}"' if id else ""
)
)
def _icon_from_client(self, client):
"""Get icon name to represent a disco client"""