Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | import React, { useCallback, useRef } from "react"; import { useAppDispatch, useAppSelector } from "store/hooks"; import l10n, { L10NKey } from "shared/lib/lang/l10n"; import { scriptEventSelectors } from "store/features/entities/entitiesState"; import { selectScriptEventDefs } from "store/features/scriptEventDefs/scriptEventDefsState"; import settingsActions from "store/features/settings/settingsActions"; import { BreakpointData } from "store/features/settings/settingsState"; import DebuggerScriptCtxBreadcrumb from "components/debugger/DebuggerScriptCtxBreadcrumb"; import styled from "styled-components"; import { Button } from "ui/buttons/Button"; import { StyledButton } from "ui/buttons/style"; import { BreakpointIcon, CloseIcon } from "ui/icons/Icons"; import useHover from "ui/hooks/use-hover"; interface DebuggerBreakpointItemProps { breakpoint: BreakpointData; } const Wrapper = styled.div` display: flex; padding: 5px 10px; padding-left: 7px; font-size: 11px; border-bottom: 1px solid ${(props) => props.theme.colors.sidebar.border}; background: ${(props) => props.theme.colors.scripting.form.background}; display: flex; align-items: center; ${StyledButton} { margin-right: 3px; svg { width: 15px; height: 15px; min-width: 15px; min-height: 15px; opacity: 0.3; } } &:hover ${StyledButton} { svg { opacity: 1; width: 10px; height: 10px; min-width: 10px; min-height: 10px; } } `; const BreakpointLabel = styled.div` display: flex; flex-direction: column; flex-grow: 1; `; const BreakpointName = styled.div` font-weight: bold; `; const BreakpointPath = styled.div``; const DebuggerBreakpointItem = ({ breakpoint, }: DebuggerBreakpointItemProps) => { const dispatch = useAppDispatch(); const ref = useRef<HTMLDivElement>(null); const isHovered = useHover(ref); const scriptEventId = breakpoint.scriptEventId; const scriptEvent = useAppSelector((state) => scriptEventSelectors.selectById(state, scriptEventId) ); const scriptEventDefs = useAppSelector((state) => selectScriptEventDefs(state) ); const command = scriptEvent?.command ?? ""; const localisedCommand = l10n(command as L10NKey); const eventName = localisedCommand !== command ? localisedCommand : (scriptEventDefs[command] && scriptEventDefs[command]?.name) || command; const onToggle = useCallback(() => { dispatch(settingsActions.toggleBreakpoint(breakpoint)); }, [breakpoint, dispatch]); return ( <Wrapper ref={ref}> <Button variant="transparent" size="small" onClick={onToggle}> {isHovered ? <CloseIcon /> : <BreakpointIcon />} </Button> <BreakpointLabel> <BreakpointName>{eventName}</BreakpointName> <BreakpointPath> <DebuggerScriptCtxBreadcrumb context={breakpoint.context} /> </BreakpointPath> </BreakpointLabel> </Wrapper> ); }; export default DebuggerBreakpointItem; |