-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parent inspector and hover through inspector (#51)
* Add parent inspector and hover through inspector * Update element layout * Update icons
- Loading branch information
Showing
12 changed files
with
222 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { getSelectedComponentParent } from '../../core/selectors/components' | ||
import ElementListItem from './elements-list/ElementListItem' | ||
import useDispatch from '../../hooks/useDispatch' | ||
|
||
const ParentInspector = () => { | ||
const parentComponent = useSelector(getSelectedComponentParent) | ||
const dispatch = useDispatch() | ||
|
||
const onSelect = () => { | ||
dispatch.components.select(parentComponent.id) | ||
} | ||
|
||
const onHover = () => { | ||
dispatch.components.hover(parentComponent.id) | ||
} | ||
|
||
const onUnhover = () => { | ||
dispatch.components.unhover() | ||
} | ||
|
||
return ( | ||
<ElementListItem | ||
type={parentComponent.type} | ||
onMouseOver={onHover} | ||
onMouseOut={onUnhover} | ||
onSelect={onSelect} | ||
/> | ||
) | ||
} | ||
|
||
export default ParentInspector |
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/components/inspector/elements-list/ElementListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { forwardRef } from 'react' | ||
import { Icon, PseudoBox, Text, PseudoBoxProps, Flex } from '@chakra-ui/core' | ||
import ActionButton from '../ActionButton' | ||
|
||
interface Props extends Pick<IComponent, 'type'> { | ||
opacity?: number | ||
onSelect: PseudoBoxProps['onClick'] | ||
onMouseOver: PseudoBoxProps['onMouseOver'] | ||
onMouseOut: PseudoBoxProps['onMouseOut'] | ||
draggable?: boolean | ||
} | ||
|
||
const ElementListItem = forwardRef( | ||
( | ||
{ type, opacity = 1, onSelect, onMouseOut, onMouseOver, draggable }: Props, | ||
ref: React.Ref<HTMLDivElement>, | ||
) => { | ||
return ( | ||
<PseudoBox | ||
boxSizing="border-box" | ||
transition="margin 200ms" | ||
my={1} | ||
rounded="md" | ||
p={1} | ||
display="flex" | ||
alignItems="center" | ||
cursor={draggable ? 'move' : undefined} | ||
opacity={opacity} | ||
ref={ref} | ||
onMouseOver={onMouseOver} | ||
onMouseOut={onMouseOut} | ||
> | ||
<Flex justify="space-between" align="center" w="100%"> | ||
<Flex align="center"> | ||
{draggable && <Icon fontSize="xs" mr={2} name="arrow-up-down" />} | ||
<Text letterSpacing="wide" fontSize="sm" textTransform="capitalize"> | ||
{type} | ||
</Text> | ||
</Flex> | ||
<ActionButton | ||
label="Inspect" | ||
onClick={onSelect} | ||
icon="settings" | ||
variantColor="blackAlpha" | ||
/> | ||
</Flex> | ||
</PseudoBox> | ||
) | ||
}, | ||
) | ||
|
||
export default ElementListItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react' | ||
import { Box } from '@chakra-ui/core' | ||
import ElementListItem from './ElementListItemDraggable' | ||
|
||
interface Props { | ||
elements: IComponent[] | ||
moveItem: (fromIndex: number, toIndex: number) => void | ||
onSelect: (id: IComponent['id']) => void | ||
onHover: (id: IComponent['id']) => void | ||
onUnhover: () => void | ||
} | ||
|
||
const ElementsList: React.FC<Props> = ({ | ||
elements, | ||
moveItem, | ||
onSelect, | ||
onHover, | ||
onUnhover, | ||
}) => { | ||
return ( | ||
<Box mx={2} h="100%"> | ||
{elements.map( | ||
(element, index) => | ||
element && ( | ||
<ElementListItem | ||
key={element.id} | ||
type={element.type} | ||
index={index} | ||
moveItem={moveItem} | ||
id={element.id} | ||
onSelect={onSelect} | ||
onHover={onHover} | ||
onUnhover={onUnhover} | ||
/> | ||
), | ||
)} | ||
</Box> | ||
) | ||
} | ||
|
||
export default ElementsList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.