mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Improve rendering of item lists
This commit is contained in:
parent
eed56b0ee5
commit
75e71e34e9
@ -17,10 +17,10 @@ class ItemsView:
|
||||
style = ''
|
||||
cid = '#' + self.container_id
|
||||
style += build_rule(cid + ' li', padding='1em', border_bottom='solid 1px ' + get_color('window-foreground'), border_top='solid 1px ' + get_color('window-background'), cursor='pointer', list_style='none')
|
||||
style += build_rule(cid + ' .title', font_size=get_font_size('item-list-title'))
|
||||
style += build_rule(cid + ' .subtitle', font_size=get_font_size('item-list-subtitle'), font_style='italic')
|
||||
style += build_rule(cid + ' .item-title', font_size=get_font_size('item-list-title'))
|
||||
style += build_rule(cid + ' .item-subtitle', font_size=get_font_size('item-list-subtitle'), font_style='italic')
|
||||
style += build_rule(cid + ' li:hover', color=get_color('list-hover-foreground'), background_color=get_color('list-hover-background'), border_top_color=get_color('list-hover-foreground'))
|
||||
style += build_rule(cid + ' li:active')
|
||||
style += build_rule(cid + ' li:active', transform='scale(1, 1.5)')
|
||||
self.base_style = style
|
||||
div = E.div(
|
||||
id=self.container_id, style='display:none',
|
||||
@ -51,25 +51,28 @@ class ItemsView:
|
||||
subtitle = getattr(data, 'subtitle', None)
|
||||
c = self.clear()
|
||||
if subtitle:
|
||||
c.appendChild(E.p(subtitle))
|
||||
c.appendChild(E.p(subtitle, style="font-style:italic; padding: 1em 1ex; border-bottom: solid 1px currentColor"))
|
||||
ul = E.ul()
|
||||
c.appendChild(ul)
|
||||
has_icons = has_subtitles = False
|
||||
has_icons = False
|
||||
for item in items:
|
||||
if item.icon_name:
|
||||
has_icons = True
|
||||
if item.subtitle:
|
||||
has_subtitles = True
|
||||
if has_icons and has_subtitles:
|
||||
break
|
||||
|
||||
for item in items:
|
||||
ic = ''
|
||||
if has_icons:
|
||||
ic = 'fa fa-fw '
|
||||
if item.icon_name:
|
||||
ic += ' fa-' + item.icon_name
|
||||
ic = E.span('\xa0', class_=ic)
|
||||
ul.appendChild(E.li(E.a(href='javascript:void(0)',
|
||||
E.div(item.title, class_='title')
|
||||
E.div(ic, item.title, class_='item-title')
|
||||
)))
|
||||
a = ul.lastChild.firstChild
|
||||
if item.subtitle:
|
||||
a.appendChild(E.div(item.subtitle, class_='subtitle'))
|
||||
a.appendChild(E.div(item.subtitle, class_='item-subtitle', style='padding-top:1ex'))
|
||||
a.addEventListener('click', def(event): event.preventDefault();)
|
||||
if item.action:
|
||||
ul.lastChild.addEventListener('click', item.action)
|
||||
|
Loading…
x
Reference in New Issue
Block a user