1
1
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/02_xtend.ipynb.
2
2
3
3
# %% auto 0
4
- __all__ = ['picocss' , 'picolink' , 'picocondcss' , 'picocondlink' , 'set_pico_cls' , 'A' , 'Form' , 'AX' , 'Hidden' , 'CheckboxX' , 'Card' ,
5
- 'Group' , 'Search' , 'Grid' , 'DialogX' , 'Container' , 'Script' , 'Style' , 'double_braces' , 'undouble_braces' ,
6
- 'loose_format' , 'ScriptX' , 'replace_css_vars' , 'StyleX' , 'On' , 'Any' , 'Prev' , 'Now' , 'AnyNow' , 'run_js' ,
7
- 'Titled' , 'Socials' , 'Favicon' , 'jsd' , 'clear' ]
4
+ __all__ = ['A' , 'Form' , 'AX' , 'Hidden' , 'CheckboxX' , 'Script' , 'Style' , 'double_braces' , 'undouble_braces' , 'loose_format' ,
5
+ 'ScriptX' , 'replace_css_vars' , 'StyleX' , 'On' , 'Any' , 'Prev' , 'Now' , 'AnyNow' , 'run_js' , 'Titled' , 'Socials' ,
6
+ 'Favicon' , 'jsd' , 'clear' ]
8
7
9
8
# %% ../nbs/api/02_xtend.ipynb
10
9
from dataclasses import dataclass , asdict
19
18
try : from IPython import display
20
19
except ImportError : display = None
21
20
22
- # %% ../nbs/api/02_xtend.ipynb
23
- picocss = "https://cdn.jsdelivr.net/npm/@picocss/pico@latest/css/pico.min.css"
24
- picolink = (Link (rel = "stylesheet" , href = picocss ),
25
- Style (":root { --pico-font-size: 100%; }" ))
26
- picocondcss = "https://cdn.jsdelivr.net/npm/@picocss/pico@latest/css/pico.conditional.min.css"
27
- picocondlink = (Link (rel = "stylesheet" , href = picocondcss ),
28
- Style (":root { --pico-font-size: 100%; }" ))
29
-
30
- # %% ../nbs/api/02_xtend.ipynb
31
- def set_pico_cls ():
32
- js = """var sel = '.cell-output, .output_area';
33
- document.querySelectorAll(sel).forEach(e => e.classList.add('pico'));
34
-
35
- new MutationObserver(ms => {
36
- ms.forEach(m => {
37
- m.addedNodes.forEach(n => {
38
- if (n.nodeType === 1) {
39
- var nc = n.classList;
40
- if (nc && (nc.contains('cell-output') || nc.contains('output_area'))) nc.add('pico');
41
- n.querySelectorAll(sel).forEach(e => e.classList.add('pico'));
42
- }
43
- });
44
- });
45
- }).observe(document.body, { childList: true, subtree: true });"""
46
- return display .Javascript (js )
47
-
48
21
# %% ../nbs/api/02_xtend.ipynb
49
22
@delegates (ft_hx , keep = True )
50
23
def A (* c , hx_get = None , target_id = None , hx_swap = None , href = '#' , ** kwargs )-> FT :
@@ -65,9 +38,9 @@ def AX(txt, hx_get=None, target_id=None, hx_swap=None, href='#', **kwargs)->FT:
65
38
66
39
# %% ../nbs/api/02_xtend.ipynb
67
40
@delegates (ft_hx , keep = True )
68
- def Hidden (value :Any = "" , ** kwargs )-> FT :
41
+ def Hidden (value :Any = "" , id : Any = None , ** kwargs )-> FT :
69
42
"An Input of type 'hidden'"
70
- return Input (type = "hidden" , value = value , ** kwargs )
43
+ return Input (type = "hidden" , value = value , id = id , ** kwargs )
71
44
72
45
# %% ../nbs/api/02_xtend.ipynb
73
46
@delegates (ft_hx , keep = True )
@@ -79,46 +52,6 @@ def CheckboxX(checked:bool=False, label=None, value="1", id=None, name=None, **k
79
52
if label : res = Label (res , label )
80
53
return Hidden (name = name , skip = True , value = "" ), res
81
54
82
- # %% ../nbs/api/02_xtend.ipynb
83
- @delegates (ft_hx , keep = True )
84
- def Card (* c , header = None , footer = None , ** kwargs )-> FT :
85
- "A PicoCSS Card, implemented as an Article with optional Header and Footer"
86
- if header : c = (Header (header ),) + c
87
- if footer : c += (Footer (footer ),)
88
- return Article (* c , ** kwargs )
89
-
90
- # %% ../nbs/api/02_xtend.ipynb
91
- @delegates (ft_hx , keep = True )
92
- def Group (* c , ** kwargs )-> FT :
93
- "A PicoCSS Group, implemented as a Fieldset with role 'group'"
94
- return Fieldset (* c , role = "group" , ** kwargs )
95
-
96
- # %% ../nbs/api/02_xtend.ipynb
97
- @delegates (ft_hx , keep = True )
98
- def Search (* c , ** kwargs )-> FT :
99
- "A PicoCSS Search, implemented as a Form with role 'search'"
100
- return Form (* c , role = "search" , ** kwargs )
101
-
102
- # %% ../nbs/api/02_xtend.ipynb
103
- @delegates (ft_hx , keep = True )
104
- def Grid (* c , cls = 'grid' , ** kwargs )-> FT :
105
- "A PicoCSS Grid, implemented as child Divs in a Div with class 'grid'"
106
- c = tuple (o if isinstance (o ,list ) else Div (o ) for o in c )
107
- return ft_hx ('div' , * c , cls = cls , ** kwargs )
108
-
109
- # %% ../nbs/api/02_xtend.ipynb
110
- @delegates (ft_hx , keep = True )
111
- def DialogX (* c , open = None , header = None , footer = None , id = None , ** kwargs )-> FT :
112
- "A PicoCSS Dialog, with children inside a Card"
113
- card = Card (* c , header = header , footer = footer , ** kwargs )
114
- return Dialog (card , open = open , id = id )
115
-
116
- # %% ../nbs/api/02_xtend.ipynb
117
- @delegates (ft_hx , keep = True )
118
- def Container (* args , ** kwargs )-> FT :
119
- "A PicoCSS Container, implemented as a Main with class 'container'"
120
- return Main (* args , cls = "container" , ** kwargs )
121
-
122
55
# %% ../nbs/api/02_xtend.ipynb
123
56
@delegates (ft_html , keep = True )
124
57
def Script (code :str = "" , ** kwargs )-> FT :
@@ -211,9 +144,9 @@ def run_js(js, id=None, **kw):
211
144
212
145
# %% ../nbs/api/02_xtend.ipynb
213
146
@delegates (ft_hx , keep = True )
214
- def Titled (title :str = "FastHTML app" , * args , ** kwargs )-> FT :
147
+ def Titled (title :str = "FastHTML app" , * args , cls = "container" , ** kwargs )-> FT :
215
148
"An HTML partial containing a `Title`, and `H1`, and any provided children"
216
- return Title (title ), Main (H1 (title ), * args , cls = "container" , ** kwargs )
149
+ return Title (title ), Main (H1 (title ), * args , cls = cls , ** kwargs )
217
150
218
151
# %% ../nbs/api/02_xtend.ipynb
219
152
def Socials (title , site_name , description , image , url = None , w = 1200 , h = 630 , twitter_site = None , creator = None , card = 'summary' ):
0 commit comments