metadata.py 2.2 KB

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