Betygsmodal är en komponent för att öppna en modal för att betygsätta med köttbullar.
Betygsmodalen använder komponenten CRating
.
<template>
<button type="button" class="button button--primary" @click="onClick">Öppna betygsmodal</button>
<c-rating-modal
:title="title"
:rating-text="ratingText"
:is-open="modalOpen"
@close="onClose"
@submit="onSubmit"
/>
<pre>{{ result }}</pre>
</template>
<script lang="ts">
import { defineComponent } from "vue";
import { type CRatingModalResult, CRatingModal } from "..";
export default defineComponent({
name: "CRatingModalExample",
components: { CRatingModal },
data() {
return {
modalOpen: false,
title: "Betygsätt betygsmodalen",
ratingText: "Hur många köttbullar ger du denna komponent?",
result: null as CRatingModalResult | null,
};
},
methods: {
onClick(): void {
this.modalOpen = !this.modalOpen;
},
onClose(): void {
this.modalOpen = false;
},
onSubmit(result: CRatingModalResult): void {
this.result = result;
},
},
});
</script>
PropsName | Description | Type | Required | Default |
---|
isOpen
| If the modal is open.
Use this to toggle if the modal should be visible or not.
| boolean
| false
| false
|
title
| Title of the modal.
| string
| false
| "Sätt ett betyg"
|
ratingText
| Description text for rating field.
| string
| false
| "Hur många köttbullar vill du ge?"
|
EventsName | Description | Properties |
---|
close
| Emitted when modal is closed by clicking a button or pressing escape.
| ‐
|
submit
| Emitted when modal has been submitted.
| <anonymous>: CRatingModalResult
|