Skip to content

Commit

Permalink
feat: added icons and tooltips to player and camera entities (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala authored Mar 26, 2024
1 parent 00c56d2 commit 6623424
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 143 deletions.
292 changes: 155 additions & 137 deletions packages/@dcl/inspector/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/@dcl/inspector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@dcl/inspector",
"version": "0.1.0",
"dependencies": {
"@dcl/asset-packs": "1.14.0",
"@dcl/asset-packs": "1.15.2",
"ts-deepmerge": "^7.0.0"
},
"devDependencies": {
Expand Down Expand Up @@ -71,4 +71,4 @@
},
"types": "dist/tooling-entrypoint.d.ts",
"typings": "dist/tooling-entrypoint.d.ts"
}
}
17 changes: 17 additions & 0 deletions packages/@dcl/inspector/src/components/Hierarchy/Hierarchy.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,20 @@
overflow-y: auto;
padding: 6px;
}

.Hierarchy .tree-icon {
width: 16px;
height: 14px;
margin-right: 4px;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}

.Hierarchy .player-icon {
background-image: url(./icons/player.svg);
}

.Hierarchy .camera-icon {
background-image: url(./icons/camera.svg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import './Hierarchy.css'
function HierarchyIcon({ value }: { value: Entity }) {
if (value === ROOT) {
return <span style={{ marginRight: '4px' }}></span>
} else if (value === PLAYER) {
return <span className="tree-icon player-icon"></span>
} else if (value === CAMERA) {
return <span className="tree-icon camera-icon"></span>
} else {
return <FiHexagon style={{ marginRight: '4px' }} />
}
Expand Down
11 changes: 11 additions & 0 deletions packages/@dcl/inspector/src/components/Hierarchy/icons/camera.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { useEntityComponent } from '../../../hooks/sdk/useEntityComponent'
import { SdkContextValue } from '../../../lib/sdk/context'
import { analytics, Event } from '../../../lib/logic/analytics'
import { getAssetByModel } from '../../../lib/logic/catalog'
import { CAMERA, PLAYER, ROOT } from '../../../lib/sdk/tree'
import { InfoTooltip } from '../../ui'

import './ActionArea.css'

Expand Down Expand Up @@ -98,10 +100,55 @@ const ActionArea: React.FC<WithSdkProps & Props> = ({ sdk, ...props }) => {
)
}, [isEntityHidden, handleToggleHideComponent])

const isRoot = entity === ROOT
const isPlayer = entity === PLAYER
const isCamera = entity === CAMERA
const isEntity = !isPlayer && !isCamera && !isRoot

const infoTooltip = useCallback(
(text: string, learnMore?: string) => (
<div className="action-button">
<InfoTooltip
text={
<>
{text}
{learnMore ? (
<>
&nbsp;
<a href={learnMore} target="_blank" rel="noopener">
Learn more
</a>
</>
) : null}
</>
}
type="info"
position="right center"
/>
</div>
),
[]
)

return (
<div className="action-area">
{toggleLockButton()}
{toggleVisibleButton()}
{isEntity && toggleLockButton()}
{isEntity && toggleVisibleButton()}
{isPlayer &&
infoTooltip(
'The player’s avatar. Nested items are fixed to the player’s position.',
'https://docs.decentraland.org/creator/web-editor/#special-entities'
)}
{isCamera &&
infoTooltip(
'The player’s camera. Nested items remain fixed to the camera’s position.',
'https://docs.decentraland.org/creator/web-editor/#special-entities'
)}
{isRoot &&
infoTooltip(
'The root entity. All items in the scene are children of this entity. Open it to adjust the scene settings.',
'https://docs.decentraland.org/creator/development-guide/sdk7/scene-metadata/#metadata'
)}
</div>
)
}
Expand Down
3 changes: 1 addition & 2 deletions packages/@dcl/inspector/src/components/Tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { IoIosArrowDown, IoIosArrowForward } from 'react-icons/io'
import cx from 'classnames'
import { Entity } from '@dcl/ecs'

import { ROOT } from '../../lib/sdk/tree'
import { withContextMenu } from '../../hoc/withContextMenu'
import { Input } from '../Input'
import { ContextMenu } from './ContextMenu'
Expand Down Expand Up @@ -194,7 +193,7 @@ export function Tree<T>() {
}

const isEntity = useMemo(() => {
return typeof value !== 'string' && (value as Entity) !== ROOT
return typeof value !== 'string'
}, [value])

drag(drop(ref))
Expand Down

0 comments on commit 6623424

Please sign in to comment.