Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import clsx from "clsx";
import { observer } from "mobx-react";
import styles from "./ChannelLegend.module.scss";
 
const ChannelLegend = observer(({ item }) => {
  const { channels, highlightedChannelId, isChannelHiddenMap } = item;
  return (
    <div
      className={clsx(styles.channelLegend, "flex justify-center gap-2 mb-2", {
        [styles.hovering]: highlightedChannelId !== null,
      })}
    >
      {channels.map((channel) => {
        const isVisible = !isChannelHiddenMap[channel.id];
        const isHighlighted = highlightedChannelId === channel.id;
 
        return (
          <div
            key={channel.id}
            className={clsx(styles.channel, "cursor-pointer select-none", { [styles.hovered]: isHighlighted })}
            onMouseEnter={() => item.setHighlightedChannel(channel.id)}
            onMouseLeave={() => item.clearHighlightedChannel()}
            onClick={(e) => {
              e.preventDefault();
              e.stopPropagation();
              item.toggleChannelVisibility(channel.id);
            }}
            style={{
              "--marker-color": channel.strokecolor,
            }}
          >
            <span className={clsx(styles.channelMarker, "mr-1", { [styles.hidden]: !isVisible })} />
            <span className="channel-name">{channel.legend || channel.columnName}</span>
          </div>
        );
      })}
    </div>
  );
});
 
export default ChannelLegend;