Home / File/ TabbedWindow.tsx — react Source File

TabbedWindow.tsx — react Source File

Architecture documentation for TabbedWindow.tsx, a tsx file in the react codebase. 3 imports, 2 dependents.

File tsx PlaygroundApp Stores 3 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  b03258e0_be86_ee60_1d40_970f96914cd3["TabbedWindow.tsx"]
  17f774ac_71d5_1815_6a34_f58dd5c8a61b["transitionTypes.ts"]
  b03258e0_be86_ee60_1d40_970f96914cd3 --> 17f774ac_71d5_1815_6a34_f58dd5c8a61b
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  b03258e0_be86_ee60_1d40_970f96914cd3 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  1a6a0699_b6b8_aaad_4b2f_053e6a985941["clsx"]
  b03258e0_be86_ee60_1d40_970f96914cd3 --> 1a6a0699_b6b8_aaad_4b2f_053e6a985941
  e75ba65e_505f_abf4_2928_6f0aefb2fc72["Input.tsx"]
  e75ba65e_505f_abf4_2928_6f0aefb2fc72 --> b03258e0_be86_ee60_1d40_970f96914cd3
  034b2d8c_7261_f40f_c380_2b5db8fde033["Output.tsx"]
  034b2d8c_7261_f40f_c380_2b5db8fde033 --> b03258e0_be86_ee60_1d40_970f96914cd3
  style b03258e0_be86_ee60_1d40_970f96914cd3 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 React, {
  startTransition,
  useId,
  unstable_ViewTransition as ViewTransition,
  unstable_addTransitionType as addTransitionType,
} from 'react';
import clsx from 'clsx';
import {TOGGLE_TAB_TRANSITION} from '../lib/transitionTypes';

export default function TabbedWindow({
  tabs,
  activeTab,
  onTabChange,
}: {
  tabs: Map<string, React.ReactNode>;
  activeTab: string;
  onTabChange: (tab: string) => void;
}): React.ReactElement {
  const id = useId();
  const transitionName = `tab-highlight-${id}`;

  const handleTabChange = (tab: string): void => {
    startTransition(() => {
      addTransitionType(TOGGLE_TAB_TRANSITION);
      onTabChange(tab);
    });
  };

  return (
    <div className="flex-1 min-w-[550px] sm:min-w-0">
      <div className="flex flex-col h-full max-w-full">
        <div className="flex p-2 flex-shrink-0">
          {Array.from(tabs.keys()).map(tab => {
            const isActive = activeTab === tab;
            return (
              <button
                key={tab}
                onClick={() => handleTabChange(tab)}
                className={clsx(
                  'transition-transform py-1.5 px-1.5 xs:px-3 sm:px-4 rounded-full text-sm relative',
                  isActive ? 'text-link' : 'hover:bg-primary/5',
                )}>
                {isActive && (
                  <ViewTransition
                    name={transitionName}
                    enter={{default: 'none'}}
                    exit={{default: 'none'}}
                    share={{
                      [TOGGLE_TAB_TRANSITION]: 'tab-highlight',
                      default: 'none',
                    }}
                    update={{default: 'none'}}>
                    <div className="absolute inset-0 bg-highlight rounded-full" />
                  </ViewTransition>
                )}
                <ViewTransition
                  enter={{default: 'none'}}
                  exit={{default: 'none'}}
                  update={{
                    [TOGGLE_TAB_TRANSITION]: 'tab-text',
                    default: 'none',
                  }}>
                  <span className="relative z-1">{tab}</span>
                </ViewTransition>
              </button>
            );
          })}
        </div>
        <div className="flex-1 overflow-hidden w-full h-full">
          {tabs.get(activeTab)}
        </div>
      </div>
    </div>
  );
}

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does TabbedWindow.tsx do?
TabbedWindow.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 TabbedWindow.tsx?
TabbedWindow.tsx defines 1 function(s): TabbedWindow.
What does TabbedWindow.tsx depend on?
TabbedWindow.tsx imports 3 module(s): clsx, react, transitionTypes.ts.
What files import TabbedWindow.tsx?
TabbedWindow.tsx is imported by 2 file(s): Input.tsx, Output.tsx.
Where is TabbedWindow.tsx in the architecture?
TabbedWindow.tsx is located at compiler/apps/playground/components/TabbedWindow.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