/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import { RefreshIcon, ShareIcon } from "@heroicons/react/outline"; import { CheckIcon } from "@heroicons/react/solid"; import clsx from "clsx"; import Link from "next/link"; import { useSnackbar } from "notistack"; import { useState } from "react"; import { defaultStore } from "../lib/defaultStore"; import { IconGitHub } from "./Icons/IconGitHub"; import Logo from "./Logo"; import { useStoreDispatch } from "./StoreContext"; export default function Header() { const [showCheck, setShowCheck] = useState(false); const dispatchStore = useStoreDispatch(); const { enqueueSnackbar, closeSnackbar } = useSnackbar(); const handleReset = () => { if (confirm("Are you sure you want to reset the playground?")) { /* Close open snackbars if any. This is necessary because when displaying outputs (Preview or not), we only close previous snackbars if we received new messages, which is needed in order to display "Bad URL" or success messages when loading Playground for the first time. Otherwise, messages such as "Bad URL" will be closed by the outputs calling `closeSnackbar`. */ closeSnackbar(); dispatchStore({ type: "setStore", payload: { store: defaultStore } }); } }; const handleShare = () => { navigator.clipboard.writeText(location.href).then(() => { enqueueSnackbar("URL copied to clipboard"); setShowCheck(true); // Show the check mark icon briefly after URL is copied setTimeout(() => setShowCheck(false), 1000); }); }; return (
React Compiler Playground