⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(email): keep the sign-in code in one piece
Andrejb1fe0c54145c
diff --git a/packages/email/src/components/otp-code.tsx b/packages/email/src/components/otp-code.tsxindex be5136893..5a90f6437 100644--- a/packages/email/src/components/otp-code.tsx+++ b/packages/email/src/components/otp-code.tsx@@ -1,6 +1,5 @@-import { Column, Text } from "react-email";+import { Text } from "react-email";import React from "react";-import { Row } from "./row";import { Section } from "./section";import { colors, shadow } from "./tokens";@@ -12,33 +11,15 @@ type OtpCodeProps = {hint: string;};-const SLOT_WIDTH = 59;-const SLOT_GAP = 6;-export function OtpCode({ code, label, hint }: OtpCodeProps) {- const slots = Array.from(code, (digit, slot) => ({ digit, slot }));- const last = slots.length - 1;-return (<Section style={wrapper}><Text className="k-text" style={labelStyle}>{label}</Text>- <Row style={{ maxWidth: `${slots.length * (SLOT_WIDTH + SLOT_GAP)}px` }}>- {slots.map(({ digit, slot }) => (- <Column- key={slot}- style={{- width: `${100 / slots.length}%`,- paddingRight: slot < last ? `${SLOT_GAP}px` : 0,- }}- >- <div className="k-slot" style={slotStyle}>- {digit}- </div>- </Column>- ))}- </Row>+ <Text className="k-slot" style={codeStyle}>+ {code}+ </Text><Text className="k-muted" style={hintStyle}>{hint}</Text>@@ -58,9 +39,17 @@ const labelStyle = {fontWeight: "500",};-const slotStyle = {- lineHeight: "42px",+const codeStyle = {+ margin: "0",+ padding: "14px 16px",textAlign: "center" as const,+ textIndent: "0.35em",+ letterSpacing: "0.35em",+ fontFamily:+ 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',+ fontSize: "28px",+ lineHeight: "32px",+ fontWeight: "600",borderWidth: "1px",borderStyle: "solid",borderColor: colors.input,@@ -68,7 +57,8 @@ const slotStyle = {backgroundColor: colors.background,boxShadow: shadow,color: colors.foreground,- fontSize: "14px",+ userSelect: "all" as const,+ WebkitUserSelect: "all" as const,};const hintStyle = {diff --git a/packages/email/src/templates/otp.test.ts b/packages/email/src/templates/otp.test.tsindex 940367365..5e576192d 100644--- a/packages/email/src/templates/otp.test.ts+++ b/packages/email/src/templates/otp.test.ts@@ -11,6 +11,12 @@ describe("OtpEmail", () => {expect(html).toContain("verification code");});+ it("keeps the code in one piece so it copies cleanly", async () => {+ const html = await render(createElement(OtpEmail, { otp: "482913" }));+ expect(html).toMatch(/>482913</);+ expect(html).not.toMatch(/>4</);+ });+it.each([["en-US", "This code expires in 5 minutes."],["de-DE", "Dieser Code läuft in 5 Minuten ab."],