Home / File/ Header.tsx — react Source File

Header.tsx — react Source File

Architecture documentation for Header.tsx, a tsx file in the react codebase. 13 imports, 0 dependents.

File tsx PlaygroundApp Stores 13 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  f0d5e809_a088_0b87_300e_fa0b251099b4["Header.tsx"]
  f69df4a5_0121_dc26_8c32_aacc01afafd1["defaultStore.ts"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> f69df4a5_0121_dc26_8c32_aacc01afafd1
  a500e9d2_8b0e_7f70_119b_2fd15dfcc648["IconGitHub.tsx"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> a500e9d2_8b0e_7f70_119b_2fd15dfcc648
  b52829e1_36fd_3d3b_0245_07f0b61b2691["IconGitHub"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> b52829e1_36fd_3d3b_0245_07f0b61b2691
  eb1fe89c_d5b5_2dc8_df02_4e36dbad219a["Logo.tsx"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> eb1fe89c_d5b5_2dc8_df02_4e36dbad219a
  f741fe53_7d4d_9828_3523_6af89d8f3f58["Logo"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> f741fe53_7d4d_9828_3523_6af89d8f3f58
  73168655_c854_d3d1_50a0_b37f865f3c7e["StoreContext.tsx"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> 73168655_c854_d3d1_50a0_b37f865f3c7e
  17f774ac_71d5_1815_6a34_f58dd5c8a61b["transitionTypes.ts"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> 17f774ac_71d5_1815_6a34_f58dd5c8a61b
  96e80500_b810_3c4e_7180_185cd24929c1["outline"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> 96e80500_b810_3c4e_7180_185cd24929c1
  58c18c31_586d_df88_126c_d6bb73618e93["solid"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> 58c18c31_586d_df88_126c_d6bb73618e93
  1a6a0699_b6b8_aaad_4b2f_053e6a985941["clsx"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> 1a6a0699_b6b8_aaad_4b2f_053e6a985941
  3425fec4_a0d0_8912_46a4_4db3c27a83d2["link"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> 3425fec4_a0d0_8912_46a4_4db3c27a83d2
  1ed1c649_67da_f7f8_4ee7_8c4eb80405dd["notistack"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> 1ed1c649_67da_f7f8_4ee7_8c4eb80405dd
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  f0d5e809_a088_0b87_300e_fa0b251099b4 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  style f0d5e809_a088_0b87_300e_fa0b251099b4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * 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,
  startTransition,
  unstable_addTransitionType as addTransitionType,
} from 'react';
import {defaultStore} from '../lib/defaultStore';
import {IconGitHub} from './Icons/IconGitHub';
import Logo from './Logo';
import {useStore, useStoreDispatch} from './StoreContext';
import {TOGGLE_INTERNALS_TRANSITION} from '../lib/transitionTypes';

export default function Header(): JSX.Element {
  const [showCheck, setShowCheck] = useState(false);
  const store = useStore();
  const dispatchStore = useStoreDispatch();
  const {enqueueSnackbar, closeSnackbar} = useSnackbar();

  const handleReset: () => void = () => {
    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: () => void = () => {
    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 (
    <div className="fixed z-10 flex items-center justify-between w-screen px-5 py-3 bg-white border-b border-gray-200 h-14">
      <div className="flex items-center flex-none h-full gap-2 text-lg">
        <Logo
          className={clsx(
            'w-8 h-8 text-link',
            process.env.NODE_ENV === 'development' && 'text-yellow-600',
          )}
// ... (64 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does Header.tsx do?
Header.tsx is a source file in the react codebase, written in tsx. It belongs to the PlaygroundApp domain, Stores subdomain.
What functions are defined in Header.tsx?
Header.tsx defines 1 function(s): Header.
What does Header.tsx depend on?
Header.tsx imports 13 module(s): IconGitHub, IconGitHub.tsx, Logo, Logo.tsx, StoreContext.tsx, clsx, defaultStore.ts, link, and 5 more.
Where is Header.tsx in the architecture?
Header.tsx is located at compiler/apps/playground/components/Header.tsx (domain: PlaygroundApp, subdomain: Stores, directory: compiler/apps/playground/components).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free