Skip to content

Commit

Permalink
refactor(ui): give distinct class
Browse files Browse the repository at this point in the history
if `valueToDisplay === ""`
  • Loading branch information
lemredd committed Jan 4, 2023
1 parent 96112d3 commit 1ab03fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/CalculatorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function setEvaluationValue(newEvaluation: Evaluations) {
.entry-screen-container {
@apply flex justify-end;
@apply mt-8 mb-2;
@apply mb-2;
}
.entry-screen-container .screen {
Expand Down
11 changes: 11 additions & 0 deletions src/components/CalculatorContainer/ExpressionScreen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@ describe("Component: CalculatorContainer/ExpressionScreen", () => {
})
expect(calculatorScreen.text()).toEqual("1")
})

it("must have distinct class if `valueToDisplay` is empty", () => {
const wrapper = shallowMount(Component, {
"props": {
"valueToDisplay": ""
}
})

const calculatorScreen = wrapper.find(".expression-screen")
expect(calculatorScreen.classes()).toContain("empty")
})
})
16 changes: 13 additions & 3 deletions src/components/CalculatorContainer/ExpressionScreen.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
<script setup lang="ts">
import { computed } from "vue"
interface Props {
valueToDisplay: string
}
defineProps<Props>()
const props = defineProps<Props>()
const expressionScreenClasses = computed(() => ({
"empty": props.valueToDisplay === ""
}))
</script>

<template>
<span class="expression-screen">
<span class="expression-screen" :class="expressionScreenClasses">
{{ valueToDisplay }}
</span>
</template>

<style scoped lang="scss"></style>
<style scoped lang="scss">
.expression-screen.empty {
@apply h-8;
}
</style>

0 comments on commit 1ab03fb

Please sign in to comment.