mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-10 12:08:14 -06:00
feat: add CopyButton and StatusBadge components with enhanced RDAP card UX
This commit introduces two new reusable components and significantly improves the user experience across all RDAP cards: New Components: - CopyButton: Provides one-click copying functionality for handles, addresses, and other identifiers - StatusBadge: Displays color-coded status badges with proper type safety RDAP Card Enhancements: - Replace deprecated ClipboardCopyIcon with ClipboardIcon - Add copy buttons next to all handles, addresses, and identifiers - Migrate status displays from PropertyList to StatusBadge components with color coding - Replace PropertyList with proper DataList components for roles and public IDs - Improve Events table layout and styling - Wrap all copyable values in Code components for better visual distinction Type Safety Improvements: - Add rdapStatusColors mapping with proper Radix UI badge color types - Update IpNetwork and AutonomousNumber schemas to use typed StatusEnum arrays
This commit is contained in:
40
src/components/CopyButton.tsx
Normal file
40
src/components/CopyButton.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { FunctionComponent } from "react";
|
||||
import React from "react";
|
||||
import { ClipboardIcon } from "@radix-ui/react-icons";
|
||||
import { IconButton } from "@radix-ui/themes";
|
||||
|
||||
export type CopyButtonProps = {
|
||||
value: string;
|
||||
size?: "1" | "2" | "3";
|
||||
};
|
||||
|
||||
const CopyButton: FunctionComponent<CopyButtonProps> = ({ value, size = "1" }) => {
|
||||
const handleCopy = () => {
|
||||
navigator.clipboard.writeText(value).then(
|
||||
() => {
|
||||
// Successfully copied to clipboard
|
||||
},
|
||||
(err) => {
|
||||
if (err instanceof Error) {
|
||||
console.error(`Failed to copy to clipboard (${err.toString()}).`);
|
||||
} else {
|
||||
console.error("Failed to copy to clipboard.");
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
size={size}
|
||||
aria-label="Copy value"
|
||||
color="gray"
|
||||
variant="ghost"
|
||||
onClick={handleCopy}
|
||||
>
|
||||
<ClipboardIcon />
|
||||
</IconButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default CopyButton;
|
||||
Reference in New Issue
Block a user