Skip to content

Commit

Permalink
Closes #218 - Make entrypoints distinct in asset tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
lrasmus committed Nov 16, 2024
1 parent 09f3324 commit f1151c7
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions app/components/AssetTree/AssetNode/AssetNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
FaChevronRight,
FaPaperclip,
FaFilter,
FaGlobe
FaGlobe,
FaFileImport
} from 'react-icons/fa';
import styled from 'styled-components';
import PropTypes from 'prop-types';
Expand All @@ -21,13 +22,31 @@ const getPaddingLeft = (level) => {
return level * 20;
};

const getNodeColor = (node) => {
if (!node || !node.attributes) {
return '#000';
}
}

const getNodeFontWeight = (node) => {
if (!node || !node.attributes) {
return 'normal';
}

if (node.attributes.entrypoint) {
return '600';
}
}

const StyledTreeNode = styled.div`
display: flex;
flex-direction: row;
align-items: center;
padding: 5px 8px;
padding-left: ${(props) => getPaddingLeft(props.$level)}px;
${(props) => (props.selected ? 'background-color: #eee;' : null)}
color: ${(props) => getNodeColor(props.node)};
font-weight: ${(props) => getNodeFontWeight(props.node)};
`;

const NodeIcon = styled.div`
Expand All @@ -41,7 +60,7 @@ const StyledInput = styled.input`

const StyledLabel = styled.span`
overflow: hidden;
text-overflow: ellipsis;
text-overflow: ellipsis;
`;

function AssetNode(props) {
Expand Down Expand Up @@ -86,6 +105,7 @@ function AssetNode(props) {
<StyledTreeNode
$level={level}
type={node.type}
node={node}
selected={node && selectedAsset && node.uri === selectedAsset.uri}
onContextMenu={(e) => {
if (onRightClick) {
Expand All @@ -105,7 +125,8 @@ function AssetNode(props) {
</NodeIcon>
{checkbox}
<NodeIcon $marginright={10}>
{node.type === Constants.AssetType.FILE && <FaFile />}
{node.type === Constants.AssetType.FILE && (!node.attributes || !node.attributes.entrypoint) && <FaFile />}
{node.type === Constants.AssetType.FILE && node.attributes && node.attributes.entrypoint && <FaFileImport />}
{node.type === Constants.AssetType.DIRECTORY && isOpen === true && <FaFolderOpen />}
{node.type === Constants.AssetType.DIRECTORY && !isOpen && <FaFolder />}
{node.type === Constants.AssetType.ASSET_GROUP && <FaPaperclip />}
Expand Down

0 comments on commit f1151c7

Please sign in to comment.