Skip to content

Commit

Permalink
Refactor : Renaming simulationMagnitud file for more clearance
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRasho committed Nov 6, 2023
1 parent a4a73cc commit 45c5d8d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 53 deletions.
22 changes: 5 additions & 17 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,11 @@ const showOutputBar = computed(() => {
</main>
<side-bar :is-visible="showOutputBar">
<h1 class="font-title">Technical Info</h1>
<number-text
class="input"
label="Resistance"
unit="Ohms"
/>
<number-text class="input" label="Current" unit="A" disabled="true" />
<number-text class="input" label="Power" unit="W" disabled="true" />
<number-text
class="input"
label="Drag Speed"
unit="m/s"
/>
<number-text
class="input"
label="Drag Speed"
unit="min"
/>
<number-text class="input" label="Resistance" unit="Ohms" />
<number-text class="input" label="Current" unit="A" />
<number-text class="input" label="Power" unit="W" />
<number-text class="input" label="Drag Speed" unit="m/s" />
<number-text class="input" label="Drag Speed" unit="min" />

<button-push class="stop-btn" width="25ch" @click="tooggleSimulation">
Stop <i class="fa-solid fa-pause"></i>
Expand Down
2 changes: 1 addition & 1 deletion src/components/atoms/numberInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<script setup>
import { ref, defineEmits, onMounted } from 'vue'
import { SimulationMagnitude } from '../../lib/model'
import { SimulationMagnitude } from '../../lib/simulationMagnitud'
/** Value to display */
const displayValue = ref('')
Expand Down
36 changes: 1 addition & 35 deletions src/components/atoms/numberText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
</template>

<script setup>
import { ref, defineEmits, onMounted, computed } from 'vue'
import { SimulationMagnitude } from '../../lib/model'
import { defineEmits, computed } from 'vue'
const emit = defineEmits(['fieldUpdated'])
Expand Down Expand Up @@ -57,41 +56,8 @@ const props = defineProps({
required: false,
type: String,
default: '30ch'
},
/**
* Must be a Predicate (Function that recives a value and return a boolean) :
* Used for for double-cheking if input is correct
* if not, will return tu last value correct value.
*/
guardInput: {
required: false,
type: Function,
default: (_) => {
return false
}
}
})
/**
* Check if value is valid, if not return it to the last valid value
* stored in currentValue, otherwise emit the <fieldUpdate> event.
* @param {*} event input value after user exit writting
*/
function updateValue(event) {
let futureValue = event.target.value
if (Number.isNaN(parseFloat(futureValue)) || props.guardInput(futureValue)) {
console.log(`Not valid value for ${props.label}`)
displayValue.value = currentValue.value
} else {
console.log(`Valid value for ${props.label}`)
currentValue.value = parseFloat(futureValue)
emit(
'fieldUpdated',
new SimulationMagnitude(currentValue.value, props.label, props.unit)
)
}
}
</script>

<style scoped>
Expand Down
1 change: 1 addition & 0 deletions src/components/molecules/numberInputAdvanced.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

<script setup>
import { ref, defineEmits, onMounted } from 'vue'
import { SimulationMagnitude } from '../../lib/simulationMagnitud'
import dropDown from '../atoms/dropDown.vue'
import ToolTip from '../atoms/toolTip.vue'
Expand Down
File renamed without changes.

0 comments on commit 45c5d8d

Please sign in to comment.