style.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from typing import List
  2. from nicegui import ui
  3. def header_link(title: str, target: str) -> ui.link:
  4. return ui.link(title, target).classes(replace='text-lg text-white')
  5. def link_target(name: str, offset: str = '0') -> ui.link_target:
  6. target = ui.link_target(name).style(f'position: absolute; top: {offset}; left: 0')
  7. target.parent_slot.parent.classes('relative')
  8. return target
  9. def section_heading(subtitle: str, title: str) -> None:
  10. ui.label(subtitle).classes('text-lg text-bold')
  11. ui.markdown(title).classes('text-5xl font-medium mt-[-12px]')
  12. def heading(title: str) -> ui.label:
  13. return ui.label(title).classes('text-3xl md:text-4xl xl:text-5xl font-medium text-white')
  14. def title(content: str) -> ui.markdown:
  15. return ui.markdown(content).classes('text-4xl sm:text-5xl md:text-6xl font-medium')
  16. def subtitle(content: str) -> ui.markdown:
  17. return ui.markdown(content).classes('text-xl sm:text-2xl md:text-3xl leading-7')
  18. def example_link(title: str, description: str) -> None:
  19. name = title.lower().replace(' ', '_')
  20. with ui.column().classes('gap-0'):
  21. with ui.link(target=f'https://github.com/zauberzeug/nicegui/tree/main/examples/{name}/main.py'):
  22. ui.label(title).classes(replace='text-black text-bold')
  23. ui.markdown(description).classes(replace='text-black bold-links')
  24. def features(icon: str, title: str, items: List[str]) -> None:
  25. with ui.column().classes('gap-1 col-3'):
  26. ui.icon(icon).classes('text-5xl mb-3 text-primary opacity-80')
  27. ui.label(title).classes('text-bold mb-3')
  28. for item in items:
  29. ui.markdown(f'- {item}').classes('bold-links')