metadata.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. """Metadata classes."""
  2. from typing import List, Union
  3. from reflex.components.el.element import Element
  4. from reflex.vars.base import Var
  5. from .base import BaseHTML
  6. class Base(BaseHTML):
  7. """Display the base element."""
  8. tag = "base"
  9. tag = "base"
  10. href: Var[Union[str, int, bool]]
  11. target: Var[Union[str, int, bool]]
  12. class Head(BaseHTML):
  13. """Display the head element."""
  14. tag = "head"
  15. class Link(BaseHTML):
  16. """Display the link element."""
  17. tag = "link"
  18. # Specifies the CORS settings for the linked resource
  19. cross_origin: Var[Union[str, int, bool]]
  20. # Specifies the URL of the linked document/resource
  21. href: Var[Union[str, int, bool]]
  22. # Specifies the language of the text in the linked document
  23. href_lang: Var[Union[str, int, bool]]
  24. # Allows a browser to check the fetched link for integrity
  25. integrity: Var[Union[str, int, bool]]
  26. # Specifies on what device the linked document will be displayed
  27. media: Var[Union[str, int, bool]]
  28. # Specifies the referrer policy of the linked document
  29. referrer_policy: Var[Union[str, int, bool]]
  30. # Specifies the relationship between the current document and the linked one
  31. rel: Var[Union[str, int, bool]]
  32. # Specifies the sizes of icons for visual media
  33. sizes: Var[Union[str, int, bool]]
  34. # Specifies the MIME type of the linked document
  35. type: Var[Union[str, int, bool]]
  36. class Meta(BaseHTML): # Inherits common attributes from BaseHTML
  37. """Display the meta element."""
  38. tag = "meta" # The HTML tag for this element is <meta>
  39. # Specifies the character encoding for the HTML document
  40. char_set: Var[Union[str, int, bool]]
  41. # Defines the content of the metadata
  42. content: Var[Union[str, int, bool]]
  43. # Provides an HTTP header for the information/value of the content attribute
  44. http_equiv: Var[Union[str, int, bool]]
  45. # Specifies a name for the metadata
  46. name: Var[Union[str, int, bool]]
  47. class Title(Element):
  48. """Display the title element."""
  49. tag = "title"
  50. # Had to be named with an underscore so it doesn't conflict with reflex.style Style in pyi
  51. class StyleEl(Element):
  52. """Display the style element."""
  53. tag = "style"
  54. media: Var[Union[str, int, bool]]
  55. special_props: List[Var] = [Var(_js_expr="suppressHydrationWarning")]
  56. base = Base.create
  57. head = Head.create
  58. link = Link.create
  59. meta = Meta.create
  60. title = Title.create
  61. style = StyleEl.create