#!/usr/bin/env python3 """Contact sheet of svg/ in both themes at 16/20/26/64 px, resolving roles through palette.toml. usage: preview.py (serve the design dir and open the html)""" import sys, glob, os, tomllib import icon_palette d, out = sys.argv[1], sys.argv[2] palette = tomllib.load(open(d + '/palette.toml', 'rb')) aliases = tomllib.load(open(d + '/aliases.toml', 'rb')).get('alias', {}) def themed(svg, theme, icon, family, size): _, accent = icon_palette.resolve(palette, aliases, icon) return icon_palette.themed(svg, palette, theme, accent, namespace='preview-' + family + '-' + icon + '-' + theme + '-' + str(size)) h = '' for theme in ('light', 'dark'): for fam in sorted(os.listdir(d + '/svg')): h += '

%s - %s

' % (theme, fam, theme) for f in sorted(glob.glob('%s/svg/%s/*.svg' % (d, fam))): svg, icon = open(f).read(), os.path.basename(f)[:-4] h += '
' h += '
%s
' % themed(svg, theme, icon, fam, 64).replace('%s' % (s, s, themed(svg, theme, icon, fam, s).replace('' + icon + '
' h += '
' open(out, 'w').write(h)