Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: migrate CopyableValue from MUI to Radix UI#20261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jaaydenh wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromjaaydenh/refactor-copyable-value
Open
Show file tree
Hide file tree
Changes fromall 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
42 changes: 28 additions & 14 deletionssite/src/components/CopyableValue/CopyableValue.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
import Tooltip, { type TooltipProps } from "@mui/material/Tooltip";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "components/Tooltip/Tooltip";
import { useClickable } from "hooks/useClickable";
import { useClipboard } from "hooks/useClipboard";
import type { FC, HTMLAttributes } from "react";
import { cn } from "utils/cn";

type TooltipSide = "top" | "right" | "bottom" | "left";

interface CopyableValueProps extends HTMLAttributes<HTMLSpanElement> {
value: string;
placement?: TooltipProps["placement"];
PopperProps?: TooltipProps["PopperProps"];
side?: TooltipSide;
}

export const CopyableValue: FC<CopyableValueProps> = ({
value,
placement = "bottom-start",
PopperProps,
side = "bottom",
children,
className,
...attrs
}) => {
const { showCopiedSuccess, copyToClipboard } = useClipboard();
Expand All@@ -22,14 +29,21 @@ export const CopyableValue: FC<CopyableValueProps> = ({
});

return (
<Tooltip
title={showCopiedSuccess ? "Copied!" : "Click to copy"}
placement={placement}
PopperProps={PopperProps}
>
<span {...attrs} {...clickableProps} css={{ cursor: "pointer" }}>
{children}
</span>
</Tooltip>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<span
{...attrs}
{...clickableProps}
className={cn("cursor-pointer", className)}
>
{children}
</span>
</TooltipTrigger>
<TooltipContent side={side}>
{showCopiedSuccess ? "Copied!" : "Click to copy"}
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
};
13 changes: 4 additions & 9 deletionssite/src/modules/resources/SensitiveValue.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,10 @@ export const SensitiveValue: FC<SensitiveValueProps> = ({ value }) => {
gap: 4,
}}
>
<CopyableValue value={value} css={styles.value}>
<CopyableValue
value={value}
className="w-[calc(100%-22px)] overflow-hidden whitespace-nowrap text-ellipsis"
>
{displayValue}
</CopyableValue>
<Tooltip title={buttonLabel}>
Expand All@@ -52,14 +55,6 @@ export const SensitiveValue: FC<SensitiveValueProps> = ({ value }) => {
};

const styles = {
value: {
// 22px is the button width
width: "calc(100% - 22px)",
overflow: "hidden",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
},

button: css`
color: inherit;
`,
Expand Down
19 changes: 9 additions & 10 deletionssite/src/pages/IconsPage/IconsPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,6 @@ import {
PageHeaderSubtitle,
PageHeaderTitle,
} from "components/PageHeader/PageHeader";
import { Stack } from "components/Stack/Stack";
import { SearchIcon, XIcon } from "lucide-react";
import { type FC, type ReactNode, useMemo, useState } from "react";
import {
Expand DownExpand Up@@ -147,19 +146,19 @@ const IconsPage: FC = () => {
}}
/>

<Stack
direction="row"
wrap="wrap"
spacing={1}
justifyContent="center"
<div
css={{ marginTop: 32 }}
className="flex flex-row gap-2 justify-center flex-wrap max-w-full"
>
{searchedIcons.length === 0 && (
<EmptyState message="No results matched your search" />
)}
{searchedIcons.map((icon) => (
<CopyableValue key={icon.url} value={icon.url} placement="bottom">
<Stack alignItems="center" css={{ margin: 12 }}>
<CopyableValue key={icon.url} value={icon.url} side="bottom">
<div
css={{ margin: 12 }}
className="flex flex-col gap-4 items-center max-w-full"
>
<img
alt={icon.url}
src={icon.url}
Expand DownExpand Up@@ -189,10 +188,10 @@ const IconsPage: FC = () => {
>
{icon.description}
</figcaption>
</Stack>
</div>
</CopyableValue>
))}
</Stack>
</div>
</Margins>
</>
);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp