Coverage for khufu/typography/p.py : 86%

Hot-keys 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# encoding: utf-8
2from builtins import range
3from . import *
6def p(
7 content="",
8 lead=False,
9 textAlign=False,
10 color=False,
11 navBar=False,
12 onPhone=True,
13 onTablet=True,
14 onDesktop=True,
15 htmlId=False,
16 htmlClass=False):
17 """
18 *Get a Paragraph element*
20 **Key Arguments**
22 - ``content`` -- content of the paragraph
23 - ``lead`` -- is this a lead paragraph?
24 - ``textAlign`` -- how to align paragraph text [ left | center | right ]
25 - ``color`` -- colored text for emphasis [ muted | warning | info | error | success ]
26 - ``navBar`` -- is this `<p>` for a navbar?
27 - ``onPhone`` -- does this container get displayed on a phone sized screen
28 - ``onTablet`` -- does this container get displayed on a tablet sized screen
29 - ``onDesktop`` -- does this container get displayed on a desktop sized screen
32 **Return**
34 - ``p`` -- the html paragraph element
36 """
37 falseList = [lead, textAlign, ]
38 for i in range(len(falseList)):
39 if not falseList[i]:
40 falseList[i] = ""
41 [lead, textAlign, ] = falseList
43 if htmlId is not False:
44 htmlId = """id="%(htmlId)s" """ % locals()
45 else:
46 htmlId = ""
48 if htmlClass is False:
49 htmlClass = ""
51 if textAlign:
52 textAlign = "text-%(textAlign)s" % locals()
53 else:
54 textAlign = ""
56 if lead is True:
57 lead = "lead"
59 if color is False:
60 color = ""
61 elif color == "muted":
62 color = "muted"
63 else:
64 color = """text-%(color)s""" % locals()
66 if navBar is True:
67 navBar = "navbar-text"
68 else:
69 navBar = ""
71 if onPhone:
72 onPhone = ""
73 else:
74 onPhone = "hidden-phone"
75 if onTablet:
76 onTablet = ""
77 else:
78 onTablet = "hidden-tablet"
79 if onDesktop:
80 onDesktop = ""
81 else:
82 onDesktop = "hidden-desktop"
84 p = """
85 <p class="%(lead)s %(onPhone)s %(onTablet)s %(onDesktop)s %(textAlign)s %(color)s %(navBar)s %(htmlClass)s" %(htmlId)s>%(content)s</p>
86 """ % locals()
88 return p