Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Dec 4, 2024
1 parent c07c565 commit 937ec49
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 97 deletions.
6 changes: 4 additions & 2 deletions apps/engineering/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { GeistSans } from "geist/font/sans";

import type { ReactNode } from "react";

import "./global.css";
import { TooltipProvider } from "@unkey/ui/src/components/tooltip";
import "./global.css";

export default function Layout({ children }: { children: ReactNode }) {
return (
Expand All @@ -15,7 +15,9 @@ export default function Layout({ children }: { children: ReactNode }) {
suppressHydrationWarning
>
<body>
<RootProvider><TooltipProvider>{children}</TooltipProvider></RootProvider>
<RootProvider>
<TooltipProvider>{children}</TooltipProvider>
</RootProvider>
</body>
</html>
);
Expand Down
14 changes: 7 additions & 7 deletions apps/engineering/content/design/components/id.valueTruncate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Row } from "@/app/components/row";
import { Id } from "@unkey/ui";

export const ValueTruncateExample: React.FC = () => (
<RenderComponentWithSnippet>
<Row>
<Id value={"api_zTLSnw1YTqUHRwJTgKWrg"} />
<Id value={"api_zTLSnw1YTqUHRwJTgKWrg"} truncate={6} />
<Id value={"api_zTLSnw1YTqUHRwJTgKWrg"} truncate={12} />
</Row>
</RenderComponentWithSnippet>
<RenderComponentWithSnippet>
<Row>
<Id value={"api_zTLSnw1YTqUHRwJTgKWrg"} />
<Id value={"api_zTLSnw1YTqUHRwJTgKWrg"} truncate={6} />
<Id value={"api_zTLSnw1YTqUHRwJTgKWrg"} truncate={12} />
</Row>
</RenderComponentWithSnippet>
);
95 changes: 57 additions & 38 deletions apps/engineering/content/design/components/tooltip.onHover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,63 @@
import { RenderComponentWithSnippet } from "@/app/components/render";
import { Row } from "@/app/components/row";

import { Tooltip, TooltipContent, TooltipTrigger } from "@unkey/ui"
import { Tooltip, TooltipContent, TooltipTrigger } from "@unkey/ui";
import { InfoIcon } from "lucide-react";
export const OnHoverExample: React.FC = () => (
<RenderComponentWithSnippet>
<Row>
<Tooltip>
<TooltipTrigger >
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">Bottom <span><InfoIcon size={14} className="text-gray-10 self-auto h-full" /></span></p>

</TooltipTrigger>
<TooltipContent className="h-8" side="bottom">
Content
</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger>
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">Top <span><InfoIcon size={14} className="text-gray-10 self-auto h-full" /></span></p>
</TooltipTrigger>
<TooltipContent className="h-8" side="top">
Content
</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger>
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">Right <span><InfoIcon size={14} className="text-gray-10 self-auto h-full" /></span></p>
</TooltipTrigger>
<TooltipContent className="h-8" side="right">
Content
</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger>
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">Left <span><InfoIcon size={14} className="text-gray-10 self-auto h-full" /></span></p>
</TooltipTrigger>
<TooltipContent className="h-8" side="left">
Content
</TooltipContent>
</Tooltip>
</Row>
</RenderComponentWithSnippet>
<RenderComponentWithSnippet>
<Row>
<Tooltip>
<TooltipTrigger>
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">
Bottom{" "}
<span>
<InfoIcon size={14} className="text-gray-10 self-auto h-full" />
</span>
</p>
</TooltipTrigger>
<TooltipContent className="h-8" side="bottom">
Content
</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger>
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">
Top{" "}
<span>
<InfoIcon size={14} className="text-gray-10 self-auto h-full" />
</span>
</p>
</TooltipTrigger>
<TooltipContent className="h-8" side="top">
Content
</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger>
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">
Right{" "}
<span>
<InfoIcon size={14} className="text-gray-10 self-auto h-full" />
</span>
</p>
</TooltipTrigger>
<TooltipContent className="h-8" side="right">
Content
</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger>
<p className="inline-flex gap-4 border border-gray-2 px-3 py-1 rounded-lg ">
Left{" "}
<span>
<InfoIcon size={14} className="text-gray-10 self-auto h-full" />
</span>
</p>
</TooltipTrigger>
<TooltipContent className="h-8" side="left">
Content
</TooltipContent>
</Tooltip>
</Row>
</RenderComponentWithSnippet>
);
1 change: 0 additions & 1 deletion internal/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"@unkey/tsconfig": "workspace:^",
"tailwindcss": "^3.4.15",
"typescript": "^5.5.3"

},
"dependencies": {
"@radix-ui/react-tooltip": "^1.0.7",
Expand Down
98 changes: 51 additions & 47 deletions internal/ui/src/components/id.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,65 @@
"use client";
import { TaskChecked, TaskUnchecked } from "@unkey/icons";
import * as React from "react";
import { cn } from "../lib/utils";
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
import { TaskUnchecked, TaskChecked } from "@unkey/icons"

type IdProps = {
value: string;
truncate?: number;
className?: string;
value: string;
truncate?: number;
className?: string;
};

export const Id: React.FC<IdProps> = ({ className, value, truncate, ...props }) => {
const [isCopied, setIsCopied] = React.useState(false);
const copyTextToClipboard = async (value: string) => {
try {
await navigator.clipboard.writeText(value ?? "");
setIsCopied(true);
} catch (error) {
console.error('Failed to copy: ', error);
}
};
const [isCopied, setIsCopied] = React.useState(false);
const copyTextToClipboard = async (value: string) => {
try {
await navigator.clipboard.writeText(value ?? "");
setIsCopied(true);
} catch (error) {
console.error("Failed to copy: ", error);
}
};

React.useEffect(() => {
if (!isCopied) {
return;
}
const timer = setTimeout(() => {
setIsCopied(false);
}, 2000);
return () => clearTimeout(timer);
}, [isCopied]);
React.useEffect(() => {
if (!isCopied) {
return;
}
const timer = setTimeout(() => {
setIsCopied(false);
}, 2000);
return () => clearTimeout(timer);
}, [isCopied]);

const ellipse = '••••';
const truncateValue = truncate ? value?.slice(0, truncate) + ellipse : value;
const Comp = "button";
const ellipse = "••••";
const truncateValue = truncate ? value?.slice(0, truncate) + ellipse : value;
const Comp = "button";

return (
<Comp
className={cn("relative inline-flex w-full ring-2 ring-transparent focus:ring-gray-6 group items-center transition duration-150 justify-center gap-3 whitespace-nowrap tracking-normal rounded-lg font-medium bg-gray-1 w-fit max-w-96 border border-accent-6 hover:border-accent-8 text-accent-12 radius radius-2 font-mono h-8 px-3 py-1 text-xs overflow-hidden", className)}
onClick={() => copyTextToClipboard(value ?? "")}
{...props}
>
{truncateValue}
<Tooltip>
<div className="absolute flex h-8 w-8 top-0 right-0 invisible group-hover:visible group-focus:visible">
<TooltipTrigger asChild>
<div className=" flex justify-end border w-full border-none h-full text-gray-1 bg-gray-1">
{!isCopied ? <TaskUnchecked className="size=[12] text-gray-10 item-end my-auto mr-2 bg-base-1" /> : <TaskChecked className="size=[12] text-gray-10 item-end my-auto mr-2" />}
</div>
</TooltipTrigger>
<TooltipContent side="bottom">
Copy ID
</TooltipContent>
</div>
</Tooltip>
</Comp>);
return (
<Comp
className={cn(
"relative inline-flex w-full ring-2 ring-transparent focus:ring-gray-6 group items-center transition duration-150 justify-center gap-3 whitespace-nowrap tracking-normal rounded-lg font-medium bg-gray-1 w-fit max-w-96 border border-accent-6 hover:border-accent-8 text-accent-12 radius radius-2 font-mono h-8 px-3 py-1 text-xs overflow-hidden",
className,
)}
onClick={() => copyTextToClipboard(value ?? "")}
{...props}
>
{truncateValue}
<Tooltip>
<div className="absolute flex h-8 w-8 top-0 right-0 invisible group-hover:visible group-focus:visible">
<TooltipTrigger asChild>
<div className=" flex justify-end border w-full border-none h-full text-gray-1 bg-gray-1">
{!isCopied ? (
<TaskUnchecked className="size=[12] text-gray-10 item-end my-auto mr-2 bg-base-1" />
) : (
<TaskChecked className="size=[12] text-gray-10 item-end my-auto mr-2" />
)}
</div>
</TooltipTrigger>
<TooltipContent side="bottom">Copy ID</TooltipContent>
</div>
</Tooltip>
</Comp>
);
};
Id.displayName = "Id";


3 changes: 1 addition & 2 deletions internal/ui/src/components/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import * as React from "react";

import { cn } from "../lib/utils";
// Adjust the import path as necessary
// Adjust the import path as necessary

const TooltipProvider = TooltipPrimitive.Provider;

Expand All @@ -28,5 +28,4 @@ const TooltipContent = React.forwardRef<
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;


export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };

0 comments on commit 937ec49

Please sign in to comment.