DrMint 35b58982d0
Use Jotai instead of React Context (#65)
* Turn React Context into Jotai

* Finish converting the remaining contexts into Jotai

* Changed the readme

* Fixed build

* Provider hell be gone

* Fixed build
2022-11-04 02:30:20 +01:00

37 lines
1.5 KiB
TypeScript

import { Ico, Icon } from "./Ico";
import { ToolTip } from "./ToolTip";
import { cJoin } from "helpers/className";
import { useAtomGetter } from "helpers/atoms";
import { atoms } from "contexts/atoms";
/*
* ╭─────────────╮
* ───────────────────────────────────────╯ COMPONENT ╰───────────────────────────────────────────
*/
interface Props {
id: string;
className?: string;
}
// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
export const AnchorShare = ({ id, className }: Props): JSX.Element => {
const langui = useAtomGetter(atoms.localData.langui);
return (
<ToolTip content={langui.copy_anchor_link} trigger="mouseenter" className="text-sm">
<ToolTip content={langui.anchor_link_copied} trigger="click" className="text-sm">
<Ico
icon={Icon.Link}
className={cJoin("transition-color cursor-pointer hover:text-dark", className)}
onClick={() => {
navigator.clipboard.writeText(
`${process.env.NEXT_PUBLIC_URL_SELF + window.location.pathname}#${id}`
);
}}
/>
</ToolTip>
</ToolTip>
);
};