elk/components/publish/PublishWidget.vue

29 lines
686 B
Vue
Raw Normal View History

2022-11-16 21:27:02 +00:00
<script setup lang="ts">
2022-11-17 13:09:54 +00:00
const masto = await useMasto()
2022-11-16 21:27:02 +00:00
2022-11-17 13:09:54 +00:00
let draftPost = $ref('')
let isSending = $ref(false)
async function publish() {
try {
isSending = true
await masto.statuses.create({ status: draftPost })
draftPost = ''
}
finally {
isSending = false
}
}
2022-11-16 21:27:02 +00:00
</script>
<template>
2022-11-17 13:09:54 +00:00
<div flex flex-col gap-4 :class="isSending ? ' pointer-events-none' : ''">
<textarea v-model="draftPost" p2 border-rounded w-full h-40 color-black placeholder="What's on your mind?" />
2022-11-16 21:27:02 +00:00
<div flex justify-end>
2022-11-17 13:09:54 +00:00
<button h-9 w-22 bg-primary border-rounded :disabled="draftPost === ''" @click="publish">
2022-11-16 21:27:02 +00:00
Publish!
</button>
</div>
</div>
</template>