Refactor renamed the component groups to something less obtuse:
Elements -> Groups -> Screens -> Views
This commit is contained in:
parent
ca6de91a96
commit
dd46acba87
2 changed files with 151 additions and 144 deletions
|
|
@ -0,0 +1,23 @@
|
|||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { CopyButton } from "./CopyButton";
|
||||
|
||||
const meta: Meta<typeof CopyButton> = {
|
||||
title: "Elements/CopyButton",
|
||||
component: CopyButton,
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof CopyButton>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
value: "Hello, world!",
|
||||
},
|
||||
};
|
||||
|
||||
export const LongValue: Story = {
|
||||
args: {
|
||||
value:
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import {
|
||||
ActionIcon,
|
||||
CopyButton as MantineCopyButton,
|
||||
Tooltip,
|
||||
} from "@mantine/core";
|
||||
|
||||
export interface CopyButtonProps {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export function CopyButton({ value }: CopyButtonProps) {
|
||||
return (
|
||||
<MantineCopyButton value={value}>
|
||||
{({ copied, copy }) => (
|
||||
<Tooltip label={copied ? "Copied" : "Copy"}>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color={copied ? "green" : "gray"}
|
||||
onClick={copy}
|
||||
>
|
||||
{copied ? "\u2713" : "\u2398"}
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
)}
|
||||
</MantineCopyButton>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue