fhdaisy.xtras

Convenience functions that combine components with their needed parts
p = mk_previewer()

Chat bubbles

p(Chat(
    ChatBubble('Hi, what is 2+2?'),
    cls='-start')
)

source

ChatTurn

 ChatTurn (msg, cls='', bubblecls='', **kw)

A ChatBubble in a Chat, representing one turn in a chat

Type Default Details
msg Text to display
cls str Class of the Chat
bubblecls str Class of the ChatBubble
kw VAR_KEYWORD
p(
    ChatTurn('Hi, what is 2+2?', cls='-start'),
    ChatTurn('The answer is 4', cls='-end', bubblecls='-primary'),
)

source

ChatPair

 ChatPair (q, a)

A question and answer pair as chat bubbles

Details
q Question text
a Answer text
c = Div(
    ChatPair('Hi, what is 2+2?', 'The answer is 4'),
    ChatPair('And what about 5*6?', 'That equals 30'),
    Div(cls='mt-4 flex gap-2')(
        Input(placeholder='Type your question...', cls='flex-1'),
        Btn('Send')
    )
)
p(c)

Actions

mk_dropdown

 mk_dropdown (summary, items, summcls='', cls='', **kw)
c = mk_dropdown('Click me',
    [Li(A('Item 1')), Li(A('Item 2'))],
    summcls="btn m-1",
    cls='bg-base-100 rounded-box w-52 p-2 shadow')

source

mk_dropdown

 mk_dropdown (summary, items, summcls='', cls='', **kw)

A dropdown menu with summary and content

Type Default Details
summary Text for the summary/button
items List of items to display in dropdown
summcls str Class for the summary element
cls str Class for the dropdown content
kw VAR_KEYWORD
p(c, height=150)

FAB


source

mk_fab

 mk_fab (txt, main, items, maincls='-success', btncls='-lg -circle',
         cls='', **kw)
c = mk_fab('➕', 'M', ['A', 'B', 'C'], cls='-flower')
p(c, height=200)

Swap


source

mk_swap

 mk_swap (on, off, cls='', **kw)
c = mk_swap('ON', 'OFF')
print(c)
<label class="swap  "><input type="checkbox"><div class="swap-on  ">ON</div><div class="swap-off  ">OFF</div></label>
p(c)
c = mk_swap('😀', '😪', cls='-rotate text-9xl')
p(c)

Data display

Accordian


source

mk_accordion_item

 mk_accordion_item (title, content, name='accordion', checked=False,
                    cls='', titlecls='', contentcls='', **kw)
accitems = [
    ('How do I create an account?', 'Click the "Sign Up" button in the top right corner.'),
    ('I forgot my password', 'Click on "Forgot Password" on the login page.'),
    ('How do I update my profile?', 'Go to "My Account" settings and select "Edit Profile".')
]
ais = [
    mk_accordion_item(*o, name='acc1', checked=i==0, cls='-arrow border border-base-300', titlecls='font-semibold')
    for i,o in enumerate(accitems)
]
p( Join(*ais, cls='-vertical min-w-md') )

source

mk_accordion

 mk_accordion (*items, name=None, cls='', itemcls='', titlecls='',
               contentcls='', itemkw=None, **kw)
c = mk_accordion(*accitems,
        titlecls='font-semibold', contentcls='text-sm',
        itemcls='-arrow border border-base-300',
        cls='-vertical min-w-md')
p(c)