mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
79 lines
1.5 KiB
TypeScript
79 lines
1.5 KiB
TypeScript
const App = `import {forwardRef} from "react";
|
|
import {LinkIcon} from "@nextui-org/shared-icons";
|
|
import {linkAnchorClasses} from "@nextui-org/theme";
|
|
|
|
import {useLink} from "@nextui-org/react";
|
|
|
|
const MyLink = forwardRef((props, ref) => {
|
|
const {
|
|
Component,
|
|
children,
|
|
showAnchorIcon,
|
|
anchorIcon = <LinkIcon className={linkAnchorClasses} />,
|
|
getLinkProps,
|
|
} = useLink({
|
|
...props,
|
|
ref,
|
|
});
|
|
|
|
return (
|
|
<Component {...getLinkProps()}>
|
|
<>
|
|
{children}
|
|
{showAnchorIcon && anchorIcon}
|
|
</>
|
|
</Component>
|
|
);
|
|
});
|
|
|
|
MyLink.displayName = "MyLink";
|
|
|
|
export default MyLink;`;
|
|
|
|
const AppTs = `import {forwardRef} from "react";
|
|
import {LinkIcon} from "@nextui-org/shared-icons";
|
|
import {linkAnchorClasses} from "@nextui-org/theme";
|
|
|
|
import {LinkProps, useLink} from "@nextui-org/react";
|
|
|
|
export interface MyLinkProps extends LinkProps {}
|
|
|
|
const MyLink = forwardRef<HTMLAnchorElement, MyLinkProps>((props, ref) => {
|
|
const {
|
|
Component,
|
|
children,
|
|
showAnchorIcon,
|
|
anchorIcon = <LinkIcon className={linkAnchorClasses} />,
|
|
getLinkProps,
|
|
} = useLink({
|
|
...props,
|
|
ref,
|
|
});
|
|
|
|
return (
|
|
<Component {...getLinkProps()}>
|
|
<>
|
|
{children}
|
|
{showAnchorIcon && anchorIcon}
|
|
</>
|
|
</Component>
|
|
);
|
|
});
|
|
|
|
MyLink.displayName = "MyLink";
|
|
|
|
export default MyLink;`;
|
|
|
|
const react = {
|
|
"/App.jsx": App,
|
|
};
|
|
|
|
const reactTs = {
|
|
"/App.tsx": AppTs,
|
|
};
|
|
|
|
export default {
|
|
...react,
|
|
...reactTs,
|
|
};
|