diff --git a/src/editor/components/Main.js b/src/editor/components/Main.js index 7d83c8c94..d17c55804 100644 --- a/src/editor/components/Main.js +++ b/src/editor/components/Main.js @@ -278,7 +278,7 @@ export default class Main extends Component { )} - {this.state.isAddLayerPanelOpen && ( + {this.state.inspectorEnabled && this.state.isAddLayerPanelOpen && ( { - const [selectedOption, setSelectedOption] = useState(null); + // set the first Layers option when opening the panel + const [selectedOption, setSelectedOption] = useState(LayersOptions[0].value); const [groupedMixins, setGroupedMixins] = useState([]); useEffect(() => { @@ -60,62 +63,6 @@ const AddLayerPanel = ({ onClose, isAddLayerPanelOpen }) => { return groupedArray; }; - const options = [ - { - value: 'Layers: Streets & Intersections', - label: 'Layers: Streets & Intersections', - onClick: () => console.log('Layers: Streets & Intersections') - }, - { - value: 'Models: Personal Vehicles', - label: 'Models: Personal Vehicles', - mixinGroups: ['vehicles', 'vehicles-rigged'], - onClick: () => console.log('Models: Personal Vehicles') - }, - { - value: 'Models: Transit Vehicles', - label: 'Models: Transit Vehicles', - mixinGroups: ['vehicles-transit'], - onClick: () => console.log('Models: Transit Vehicles') - }, - { - value: 'Models: Utility Vehicles', - label: 'Models: Utility Vehicles', - mixinGroups: ['vehicles-rigged'], - onClick: () => console.log('Models: Utility Vehicles') - }, - { - value: 'Models: Characters', - label: 'Models: Characters', - mixinGroups: ['people', 'people-rigged'], - onClick: () => console.log('Models: Characters') - }, - { - value: 'Models: Street Props', - label: 'Models: Street Props', - mixinGroups: ['sidewalk-props', 'intersection-props'], - onClick: () => console.log('Models: Street Props') - }, - { - value: 'Models: dividers', - label: 'Models: dividers', - mixinGroups: ['dividers'], - onClick: () => console.log('Models: dividers') - }, - { - value: 'Models: Buildings', - label: 'Models: Buildings', - mixinGroups: ['buildings'], - onClick: () => console.log('Models: Buildings') - }, - { - value: 'Models: stencils', - label: 'Models: stencils', - mixinGroups: ['stencils'], - onClick: () => console.log('Models: stencils') - } - ]; - // data for layers cards const layersData = [ { @@ -177,7 +124,7 @@ const AddLayerPanel = ({ onClose, isAddLayerPanelOpen }) => { // get array with objects data (cardsData) from mixinGroups of selectedOption const getSelectedMixinCards = (selectedOption) => { if (!selectedOption) return []; - const selectedOptionData = options.find( + const selectedOptionData = LayersOptions.find( (option) => option.value === selectedOption ); const selectedMixinGroupNames = selectedOptionData.mixinGroups; @@ -344,7 +291,7 @@ const AddLayerPanel = ({ onClose, isAddLayerPanelOpen }) => { console.log('Layers: Streets & Intersections') + }, + { + value: 'Models: Personal Vehicles', + label: 'Models: Personal Vehicles', + mixinGroups: ['vehicles', 'vehicles-rigged'], + onClick: () => console.log('Models: Personal Vehicles') + }, + { + value: 'Models: Transit Vehicles', + label: 'Models: Transit Vehicles', + mixinGroups: ['vehicles-transit'], + onClick: () => console.log('Models: Transit Vehicles') + }, + { + value: 'Models: Utility Vehicles', + label: 'Models: Utility Vehicles', + mixinGroups: ['vehicles-rigged'], + onClick: () => console.log('Models: Utility Vehicles') + }, + { + value: 'Models: Characters', + label: 'Models: Characters', + mixinGroups: ['people', 'people-rigged'], + onClick: () => console.log('Models: Characters') + }, + { + value: 'Models: Street Props', + label: 'Models: Street Props', + mixinGroups: ['sidewalk-props', 'intersection-props'], + onClick: () => console.log('Models: Street Props') + }, + { + value: 'Models: dividers', + label: 'Models: dividers', + mixinGroups: ['dividers'], + onClick: () => console.log('Models: dividers') + }, + { + value: 'Models: Buildings', + label: 'Models: Buildings', + mixinGroups: ['buildings'], + onClick: () => console.log('Models: Buildings') + } +]; + +export { LayersOptions };