/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-devtools-shared/src/devtools/views/Profiler/ChartNode.js
80 строк
2 KB
Jan Kassens
Update Flow to 0.263 (#34269)
22 авг 2025, 19:10
Не верифицирован
22 авг 2025, 19:10
6de32a5
Код
Авторство
О чём код?
/** * 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 styles from './ChartNode.css'; import typeof {SyntheticMouseEvent} from 'react-dom-bindings/src/events/SyntheticEvent'; type Props = { color: string, height: number, isDimmed?: boolean, label: string, onClick: (event: SyntheticMouseEvent) => mixed, onDoubleClick?: (event: SyntheticMouseEvent) => mixed, onMouseEnter: (event: SyntheticMouseEvent) => mixed, onMouseLeave: (event: SyntheticMouseEvent) => mixed, placeLabelAboveNode?: boolean, textStyle?: Object, width: number, x: number, y: number, }; const minWidthToDisplay = 35; export default function ChartNode({ color, height, isDimmed = false, label, onClick, onMouseEnter, onMouseLeave, onDoubleClick, textStyle, width, x, y, }: Props): React.Node { return ( <g className={styles.Group} transform={`translate(${x},${y})`}> <rect width={width} height={height} fill={color} onClick={onClick} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} onDoubleClick={onDoubleClick} className={styles.Rect} style={{ opacity: isDimmed ? 0.5 : 1, }} /> {width >= minWidthToDisplay && ( <foreignObject width={width} height={height} className={styles.ForeignObject} style={{ paddingLeft: x < 0 ? -x : 0, opacity: isDimmed ? 0.75 : 1, display: width < minWidthToDisplay ? 'none' : 'block', }} y={0}> <div className={styles.Div} style={textStyle}> {label} </div> </foreignObject> )} </g> ); }