|
1 |
| -from fh_bootstrap import * |
2 | 1 | from itertools import chain
|
3 |
| -from markdown import markdown |
4 |
| - |
5 |
| -md_exts='codehilite', 'smarty', 'extra', 'sane_lists' |
6 |
| -def Markdown(s, exts=md_exts, **kw): return Div(NotStr(markdown(s, extensions=exts)), **kw) |
| 2 | +from fasthtml.common import * |
| 3 | +from functools import partial |
| 4 | +from monsterui.all import * |
| 5 | +from fasthtml.components import Uk_theme_switcher |
| 6 | +_A = partial(A, target='_blank') |
| 7 | +def Markdown(s, **kw): return Div(render_md(s, class_map_mods={'ul':'uk-list uk-list-bullet space-y-2 mb-6 ml-6 text-lg'}), **kw) |
7 | 8 |
|
8 | 9 | ghurl = 'https://github.com/AnswerDotAI/fasthtml'
|
9 | 10 | fhurl = 'https://fastht.ml'
|
10 | 11 | docs = 'https://docs.fastht.ml'
|
11 | 12 |
|
12 |
| -def BstPage(selidx, title, *c): |
| 13 | +def BstPage(selidx, title, h2s, *c): |
13 | 14 | navitems = [('About', '/'), ('Vision', '/vision'), ('Foundations', '/foundation'),
|
14 | 15 | ('Technology', '/tech'), ('Components', '/components'), ('Limits', '#', {'disabled':True})]
|
15 | 16 | logo = 'assets/logo.svg'
|
16 |
| - ra_items = (A('Docs', href=docs, cls="nav-link"), |
17 |
| - Icon('fab fa-github', dark=False, sz='lg', href=ghurl, cls='ms-2 px-2')) |
18 |
| - ftlinks = [A(k, href=v, cls='nav-link px-2 text-muted') |
19 |
| - for k,v in dict(Home='/', Docs=docs, Company='https://www.answer.ai').items()] |
| 17 | + _NavBarP = partial(P, cls=TextT.lg) |
20 | 18 | return (
|
21 | 19 | Title(title),
|
22 |
| - Script('initTOC()'), |
23 | 20 | Container(
|
24 |
| - Navbar('nav', selidx, items=navitems, ra_items=ra_items, cls='navbar-light bg-secondary rounded-lg', |
25 |
| - image=f'/{logo}', hdr_href=fhurl, placement=PlacementT.Default, expand=SizeT.Md, toggle_left=False), |
26 |
| - Toc(Container(H1(title, cls='pb-2 pt-1'), *c, cls='mt-3')), |
27 |
| - BstFooter('© 2024 onwards AnswerDotAI, Inc', File(logo), img_href=fhurl, cs=ftlinks), |
28 |
| - typ=ContainerT.Xl, cls='mt-3', data_bs_spy='scroll', data_bs_target='#toc')) |
| 21 | + # NavBar |
| 22 | + NavBarContainer( |
| 23 | + NavBarLSide( |
| 24 | + NavBarNav( |
| 25 | + Li(A(Img(src=logo), href=fhurl)), |
| 26 | + *[Li(A(_NavBarP(k), href=v), cls='uk-active' if selidx==i else '') for i, (k,v) in enumerate(navitems[:-1])], |
| 27 | + Li(A(_NavBarP('Limits', href='#'), disabled=True, uk_tooltip='No limits!')))), |
| 28 | + NavBarRSide( |
| 29 | + NavBarNav( |
| 30 | + Li(A(_NavBarP("Theme"))),DropDownNavContainer(Div(Uk_theme_switcher(), cls='p-6 uk-drop-close'), cls='w-96'), |
| 31 | + Li(_A(_NavBarP('Docs'), href=docs)), |
| 32 | + Li(_A(_NavBarP(UkIcon('github')), href=ghurl)))), |
| 33 | + cls='bg-green-400/70 rounded-lg rounded-tl-3xl shadow-md p-2 px-4'), |
| 34 | + # Main Content |
| 35 | + Container( |
| 36 | + Grid( |
| 37 | + Div(NavContainer(*[Li(A(h2, href=f'#sec{i+1}')) for i,h2 in enumerate(h2s)], |
| 38 | + sticky=True, uk_scrollspy_nav=True), cls='hidden md:block col-span-1'), |
| 39 | + Div(H1(title, cls='mb-12'), *c, cls='col-span-12 md:col-span-5'), |
| 40 | + cols=6)), |
| 41 | + # Footer |
| 42 | + DividerLine(), |
| 43 | + Grid( |
| 44 | + P("© 2024 onwards AnswerDotAI, Inc", cls=TextPresets.muted_lg), |
| 45 | + DivCentered(A(Img(src=logo, height=24), href=fhurl)), |
| 46 | + DivRAligned(A("Home"), |
| 47 | + _A("Docs",href='https://docs.fastht.ml/'), |
| 48 | + _A("Company", href='https://www.answer.ai/'), cls=TextPresets.muted_lg+'space-x-4'), |
| 49 | + ), |
| 50 | + cls='py-8 mb-4' + ContainerT.xl)) |
29 | 51 |
|
30 | 52 | def Sections(h2s, texts):
|
31 | 53 | colors = 'yellow', 'pink', 'teal', 'blue'
|
32 |
| - div_cls = 'py-2 px-3 mt-4 bg-light-{} rounded-tl-lg' |
| 54 | + div_cls = 'py-2 px-3 mt-4 mb-2 bg-{}-400/70 shadow-md rounded-lg rounded-tl-3xl' #bg-{}-100 |
33 | 55 | return chain([Div(H2(h2, id=f'sec{i+1}', cls=div_cls.format(colors[i%4])), Div(txt, cls='px-2'))
|
34 | 56 | for i,(h2,txt) in enumerate(zip(h2s, texts))])
|
0 commit comments