@heroicons/react/solid#ShareIcon TypeScript Examples

The following examples show how to use @heroicons/react/solid#ShareIcon. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NavBar.tsx    From ide with Mozilla Public License 2.0 4 votes vote down vote up
NavBar = (props: DesktopNavBarProps): JSX.Element => {
  const onlineUsers = useOnlineUsers();
  const onlineUserCount = onlineUsers?.filter(isUserOnline).length;

  const [showCopied, setShowCopied] = useState(false);
  const handleShare = () => {
    navigator.clipboard.writeText(window.location.href).then(
      () => {
        setShowCopied(true);
        setTimeout(() => {
          setShowCopied(false);
        }, 3000);
      },
      () => {
        alert(
          "Couldn't copy link to clipboard. Share the current URL manually."
        );
      }
    );
  };

  return (
    <div className="flex items-center overflow-x-auto">
      <div className="flex items-center divide-x divide-gray-700">
        <Link href="/">
          <a className="relative inline-flex items-center px-4 py-2 shadow-sm text-sm font-medium text-gray-200 hover:bg-gray-800 focus:bg-gray-800 focus:outline-none">
            <HomeIcon className="h-5 w-5" />
          </a>
        </Link>
        {props.fileMenu}
        <button
          type="button"
          className="relative inline-flex items-center px-4 py-2 shadow-sm text-sm font-medium text-gray-200 hover:bg-gray-800 focus:bg-gray-800 focus:outline-none"
          onClick={() => handleShare()}
        >
          <ShareIcon
            className="-ml-1 mr-2 h-5 w-5 text-gray-400"
            aria-hidden="true"
          />
          {showCopied ? 'URL Copied!' : 'Share'}
        </button>
      </div>
      {props.runButton}
      <div className="flex items-center divide-x divide-gray-700">
        <a
          href="https://github.com/cpinitiative/ide/issues"
          target="_blank"
          className="px-4 py-2 text-gray-400 hover:text-gray-200 text-sm font-medium flex-shrink-0"
          rel="noreferrer"
        >
          Report an Issue
        </a>
        <a
          href="https://github.com/cpinitiative/ide"
          target="_blank"
          rel="noreferrer"
          className="px-4 py-2 text-gray-400 hover:text-gray-200 text-sm font-medium flex-shrink-0"
        >
          Star this on Github!
        </a>
        {props.showViewOnly && (
          <span className="px-4 py-2 text-gray-400 text-sm font-medium">
            View Only
          </span>
        )}
      </div>
      <div className="flex-1" />
      {props.showSidebarButton && (
        <div>
          <button
            type="button"
            className="relative inline-flex items-center px-4 py-2 shadow-sm text-sm font-medium text-gray-200 hover:bg-gray-800 focus:bg-gray-800 focus:outline-none"
            onClick={() => props.onToggleSidebar()}
          >
            {props.isSidebarOpen ? (
              <ChevronRightIcon
                className="-ml-1 mr-2 h-5 w-5 text-gray-400"
                aria-hidden="true"
              />
            ) : (
              <ChevronLeftIcon
                className="-ml-1 mr-2 h-5 w-5 text-gray-400"
                aria-hidden="true"
              />
            )}
            {onlineUserCount} User{onlineUserCount === 1 ? '' : 's'} Online
          </button>
        </div>
      )}
    </div>
  );
}