Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component naming #92

Merged
merged 3 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add component name in children inspector
  • Loading branch information
foyarash committed Jul 29, 2020
commit dcb5b8ecb2bb90a4bc731c24307df33a04b96593
13 changes: 11 additions & 2 deletions src/components/inspector/elements-list/ElementListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ interface Props extends Pick<IComponent, 'type'> {
onMouseOver: PseudoBoxProps['onMouseOver']
onMouseOut: PseudoBoxProps['onMouseOut']
draggable?: boolean
name?: string
}

const ElementListItem = forwardRef(
(
{ type, opacity = 1, onSelect, onMouseOut, onMouseOver, draggable }: Props,
{
type,
opacity = 1,
onSelect,
onMouseOut,
onMouseOver,
draggable,
name,
}: Props,
ref: React.Ref<HTMLDivElement>,
) => {
return (
Expand All @@ -34,7 +43,7 @@ const ElementListItem = forwardRef(
<Flex align="center">
{draggable && <Icon fontSize="xs" mr={2} name="arrow-up-down" />}
<Text letterSpacing="wide" fontSize="sm" textTransform="capitalize">
{type}
{name || type}
</Text>
</Flex>
<ActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface Props extends Pick<IComponent, 'type' | 'id'> {
onSelect: (id: IComponent['id']) => void
onHover: (id: IComponent['id']) => void
onUnhover: () => void
name?: string
}

const ITEM_TYPE = 'elementItem'
Expand All @@ -20,6 +21,7 @@ const ElementListItemDraggable: React.FC<Props> = ({
index,
onHover,
onUnhover,
name,
}) => {
const ref = useRef<HTMLDivElement>(null)
const [, drop] = useDrop({
Expand Down Expand Up @@ -80,6 +82,7 @@ const ElementListItemDraggable: React.FC<Props> = ({
onMouseOut={onUnhover}
type={type}
draggable
name={name}
/>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/components/inspector/elements-list/ElementsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ElementsList: React.FC<Props> = ({
onSelect={onSelect}
onHover={onHover}
onUnhover={onUnhover}
name={element.componentName}
/>
),
)}
Expand Down