components.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 Span({ children, ...props }: SpanProps) {
  29. return React.createElement("span", props, children)
  30. }
  31. export function Wbr({ children, ...props }: WbrProps) {
  32. return React.createElement("wbr", props, children)
  33. }
  34. export function Fonts({ assetsUrl }: { assetsUrl: string }) {
  35. return (
  36. <>
  37. <Font
  38. fontFamily="IBM Plex Mono"
  39. fallbackFontFamily="monospace"
  40. webFont={{
  41. url: `${assetsUrl}/ibm-plex-mono-latin-400.woff2`,
  42. format: "woff2",
  43. }}
  44. fontWeight="400"
  45. fontStyle="normal"
  46. />
  47. <Font
  48. fontFamily="IBM Plex Mono"
  49. fallbackFontFamily="monospace"
  50. webFont={{
  51. url: `${assetsUrl}/ibm-plex-mono-latin-500.woff2`,
  52. format: "woff2",
  53. }}
  54. fontWeight="500"
  55. fontStyle="normal"
  56. />
  57. <Font
  58. fontFamily="IBM Plex Mono"
  59. fallbackFontFamily="monospace"
  60. webFont={{
  61. url: `${assetsUrl}/ibm-plex-mono-latin-600.woff2`,
  62. format: "woff2",
  63. }}
  64. fontWeight="600"
  65. fontStyle="normal"
  66. />
  67. <Font
  68. fontFamily="IBM Plex Mono"
  69. fallbackFontFamily="monospace"
  70. webFont={{
  71. url: `${assetsUrl}/ibm-plex-mono-latin-700.woff2`,
  72. format: "woff2",
  73. }}
  74. fontWeight="700"
  75. fontStyle="normal"
  76. />
  77. <Font
  78. fontFamily="Rubik"
  79. fallbackFontFamily={["Helvetica", "Arial", "sans-serif"]}
  80. webFont={{
  81. url: `${assetsUrl}/rubik-latin.woff2`,
  82. format: "woff2",
  83. }}
  84. fontWeight="400 500 600 700"
  85. fontStyle="normal"
  86. />
  87. </>
  88. )
  89. }
  90. export function SplitString({ text, split }: { text: string; split: number }) {
  91. const segments: JSX.Element[] = []
  92. for (let i = 0; i < text.length; i += split) {
  93. segments.push(<>{text.slice(i, i + split)}</>)
  94. if (i + split < text.length) {
  95. segments.push(<Wbr key={`${i}wbr`} />)
  96. }
  97. }
  98. return <>{segments}</>
  99. }