Skip to content

Commit 4420a86

Browse files
committed
feat: support-icon-placement-in-copiable-component
1 parent 0aa53fb commit 4420a86

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/examples/copiable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { Tooltip } from "../lib";
44

55
const CopiableExample: React.FC = () => (
66
<>
7-
<Copiable copiableContent="Copied text">Copiable text</Copiable>
7+
<Copiable copiableContent="Copied text" iconPlacement="left">
8+
Copiable text
9+
</Copiable>
810
<Copiable
911
copiableContent="0xbe8d95497E53aB41d5A45CC8def90d0e59b49f99"
1012
info="Copy Address"

src/lib/copiable/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import Copied from "../../assets/svgs/copiable/copied.svg";
77
interface CopiableBaseProps {
88
copiableContent: string;
99
info?: string;
10+
iconPlacement?: "left" | "right";
1011
}
1112

12-
const Wrapper = styled.div`
13+
const Wrapper = styled.div<{ iconPlacement: string }>`
1314
position: relative;
1415
display: inline-flex;
1516
align-items: center;
1617
gap: 8px;
18+
flex-direction: ${({ iconPlacement }) =>
19+
iconPlacement === "left" ? "row-reverse" : "row"};
1720
`;
1821

1922
const StyledTooltip = styled(Tooltip)`
@@ -46,6 +49,7 @@ const Copiable: React.FC<CopiableProps> = ({
4649
info,
4750
children,
4851
tooltipProps,
52+
iconPlacement = "right",
4953
...props
5054
}) => {
5155
const [isCopied, setIsCopied] = useState(false);
@@ -61,7 +65,7 @@ const Copiable: React.FC<CopiableProps> = ({
6165
};
6266

6367
return (
64-
<Wrapper {...props}>
68+
<Wrapper {...props} iconPlacement={iconPlacement}>
6569
{children}
6670
<StyledTooltip
6771
text={isCopied ? "Copied!" : `${info ?? "Copy"}`}

0 commit comments

Comments
 (0)