<div class="map-legend" id="legend">
<div class="map-legend-head" id="legendHead">Legend</div>
<div class="map-legend-body">
<div class="map-legend-list">
<!-- this is one child -->
<li class="map-legend-list-item">
<span class="item-symbol"></span> <!-- item symbol is for colouring -->
<span class="item-name">The legend will scale itself</span>
</li>
<!-- legend child end -->
<li class="map-legend-list-item">
<span class="item-symbol"></span>
<span class="item-name">Never to be less than 170px in width, but never more than 300px</span>
</li>
<li class="map-legend-list-item">
<span class="item-symbol"></span>
<span class="item-name">We can set a fixed width, but if all items are short strings, will look odd</span>
</li>
<li class="map-legend-list-item">
<span class="item-symbol"></span>
<span class="item-name">osm</span>
</li>
</div>
</div>
</div>
<div class="drawing-area-poligon"></div>
<div id="actionButtons" class="action-buttons">
<button role="button" id="actionButtonsYes" class="action-buttons-yes">Apply selection</button>
<button role="button" id="actionButtonsNo" class="action-buttons-no">Clear selection</button>
</div>
<button class="share-region">
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="31.5" viewBox="0 0 36 31.5">
<path id="Icon_open-share-boxed" data-name="Icon open-share-boxed" d="M3.375,0A3.4,3.4,0,0,0,0,3.375v24.75A3.4,3.4,0,0,0,3.375,31.5h20.25A3.4,3.4,0,0,0,27,28.125V22.5H22.5V27H4.5V4.5h9V0ZM27,0V4.5A17.875,17.875,0,0,0,9.27,20.385,8.937,8.937,0,0,1,18,13.5h9V18l9-9Z" fill="#fff"/>
</svg>
</button>
<script>
let legend = document.getElementById('legend');
let legendHead = document.getElementById('legendHead');
legendHead.addEventListener('click', event => {
legend.classList.toggle('collapsed');
});
</script>