Added Application HolidayViewer
This commit is contained in:
@@ -3,12 +3,12 @@ from fasthtml.components import *
|
||||
from core.utils import merge_classes
|
||||
|
||||
|
||||
def mk_icon(icon, size=20, can_select=True, cls='', **kwargs):
|
||||
def mk_icon(icon, size=20, can_select=True, cls='', tooltip=None, **kwargs):
|
||||
merged_cls = merge_classes(f"icon-{size}",
|
||||
'icon-btn' if can_select else '',
|
||||
cls,
|
||||
kwargs)
|
||||
return Div(icon, cls=merged_cls, **kwargs)
|
||||
return mk_tooltip(icon, tooltip, cls=merged_cls, **kwargs) if tooltip else Div(icon, cls=merged_cls, **kwargs)
|
||||
|
||||
|
||||
def mk_ellipsis(txt: str, cls='', **kwargs):
|
||||
@@ -18,11 +18,22 @@ def mk_ellipsis(txt: str, cls='', **kwargs):
|
||||
return Div(txt, cls=merged_cls, data_tooltip=txt, **kwargs)
|
||||
|
||||
|
||||
def mk_tooltip(element, tooltip: str, cls='', **kwargs):
|
||||
merged_cls = merge_classes("mmt-tooltip",
|
||||
cls,
|
||||
kwargs)
|
||||
return Div(element, cls=merged_cls, data_tooltip=tooltip, **kwargs)
|
||||
|
||||
|
||||
def mk_tooltip_container(component_id):
|
||||
return Div(id=f"tt_{component_id}", style="position: fixed; z-index: 1000;", cls="mmt-tooltip-container")
|
||||
|
||||
|
||||
def mk_dialog_buttons(ok_title: str = "OK", cancel_title: str = "Cancel", on_ok: dict = None, on_cancel: dict = None):
|
||||
def mk_dialog_buttons(ok_title: str = "OK",
|
||||
cancel_title: str = "Cancel",
|
||||
on_ok: dict = None,
|
||||
on_cancel: dict = None,
|
||||
cls=None):
|
||||
if on_ok is None:
|
||||
on_ok = {}
|
||||
if on_cancel is None:
|
||||
@@ -34,7 +45,7 @@ def mk_dialog_buttons(ok_title: str = "OK", cancel_title: str = "Cancel", on_ok:
|
||||
Button(cancel_title, cls="btn btn-ghost btn-sm", **on_cancel),
|
||||
cls="flex justify-end"
|
||||
),
|
||||
cls="flex justify-end w-full"
|
||||
cls=merge_classes("flex justify-end w-full", cls)
|
||||
)
|
||||
|
||||
|
||||
@@ -48,3 +59,49 @@ def mk_select_option(option: str, value=None, selected_value: str = None, select
|
||||
attrs["disabled"] = True
|
||||
|
||||
return Option(option, **attrs)
|
||||
|
||||
|
||||
def mk_accordion_section(component_id, title, icon, content, selected=False):
|
||||
return Div(
|
||||
Input(type="radio",
|
||||
name=f"debugger-accordion-{component_id}",
|
||||
checked="checked" if selected else None,
|
||||
cls="p-0! min-h-0!",
|
||||
),
|
||||
Div(
|
||||
mk_icon(icon, can_select=False), mk_ellipsis(title, cls="text-sm"),
|
||||
cls="collapse-title p-0 min-h-0 flex truncate",
|
||||
),
|
||||
Div(
|
||||
*content,
|
||||
cls="collapse-content pr-0! truncate",
|
||||
),
|
||||
cls="collapse mb-2",
|
||||
id=f"{component_id}",
|
||||
)
|
||||
|
||||
|
||||
def set_boundaries(boundaries, remove_margin=True, other=0):
|
||||
if isinstance(boundaries, int):
|
||||
max_height = boundaries
|
||||
else:
|
||||
max_height = int(boundaries["height"])
|
||||
|
||||
if remove_margin:
|
||||
max_height -= 8
|
||||
|
||||
max_height -= other
|
||||
|
||||
return {"style": f"max-height:{max_height}px;"}
|
||||
|
||||
|
||||
def safe_get_dialog_buttons_parameters(buttons_dict):
|
||||
res = {}
|
||||
if buttons_dict is None:
|
||||
return res
|
||||
|
||||
for param in ["ok_title", "cancel_title", "on_ok", "on_cancel"]:
|
||||
if param in buttons_dict:
|
||||
res[param] = buttons_dict[param]
|
||||
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user