link.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. """Display the title of the current page."""
  2. from typing import Optional
  3. from pynecone.components.component import Component
  4. from pynecone.components.tags import Tag
  5. from pynecone.var import Var
  6. class Link(Component):
  7. """A component that displays the title of the current page."""
  8. # The href.
  9. href: Var[str]
  10. # The type of link.
  11. rel: Var[str]
  12. def _render(self) -> Tag:
  13. return Tag(name="link").add_props(
  14. href=self.href,
  15. rel=self.rel,
  16. )
  17. class ScriptTag(Component):
  18. """A component that creates a script tag with the speacified type and source.
  19. Args:
  20. type: This attribute indicates the type of script represented.
  21. The value of this attribute will be one of the following:
  22. - module: This value causes the code to be treated as a JavaScript module.
  23. - importmap: This value indicates that the body of the element
  24. contains an import map.
  25. - Any value: The embedded content is treated as a data block, and won't be
  26. processed by the browser.
  27. - blocking: This attribute explicitly indicates that certain operations
  28. should be blocked on the fetching of the script.
  29. source: This attribute specifies the URI of an external script; this can be
  30. used as an alternative to embedding a script directly within a document.
  31. integrity: This attribute contains inline metadata that a user agent can use
  32. to verify that a fetched resource has been delivered free of unexpected manipulation
  33. crossorigin: To allow error logging for sites which use a separate domain for static media,
  34. use this attribute.
  35. referrer_policy: Indicates which referrer to send when fetching the script, or resources fetched by the script
  36. refrence: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#:~:text=Indicates%20which%20referrer%20to%20send%20when%20fetching%20the%20script%2C%20or%20resources%20fetched%20by%20the%20script%3A
  37. is_async: This attribute allows the elimination of parser-blocking JavaScript where the browser would have to
  38. load and evaluate scripts before continuing to parse. defer has a similar effect in this case.
  39. defer: This Boolean attribute is set to indicate to a browser that the script is
  40. meant to be executed after the document has been parsed, but before firing DOMContentLoaded.
  41. """
  42. tag = "script"
  43. type: Var[str]
  44. source: Var[str]
  45. integrity: Optional[Var[str]]
  46. crossorigin: Optional[Var[str]]
  47. referrer_policy: Optional[Var[str]]
  48. is_async: Optional[Var[bool]]
  49. defer: Optional[Var[bool]]