Home / File/ CommitRankedListItem.js — react Source File

CommitRankedListItem.js — react Source File

Architecture documentation for CommitRankedListItem.js, a javascript file in the react codebase. 8 imports, 1 dependents.

File javascript BabelCompiler Validation 8 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  89b916c8_640c_20f1_5b9e_9022ade373b8["CommitRankedListItem.js"]
  f14bbaea_a3f1_245b_696c_0c4d0bd624c7["constants.js"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> f14bbaea_a3f1_245b_696c_0c4d0bd624c7
  0f941e70_3fdb_aa42_7939_2878d5d4125b["utils.js"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> 0f941e70_3fdb_aa42_7939_2878d5d4125b
  56bcba00_c929_183d_07ac_24aeb71afa91["ChartNode.js"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> 56bcba00_c929_183d_07ac_24aeb71afa91
  b359961f_cc11_89c8_9f4d_ba4c236458c1["ChartNode"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> b359961f_cc11_89c8_9f4d_ba4c236458c1
  5996f1e4_af81_a51b_84bc_175bfba4f818["SettingsContext.js"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> 5996f1e4_af81_a51b_84bc_175bfba4f818
  0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0["CommitRanked.js"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> 0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  74ef1e61_51ba_b12a_3785_620fbf571ab2["react-window"]
  89b916c8_640c_20f1_5b9e_9022ade373b8 --> 74ef1e61_51ba_b12a_3785_620fbf571ab2
  0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0["CommitRanked.js"]
  0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0 --> 89b916c8_640c_20f1_5b9e_9022ade373b8
  style 89b916c8_640c_20f1_5b9e_9022ade373b8 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.
 *
 * @flow
 */

import * as React from 'react';
import {memo, useCallback, useContext} from 'react';
import {areEqual} from 'react-window';
import {minBarWidth} from './constants';
import {getGradientColor} from './utils';
import ChartNode from './ChartNode';
import {SettingsContext} from '../Settings/SettingsContext';

import type {ItemData} from './CommitRanked';

type Props = {
  data: ItemData,
  index: number,
  style: Object,
};

function CommitRankedListItem({data, index, style}: Props) {
  const {
    chartData,
    onElementMouseEnter,
    onElementMouseLeave,
    scaleX,
    selectedFiberIndex,
    selectFiber,
    width,
  } = data;

  const node = chartData.nodes[index];

  const {lineHeight} = useContext(SettingsContext);

  const handleClick = useCallback(
    (event: $FlowFixMe) => {
      event.stopPropagation();
      const {id, name} = node;
      selectFiber(id, name);
    },
    [node, selectFiber],
  );

  const handleMouseEnter = () => {
    const {id, name} = node;
    onElementMouseEnter({id, name});
  };

  const handleMouseLeave = () => {
    onElementMouseLeave();
  };

  // List items are absolutely positioned using the CSS "top" attribute.
  // The "left" value will always be 0.
  // Since height is fixed, and width is based on the node's duration,
  // We can ignore those values as well.
  const top = parseInt(style.top, 10);

  return (
    <ChartNode
      color={getGradientColor(node.value / chartData.maxValue)}
      height={lineHeight}
      isDimmed={index < selectedFiberIndex}
      key={node.id}
      label={node.label}
      onClick={handleClick}
      onMouseEnter={handleMouseEnter}
      onMouseLeave={handleMouseLeave}
      width={Math.max(minBarWidth, scaleX(node.value, width))}
      x={0}
      y={top}
    />
  );
}

export default (memo(CommitRankedListItem, areEqual): component(
  ...props: Props
));

Domain

Subdomains

Frequently Asked Questions

What does CommitRankedListItem.js do?
CommitRankedListItem.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in CommitRankedListItem.js?
CommitRankedListItem.js defines 1 function(s): CommitRankedListItem.
What does CommitRankedListItem.js depend on?
CommitRankedListItem.js imports 8 module(s): ChartNode, ChartNode.js, CommitRanked.js, SettingsContext.js, constants.js, react, react-window, utils.js.
What files import CommitRankedListItem.js?
CommitRankedListItem.js is imported by 1 file(s): CommitRanked.js.
Where is CommitRankedListItem.js in the architecture?
CommitRankedListItem.js is located at packages/react-devtools-shared/src/devtools/views/Profiler/CommitRankedListItem.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Profiler).

Analyze Your Own Codebase

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

Try Supermodel Free