import React from "react"; import { Button, HoverCard } from "@mantine/core"; import { styled, DefaultTheme } from "styled-components"; import _get from "lodash.get"; import { VscEdit } from "react-icons/vsc"; import { KeyPath } from "react-json-tree"; import useJson from "src/store/useJson"; interface LabelProps { keyPath: KeyPath; nodeType: string; setOpened: React.Dispatch>; setSelectedValue: React.Dispatch>; setPath: React.Dispatch>; setValue: React.Dispatch>; } function getLabelColor({ $type, theme }: { $type?: string; theme: DefaultTheme }) { if ($type === "Object") return theme.NODE_COLORS.PARENT_OBJ; if ($type === "Array") return theme.NODE_COLORS.PARENT_ARR; return theme.NODE_COLORS.PARENT_OBJ; } const StyledLabel = styled.span<{ $nodeType?: string }>` color: ${({ theme, $nodeType }) => getLabelColor({ theme, $type: $nodeType })}; &:hover { filter: brightness(1.5); transition: filter 0.2s ease-in-out; } `; export const Label = ({ keyPath, nodeType, setOpened, setSelectedValue, setPath, setValue, }: LabelProps) => { const getJson = useJson(state => state.getJson); return ( {keyPath[0]}: ); };