|
8 | 8 | SchemaNodeKind, |
9 | 9 | } from '@stoplight/json-schema-tree'; |
10 | 10 | import { Box, Flex, Icon, Select, SpaceVals, VStack } from '@stoplight/mosaic'; |
| 11 | +import { Atom } from 'jotai'; |
11 | 12 | import { useAtomValue, useUpdateAtom } from 'jotai/utils'; |
12 | 13 | import last from 'lodash/last.js'; |
13 | 14 | import * as React from 'react'; |
@@ -39,7 +40,6 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = React.memo(({ |
39 | 40 | const { defaultExpandedDepth, renderRowAddon, onGoToRef, hideExamples, renderRootTreeLines } = useJSVOptionsContext(); |
40 | 41 |
|
41 | 42 | const setHoveredNode = useUpdateAtom(hoveredNodeAtom); |
42 | | - const isHovering = useAtomValue(isNodeHoveredAtom(schemaNode)); |
43 | 43 |
|
44 | 44 | const [isExpanded, setExpanded] = React.useState<boolean>( |
45 | 45 | !isMirroredNode(schemaNode) && nestingLevel <= defaultExpandedDepth, |
@@ -156,7 +156,7 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = React.memo(({ |
156 | 156 | )} |
157 | 157 | </Flex> |
158 | 158 |
|
159 | | - {hasProperties && <Box bg={isHovering ? 'canvas-200' : undefined} h="px" flex={1} mx={3} />} |
| 159 | + {hasProperties && <Divider atom={isNodeHoveredAtom(schemaNode)} />} |
160 | 160 |
|
161 | 161 | <Properties required={required} deprecated={deprecated} validations={validations} /> |
162 | 162 | </Flex> |
@@ -188,6 +188,12 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = React.memo(({ |
188 | 188 | ); |
189 | 189 | }); |
190 | 190 |
|
| 191 | +const Divider = ({ atom }: { atom: Atom<boolean> }) => { |
| 192 | + const isHovering = useAtomValue(atom); |
| 193 | + |
| 194 | + return <Box bg={isHovering ? 'canvas-200' : undefined} h="px" flex={1} mx={3} />; |
| 195 | +}; |
| 196 | + |
191 | 197 | function shouldShowPropertyName(schemaNode: SchemaNode) { |
192 | 198 | return ( |
193 | 199 | schemaNode.subpath.length === 2 && |
|
0 commit comments