Home / File/ Message.tsx — react Source File

Message.tsx — react Source File

Architecture documentation for Message.tsx, a tsx file in the react codebase. 4 imports, 1 dependents.

File tsx PlaygroundApp UI 4 imports 1 dependents 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  f9d1133a_53e5_153c_11b1_7ac96107f8d7["Message.tsx"]
  200e1d7d_8772_57b3_072e_509f07464987["index.ts"]
  f9d1133a_53e5_153c_11b1_7ac96107f8d7 --> 200e1d7d_8772_57b3_072e_509f07464987
  58c18c31_586d_df88_126c_d6bb73618e93["solid"]
  f9d1133a_53e5_153c_11b1_7ac96107f8d7 --> 58c18c31_586d_df88_126c_d6bb73618e93
  1ed1c649_67da_f7f8_4ee7_8c4eb80405dd["notistack"]
  f9d1133a_53e5_153c_11b1_7ac96107f8d7 --> 1ed1c649_67da_f7f8_4ee7_8c4eb80405dd
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  f9d1133a_53e5_153c_11b1_7ac96107f8d7 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  aea9e403_bd5c_975e_c5c8_ef2ec5387324["page.tsx"]
  aea9e403_bd5c_975e_c5c8_ef2ec5387324 --> f9d1133a_53e5_153c_11b1_7ac96107f8d7
  style f9d1133a_53e5_153c_11b1_7ac96107f8d7 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 {
  BanIcon,
  ExclamationIcon,
  InformationCircleIcon,
  XIcon,
} from '@heroicons/react/solid';
import {CustomContentProps, SnackbarContent, useSnackbar} from 'notistack';
import {forwardRef} from 'react';
import {MessageLevel, MessageSource} from '../lib/stores';

// https://notistack.com/examples/advanced/custom-component#custom-variant-(typescript)
declare module 'notistack' {
  interface VariantOverrides {
    message: {
      title: string;
      level: MessageLevel;
      codeframe: string | undefined;
    };
  }
}

interface MessageProps extends CustomContentProps {
  title: string;
  level: MessageLevel;
  source: MessageSource;
  codeframe: string | undefined;
}

const Message = forwardRef<HTMLDivElement, MessageProps>(
  ({id, title, level, source, codeframe}, ref) => {
    const {closeSnackbar} = useSnackbar();
    const isDismissible = source !== MessageSource.Playground;

    return (
      <SnackbarContent
        ref={ref}
        className="flex items-start justify-between gap-3 px-4 py-3 text-sm bg-white border rounded-md shadow w-toast">
        <div className="flex gap-3 w-toast-body">
          {level === MessageLevel.Warning ? (
            <div className="flex items-center justify-center flex-none rounded-md w-7 h-7 bg-amber-100">
              <ExclamationIcon className="w-5 h-5 text-amber-600" />
            </div>
          ) : level === MessageLevel.Error ? (
            <div className="flex items-center justify-center flex-none bg-red-100 rounded-md w-7 h-7">
              <BanIcon className="w-5 h-5 text-red-600" />
            </div>
          ) : (
            <div className="flex items-center justify-center flex-none rounded-md bg-sky-100 w-7 h-7">
              <InformationCircleIcon className="w-5 h-5 text-sky-600" />
            </div>
          )}
          <div className="flex flex-col justify-center gap-1 w-toast-title">
            <p className="w-full">{title}</p>
            {codeframe ? (
              <pre className="overflow-x-auto break-words whitespace-pre-wrap">
                <code className="text-xs">{codeframe}</code>
              </pre>
            ) : null}
          </div>
        </div>
        {isDismissible ? (
          <button
            className="flex items-center justify-center flex-none transition-colors duration-150 ease-in rounded-md justify-self-end group w-7 h-7 hover:bg-gray-200"
            onClick={() => closeSnackbar(id)}>
            <XIcon className="w-5 h-5 fill-gray-500 group-hover:fill-gray-800" />
          </button>
        ) : null}
      </SnackbarContent>
    );
  },
);

Message.displayName = 'MessageComponent';

export default Message;

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does Message.tsx do?
Message.tsx is a source file in the react codebase, written in tsx. It belongs to the PlaygroundApp domain, UI subdomain.
What functions are defined in Message.tsx?
Message.tsx defines 1 function(s): Message.
What does Message.tsx depend on?
Message.tsx imports 4 module(s): index.ts, notistack, react, solid.
What files import Message.tsx?
Message.tsx is imported by 1 file(s): page.tsx.
Where is Message.tsx in the architecture?
Message.tsx is located at compiler/apps/playground/components/Message.tsx (domain: PlaygroundApp, subdomain: UI, 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