koreezgames / phaser3-particle-editor

A flexible editor for building phaser particles.
https://koreezgames.github.io/phaser3-particle-editor/
MIT License
169 stars 13 forks source link

Similar code fixings - CODEBEAT #22

Closed saqsun closed 5 years ago

saqsun commented 5 years ago

Expected Behavior

To have separate components for similar emitter configs.

Current Behavior

Duplicate code for too similar emitter configs.

Possible Solution

Instead of this code:

        <ExpansionPanel>
          <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
            <Typography>Acceleration</Typography>
          </ExpansionPanelSummary>
          <ExpansionPanelDetails>
            <Grid container spacing={40}>
              <Grid item xs={6}>
                <FormLabel component="legend">X</FormLabel>
                <CompositeProperty configName="accelerationX" />
              </Grid>
              <Grid item xs={6}>
                <FormLabel component="legend">Y</FormLabel>
                <CompositeProperty configName="accelerationY" />
              </Grid>
            </Grid>
          </ExpansionPanelDetails>
        </ExpansionPanel>
        <ExpansionPanel>
          <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
            <Typography>Max Velocity</Typography>
          </ExpansionPanelSummary>
          <ExpansionPanelDetails>
            <Grid container spacing={40}>
              <Grid item xs={6}>
                <FormLabel component="legend">X</FormLabel>
                <CompositeProperty configName="maxVelocityX" />
              </Grid>
              <Grid item xs={6}>
                <FormLabel component="legend">Y</FormLabel>
                <CompositeProperty configName="maxVelocityY" />
              </Grid>
            </Grid>
          </ExpansionPanelDetails>
        </ExpansionPanel>

have this:

        <ExpansionPanelXY
          composite
          typography="Acceleration"
          configNameX="accelerationX"
          configNameY="accelerationY"
        />
        <ExpansionPanelXY
          composite
          typography="Max Velocity"
          configNameX="maxVelocityX"
          configNameY="maxVelocityY"
        />

Context

To make code more clear and reusable.