elk/components/publish/PublishWidget.vue

34 lines
744 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' : ''">
2022-11-20 21:21:53 +00:00
<textarea
v-model="draftPost"
placeholder="What's on your mind?"
p2 border-rounded w-full h-40
bg-gray:10 outline-none border="~ border"
/>
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>