components.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // @ts-nocheck
  2. import React from "react"
  3. import { Font, Hr as JEHr, Text as JEText, type HrProps, type TextProps } from "@jsx-email/all"
  4. import { DIVIDER_COLOR, SURFACE_DIVIDER_COLOR, textColor } from "./styles"
  5. export function Text(props: TextProps) {
  6. return <JEText {...props} style={{ ...textColor, ...props.style }} />
  7. }
  8. export function Hr(props: HrProps) {
  9. return <JEHr {...props} style={{ borderTop: `1px solid ${DIVIDER_COLOR}`, ...props.style }} />
  10. }
  11. export function SurfaceHr(props: HrProps) {
  12. return (
  13. <JEHr
  14. {...props}
  15. style={{
  16. borderTop: `1px solid ${SURFACE_DIVIDER_COLOR}`,
  17. ...props.style,
  18. }}
  19. />
  20. )
  21. }
  22. export function Title({ children }: TitleProps) {
  23. return React.createElement("title", null, children)
  24. }
  25. export function A({ children, ...props }: AProps) {
  26. return React.createElement("a", props, children)
  27. }
  28. export function B({ children, ...props }: AProps) {
  29. return React.createElement("b", props, children)
  30. }
  31. export function Span({ children, ...props }: SpanProps) {
  32. return React.createElement("span", props, children)
  33. }
  34. export function Wbr({ children, ...props }: WbrProps) {
  35. return React.createElement("wbr", props, children)
  36. }
  37. export function Fonts({ assetsUrl }: { assetsUrl: string }) {
  38. return (
  39. <>
  40. <Font
  41. fontFamily="IBM Plex Mono"
  42. fallbackFontFamily="monospace"
  43. webFont={{
  44. url: `${assetsUrl}/ibm-plex-mono-latin-400.woff2`,
  45. format: "woff2",
  46. }}
  47. fontWeight="400"
  48. fontStyle="normal"
  49. />
  50. <Font
  51. fontFamily="IBM Plex Mono"
  52. fallbackFontFamily="monospace"
  53. webFont={{
  54. url: `${assetsUrl}/ibm-plex-mono-latin-500.woff2`,
  55. format: "woff2",
  56. }}
  57. fontWeight="500"
  58. fontStyle="normal"
  59. />
  60. <Font
  61. fontFamily="IBM Plex Mono"
  62. fallbackFontFamily="monospace"
  63. webFont={{
  64. url: `${assetsUrl}/ibm-plex-mono-latin-600.woff2`,
  65. format: "woff2",
  66. }}
  67. fontWeight="600"
  68. fontStyle="normal"
  69. />
  70. <Font
  71. fontFamily="IBM Plex Mono"
  72. fallbackFontFamily="monospace"
  73. webFont={{
  74. url: `${assetsUrl}/ibm-plex-mono-latin-700.woff2`,
  75. format: "woff2",
  76. }}
  77. fontWeight="700"
  78. fontStyle="normal"
  79. />
  80. <Font
  81. fontFamily="Rubik"
  82. fallbackFontFamily={["Helvetica", "Arial", "sans-serif"]}
  83. webFont={{
  84. url: `${assetsUrl}/rubik-latin.woff2`,
  85. format: "woff2",
  86. }}
  87. fontWeight="400 500 600 700"
  88. fontStyle="normal"
  89. />
  90. </>
  91. )
  92. }
  93. export function SplitString({ text, split }: { text: string; split: number }) {
  94. const segments: JSX.Element[] = []
  95. for (let i = 0; i < text.length; i += split) {
  96. segments.push(<>{text.slice(i, i + split)}</>)
  97. if (i + split < text.length) {
  98. segments.push(<Wbr key={`${i}wbr`} />)
  99. }
  100. }
  101. return <>{segments}</>
  102. }