"""Page layout: the header, cards, section messages, the footer and the copy button. CSS: layout.css.""" from .icons import icon from .links import e, text, texts def header(eyebrow, title, meta, counts='', badge='', lede=''): """The page header: the eyebrow, the page's only h1 with its badge on the right, then the meta line, with its counts at the right end, then the lede. meta, counts and badge are HTML. Build each meta item with meta_item. badge holds the page's verdict or the anchor's own status, as one or more lozenges. counts holds count lozenges, or the page's one action or live state. lede is a text field: one line of small subtlest text on how the page was made. header('Catch-up', 'Search migration', meta_item('calendar', 'Oct 12 to Oct 23'), counts=lz({"text": "3 need you", "tone": "warning"})) """ m = f'
' if meta else '' if counts: m = f'' h1 = f'{text(s)}
' for s in texts(paras)) + f'Generated from {e(generated_from)}. Check it before {check} it.
' + extra, ic_cls='ic-disc') def tabs(items, label): """Tabs: the tab list, then one panel per tab, with the first selected. The page script switches them, with clicks and the arrow keys, and keeps the choice in the URL hash, and print shows every panel. label names the tab list for screen readers. Data: [{"key", "label", "icon", "count"?, "body", "card"?}]. body is HTML, and count shows after the label when given. With card, the panel is itself a card, for a tab holding one section. Without it, the panel holds cards. tabs([{"key": "read", "label": "Read first", "icon": "book", "count": 4, "body": card('book', 'Read first', rows)}, {"key": "trace", "label": "Trace", "icon": "task", "body": trace, "card": True}], 'Guide sections') """ tab_list = ''.join( f'' for i, x in enumerate(items)) panels = ''.join(f'{e(msg)}
' def note(item, ic='info', tone='', title='', after=''): """A section message holding a text field, with an optional title, and after it an optional text field in small text. tone is warning, danger, success, information or discovery, for the section message of that kind. note({"text": "{0} says the limit is 100.", "links": [link]}, ic='warning', tone='warning', title='A support article disagrees with the code') """ cls = f' section-msg--{e({"danger": "error"}.get(tone, tone))}' if tone else '' head = f'{text(after)}
' if after else '' return f'{e(target)}' if fallback else '')
def footer(f):
"""The sources footer.
Data: {"tags": [{"text", "muted"?}], "lines": [text fields]}. A muted tag is for an app with no results.
footer({"tags": [{"text": "Jira"}, {"text": "No results from Zoom", "muted": True}],
"lines": ["Prepared just now, Oct 27, 9:05 AM PT"]})
"""
tags = ''.join(f'{e(t["text"])}' for t in f.get('tags', []))
return f''