Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions apps/web/src/components/chat/ComposerSecretRequestPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { selectEnvironmentState, useStore } from "~/store";
import { formatTimeWithDay } from "~/timestampFormat";
import { useComputerLabel } from "../sidebar/linkedComputers";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { Input, MASKED_TEXT_FONT } from "../ui/input";
import { Textarea } from "../ui/textarea";
import { toastManager } from "../ui/toast";
import { settingsChangeDeviceLabel } from "./settingsChangeCard.logic";
Expand All @@ -38,14 +38,6 @@ import {
type SecretAnswerResult,
} from "./secretRequestClaims";

/**
* The masking dot sits at a different height in every font (SF Mono high,
* the system font low), and themes can change the fonts. Masked text is
* pinned to the app's bundled sans, whose dot is centered in the field;
* shown text reads in mono.
*/
const MASKED_FONT = "[font-family:'Schibsted_Grotesk_Variable',var(--font-sans)]";

function showNotice(notice: SecretRequestNotice): void {
toastManager.add({
type: notice.type,
Expand Down Expand Up @@ -264,7 +256,8 @@ export const ComposerSecretRequestPanel = memo(function ComposerSecretRequestPan
autoComplete="off"
// Masked like a password field until shown.
className={cn(
shown ? "font-mono" : MASKED_FONT,
// Shown text reads in mono; masked dots sit centered (see MASKED_TEXT_FONT).
shown ? "font-mono" : MASKED_TEXT_FONT,
!shown && "[&_textarea]:[-webkit-text-security:disc]",
)}
onChange={(event) => onFieldChange(event.target.value)}
Expand All @@ -276,7 +269,7 @@ export const ComposerSecretRequestPanel = memo(function ComposerSecretRequestPan
size="sm"
type={shown ? "text" : "password"}
autoComplete="new-password"
className={shown ? "font-mono" : MASKED_FONT}
className="font-mono"
onChange={(event) => onFieldChange(event.target.value)}
onKeyDown={onFieldKeyDown}
onPaste={onFieldPaste}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/scheduled/EventTaskPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function SigningSecretRow({
size="sm"
type="password"
autoComplete="off"
className="w-full min-w-0 font-mono sm:w-64"
className="w-full min-w-0 sm:w-64"
value={typing}
placeholder="The sender's secret"
aria-label="Signing secret"
Expand Down
9 changes: 9 additions & 0 deletions apps/web/src/components/ui/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import type * as React from "react";

import { cn } from "~/lib/utils";

/**
* The masking dot sits at a different height in every font (SF Mono high,
* the system font low), and themes can change the fonts. Masked text is
* pinned to the app's bundled sans, whose dot is centered in the field.
* Password inputs get it here; a masked textarea adds it itself.
*/
export const MASKED_TEXT_FONT = "[font-family:'Schibsted_Grotesk_Variable',var(--font-sans)]";

type InputProps = Omit<InputPrimitive.Props & React.RefAttributes<HTMLInputElement>, "size"> & {
size?: "sm" | "default" | "lg" | number;
unstyled?: boolean;
Expand All @@ -24,6 +32,7 @@ function Input({
size === "lg" && "h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5",
props.type === "search" &&
"[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none",
props.type === "password" && MASKED_TEXT_FONT,
props.type === "file" &&
"text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm",
);
Expand Down
Loading