Skip to content

Commit

Permalink
fix: check condition for icon display and styling
Browse files Browse the repository at this point in the history
  • Loading branch information
AmandaTamanda committed Dec 11, 2024
1 parent 2f6538f commit bc33a7e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
15 changes: 10 additions & 5 deletions src/components/ToolMenu/LayerTree/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@
.ant-tree-node-content-wrapper {
flex: 1;
overflow-x: auto;

.ant-tree-title {
.tree-node-header {
display: flex;

.layer-name{
.layer-name {
margin-right: 8px;
}

.layer-icon{
margin-left: 5px;
margin-right: 5px;
.layer-icons-group {
margin-left: 15px;

.layer-icon {
margin-right: 8px;
}
}

.loading-dots{
.loading-dots {
position: fixed;
margin-right: 5px;
}

.loading-indicator {
Expand Down
43 changes: 23 additions & 20 deletions src/components/ToolMenu/LayerTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const LayerTree: React.FC<LayerTreeProps> = ({
const initialLayersUid = map?.getAllLayers().map(l => getUid(l));

const showLegendsState: boolean = useAppSelector(state => state.layerTree.showLegends) ?? false;
const [visibleLegendsIds, setVisibleLegendsIds] = useState<string[]> (showLegendsState ? initialLayersUid ?? [] : []);
const [visibleLegendsIds, setVisibleLegendsIds] = useState<string[]>(showLegendsState ? initialLayersUid ?? [] : []);
const [layerTileLoadCounter, setLayerTileLoadCounter] = useState<LayerTileLoadCounter>({});
const layerIconsVisible: boolean = useAppSelector(state => state.layerTree.layerIconsVisible) ?? false;

Expand Down Expand Up @@ -210,7 +210,6 @@ export const LayerTree: React.FC<LayerTreeProps> = ({
const scale = resolution ? MapUtil.getScaleForResolution(resolution, unit) : undefined;
const percent = layer instanceof OlLayer && getUid(layer.getSource()) ?
layerTileLoadCounter[getUid(layer.getSource())]?.percent : 100;
const shouldDisplayIcon = layer.get('visible') && layerIconsVisible;

if (layer instanceof OlLayerGroup) {
return (
Expand All @@ -232,29 +231,33 @@ export const LayerTree: React.FC<LayerTreeProps> = ({
className='layer-name'
>
{layer.get('name')}
{layer.get('searchable') && shouldDisplayIcon && (
< FontAwesomeIcon
icon={faMagnifyingGlass}
className='layer-icon'
/>
)}
{layer.get('hoverable') && shouldDisplayIcon && (
< FontAwesomeIcon
icon={faCircleInfo}
className='layer-icon'
/>
)}
{layer.get('editable') && shouldDisplayIcon && (
< FontAwesomeIcon
icon={faPen}
className='layer-icon'
/>
)}
<span
className='loading-dots'
>
{percent < 100 && <LoadingIndicator />}
</span>
<span
className='layer-icons-group'
>
{layer.get('searchable') && layerIconsVisible && (
<FontAwesomeIcon
icon={faMagnifyingGlass}
className='layer-icon'
/>
)}
{layer.get('hoverable') && layer.get('visible') && layerIconsVisible && (
<FontAwesomeIcon
icon={faCircleInfo}
className='layer-icon'
/>
)}
{layer.get('editable') && layerIconsVisible && (
<FontAwesomeIcon
icon={faPen}
className='layer-icon'
/>
)}
</span>
</span>
{
(layer instanceof OlLayerTile || layer instanceof OlLayerImage) && (
Expand Down

0 comments on commit bc33a7e

Please sign in to comment.