link.py 531 B

12345678910111213141516171819202122
  1. from typing import Union
  2. import justpy as jp
  3. from .group import Group
  4. from .page import Page
  5. class Link(Group):
  6. def __init__(self, text: str = '', target: Union[Page, str] = '#'):
  7. """Link
  8. Create a link.
  9. :param text: link text
  10. :param target: link target (either a string or a page object)
  11. """
  12. href = target if isinstance(target, str) else target.route[1:]
  13. view = jp.A(text=text, href=href, classes='underline text-blue', temp=False)
  14. super().__init__(view)