Extract error into component
This commit is contained in:
parent
020daf8a16
commit
8df09e1b21
3 changed files with 19 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, useTemplateRef } from "vue";
|
||||
import CSegmentError from "./CSegmentError.vue";
|
||||
|
||||
const form = useTemplateRef<HTMLFormElement>("form");
|
||||
const disabled = ref(false);
|
||||
|
|
@ -55,7 +56,7 @@ async function submit(): Promise<void> {
|
|||
</label>
|
||||
<label><input v-model="feed" type="checkbox" :disabled /> Feed</label>
|
||||
<button :disabled>Print</button>
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<CSegmentError :message="error" />
|
||||
</form>
|
||||
</template>
|
||||
|
||||
|
|
@ -76,10 +77,4 @@ fieldset {
|
|||
flex-direction: column;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.error {
|
||||
background-color: #fdd;
|
||||
color: #400;
|
||||
padding: 0 2px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
15
showbits-thermal-printer-ui/src/components/CSegmentError.vue
Normal file
15
showbits-thermal-printer-ui/src/components/CSegmentError.vue
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
const { message } = defineProps<{ message?: string }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p v-if="message">{{ message }}</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
p {
|
||||
background-color: #fdd;
|
||||
color: #400;
|
||||
padding: 0 2px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { computed, ref, type StyleValue, useTemplateRef } from "vue";
|
||||
import CSegmentError from "./CSegmentError.vue";
|
||||
|
||||
const form = useTemplateRef<HTMLFormElement>("form");
|
||||
const disabled = ref(false);
|
||||
|
|
@ -73,7 +74,7 @@ async function submit(): Promise<void> {
|
|||
<label><input v-model="feed" type="checkbox" :disabled /> Feed</label>
|
||||
</fieldset>
|
||||
<button :disabled>Print</button>
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<CSegmentError :message="error" />
|
||||
</form>
|
||||
</template>
|
||||
|
||||
|
|
@ -98,10 +99,4 @@ fieldset {
|
|||
flex-direction: column;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.error {
|
||||
background-color: #fdd;
|
||||
color: #400;
|
||||
padding: 0 2px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue