Coverage for src/lcdoc/mkdocs/lp/plugs/column/__init__.py: 88.10%
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2### `lightbox`
4"""
7from lcdoc.mkdocs.tools import style lp|features/lp/examples.md
9nocache = True lp|features/lp/examples.md
10formatted = True lp|features/lp/examples.md
11nocache = True lp|features/lp/examples.md
13sep = '<b>-col-</b>' lp|features/lp/examples.md
15# :docs:lp_column_dflts
16lp_column_dflts = {
17 'max_width': '1000px', # max width per column - determines the min total width
18 'padding': '0',
19 'margin': '2%',
20 'custom_style': False, # when set we do NOT include our Column Style, user must.
21}
23ColumnStyle = '''
24@media screen and (min-width: %(min_total_width)s) {
25 .md-grid { max-width: initial;}
26 .lp-row { display: flex; }
27 .lp-column {
28 padding: %(padding)s;
29 margin-left: %(margin)s;
30 margin-right: %(margin)s;
31 flex: %(flex)s%%;
32 max-width: %(max_width)s;
33 }
34}
35'''
36# :docs:lp_column_dflts
39def to_col(html, page, LP, **kw): lp|features/lp/examples.md
40 html = html.split(sep) lp|features/lp/examples.mdlp|features/lp/syntax.md
41 cols = len(html) lp|features/lp/examples.mdlp|features/lp/syntax.md
42 if cols == 1: 42 ↛ 43line 42 didn't jump to line 43, because the condition on line 42 was never truelp|features/lp/examples.mdlp|features/lp/syntax.md
43 return html
44 d = dict(lp_column_dflts) lp|features/lp/examples.mdlp|features/lp/syntax.md
45 d.update(page.lp_column_settings) lp|features/lp/examples.mdlp|features/lp/syntax.md
46 mw = d.get('max_width') lp|features/lp/examples.mdlp|features/lp/syntax.md
47 unit = 'px' lp|features/lp/examples.mdlp|features/lp/syntax.md
48 for u in ('px', '%', 'em', 'rem'): 48 ↛ 53line 48 didn't jump to line 53, because the loop on line 48 didn't completelp|features/lp/examples.mdlp|features/lp/syntax.md
49 if mw.endswith(u): 49 ↛ 48line 49 didn't jump to line 48, because the condition on line 49 was never falselp|features/lp/examples.mdlp|features/lp/syntax.md
50 unit = u lp|features/lp/examples.mdlp|features/lp/syntax.md
51 mw = int(mw.split(u, 1)[0]) lp|features/lp/examples.mdlp|features/lp/syntax.md
52 break lp|features/lp/examples.mdlp|features/lp/syntax.md
53 d['min_total_width'] = d.get('min_total_width', '%s%s' % (mw * cols, unit)) lp|features/lp/examples.mdlp|features/lp/syntax.md
54 d['flex'] = 100.0 / cols lp|features/lp/examples.mdlp|features/lp/syntax.md
55 h = '<div class="lp-row"><div class="lp-column">' lp|features/lp/examples.mdlp|features/lp/syntax.md
56 h = h + '</div><div class="lp-column">'.join(html) + '</div></div>' lp|features/lp/examples.mdlp|features/lp/syntax.md
57 if not d['custom_style']: 57 ↛ 59line 57 didn't jump to line 59, because the condition on line 57 was never falselp|features/lp/examples.mdlp|features/lp/syntax.md
58 h += style(ColumnStyle % d) lp|features/lp/examples.mdlp|features/lp/syntax.md
59 return h lp|features/lp/examples.mdlp|features/lp/syntax.md
62page_assets = {'func': to_col} lp|features/lp/examples.md
65def run(cmd, kw): lp|features/lp/examples.md
66 p = kw['LP'].page lp|features/lp/examples.mdlp|features/lp/syntax.md
67 p.lp_column_settings = s = getattr(p, 'lp_column_settings', {}) lp|features/lp/examples.mdlp|features/lp/syntax.md
68 s.update(kw) lp|features/lp/examples.mdlp|features/lp/syntax.md
69 return sep lp|features/lp/examples.mdlp|features/lp/syntax.md