Skip to content
Merged
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
18 changes: 9 additions & 9 deletions src/components/Output/PrintToZebraDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ const LS_PRINTER_UID = "zebra_print_uid";
type Tab = "network" | "browserprint";
interface Status { type: "idle" | "sending" | "success" | "error"; message?: string }

function StatusMessage({ status }: { status: Status }) {
if (status.type === "idle" || status.type === "sending") return null;
return (
<p className={`font-mono text-[10px] ${status.type === "success" ? "text-green-400" : "text-red-400"}`}>
{status.message}
</p>
);
}
Comment on lines +19 to +26
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The StatusMessage component should handle cases where status.message might be missing or empty to avoid rendering an empty <p> tag. In a flex container with a gap, an empty child still occupies space and creates an unnecessary layout gap. Additionally, adding role="status" improves accessibility by ensuring status updates are announced to screen readers.

function StatusMessage({ status }: { status: Status }) {
  if (status.type === "idle" || status.type === "sending" || !status.message) return null;
  return (
    <p
      role="status"
      className={`font-mono text-[10px] ${status.type === "success" ? "text-green-400" : "text-red-400"}`}
    >
      {status.message}
    </p>
  );
}


interface Props {
zpl: string;
onClose: () => void;
Expand Down Expand Up @@ -97,15 +106,6 @@ export function PrintToZebraDialog({ zpl, onClose }: Props) {
: "text-muted hover:text-text"
}`;

function StatusMessage({ status }: { status: Status }) {
if (status.type === "idle" || status.type === "sending") return null;
return (
<p className={`font-mono text-[10px] ${status.type === "success" ? "text-green-400" : "text-red-400"}`}>
{status.message}
</p>
);
}

return (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"
Expand Down