details: https://code.tryton.org/tryton/commit/7173c77acabb
branch: default
user: Cédric Krier <[email protected]>
date: Tue Dec 02 13:39:07 2025 +0100
description:
Make icon badge independent of the view box of the SVG
diffstat:
tryton/tryton/common/common.py | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r d3c356d9a99a -r 7173c77acabb tryton/tryton/common/common.py
--- a/tryton/tryton/common/common.py Thu Oct 02 09:44:58 2025 +0200
+++ b/tryton/tryton/common/common.py Tue Dec 02 13:39:07 2025 +0100
@@ -138,6 +138,10 @@
ET.register_namespace('', 'http://www.w3.org/2000/svg')
root = ET.fromstring(data)
root.attrib['fill'] = color
+ if view_box := root.attrib.get('viewBox'):
+ min_x, min_y, width, height = map(
+ float, view_box.split(' '))
+ factor = max(width, height) / 24
if badge:
if not isinstance(badge, str):
try:
@@ -145,9 +149,9 @@
except IndexError:
badge = color
ET.SubElement(root, 'circle', {
- 'cx': '20',
- 'cy': '4',
- 'r': '4',
+ 'cx': str(20 * factor + min_x),
+ 'cy': str(4 * factor + min_y),
+ 'r': str(4 * factor),
'fill': badge,
})
data = ET.tostring(root)