Skip to content

Commit

Permalink
コメント欄
Browse files Browse the repository at this point in the history
  • Loading branch information
mehm8128 committed Apr 26, 2024
1 parent 97d9d35 commit 18f898a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 92 deletions.
13 changes: 6 additions & 7 deletions src/components/requestDetail/NewComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ const { comment, isSending, submit } = useNewComment(request.value?.id ?? '')
</script>

<template>
<form class="mx-4 w-full">
<MarkdownTextarea v-model="comment" placeholder="コメント" />
<div class="mt-1">
<div class="w-full">
<MarkdownTextarea v-model="comment">
<SimpleButton
class="ml-auto"
:disabled="isSending"
font-size="md"
padding="sm"
@click.prevent="submit">
type="success"
@click="submit">
コメントする
</SimpleButton>
</div>
</form>
</MarkdownTextarea>
</div>
</template>
60 changes: 0 additions & 60 deletions src/components/requestDetail/RequestContent.vue

This file was deleted.

1 change: 1 addition & 0 deletions src/components/requestDetail/RequestLogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { RequestStatusDetail } from '/@/features/requestStatus/model'
import CommentLog from './CommentLog.vue'
import StatusChangeLog from './StatusChangeLog.vue'
import NewComment from './NewComment.vue'
type CommentWithType = RequestComment & { type: 'comment' }
type StatusWithType = RequestStatusDetail & { type: 'statusChange' }
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/InputTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ onMounted(() => {
<template>
<textarea
ref="textareaRef"
class="bg-background min-h-32 rounded border border-gray-300 px-1"
class="bg-background min-h-32 rounded border border-gray-300 px-3 py-2"
:placeholder="props.placeholder"
:required="required"
:value="props.modelValue"
Expand Down
57 changes: 33 additions & 24 deletions src/components/shared/MarkdownTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ const emit = defineEmits<{ (e: 'update:modelValue', value: string): void }>()
const currentTab = ref<TabType>('input')
const selectedTemplate = ref('')
const templateOptions = computed(() => {
return (
const templateOptions = computed(
() =>
props.templates?.map(template => {
return {
key: template.name,
value: template.name
}
}) ?? []
)
})
)
function setTemplate(template: string) {
const foundTemplate = props.templates?.find(t => t.name === template)
Expand All @@ -48,43 +47,53 @@ function changeCurrentTab(tab: TabType) {
</script>

<template>
<div>
<div class="flex gap-2">
<button
:class="`w-20 rounded-t py-1 ${
currentTab === 'input' ? 'bg-gray-400 text-white' : 'bg-gray-200'
}`"
@click.prevent="changeCurrentTab('input')">
入力
</button>
<button
:class="`w-20 rounded-t py-1 ${
currentTab === 'preview' ? 'bg-gray-400 text-white' : 'bg-gray-200'
}`"
@click.prevent="changeCurrentTab('preview')">
プレビュー
</button>
<div class="flex flex-col rounded border border-gray-300">
<div
class="flex items-center justify-between rounded-t bg-gray-200 px-4 pt-3">
<div class="flex items-center">
<button
:class="`rounded-t py-2 px-6 ${
currentTab === 'input'
? 'bg-white border-t border-x border-gray-300'
: 'bg-gray-200'
}`"
@click="changeCurrentTab('input')">
入力
</button>
<button
:class="`rounded-t py-2 px-6 ${
currentTab === 'preview'
? 'bg-white border-t border-x border-gray-300'
: 'bg-gray-200'
}`"
@click="changeCurrentTab('preview')">
プレビュー
</button>
</div>
<InputSelectSingle
v-if="props.templates !== undefined"
v-model="selectedTemplate"
class="m-1 ml-auto inline-block w-1/3"
class="inline-block"
:options="templateOptions"
placeholder="テンプレートを選択"
@option:selected="setTemplate(selectedTemplate)">
</InputSelectSingle>
</div>
<div>
<div class="px-5 py-3">
<InputTextarea
v-if="currentTab === 'input'"
:auto-focus="autoFocus"
class="min-h-40 w-full"
class="min-h-40 w-full bg-gray-200"
:model-value="modelValue"
:placeholder="placeholder"
@update:model-value="emit('update:modelValue', $event)" />
<MarkdownIt
v-if="currentTab === 'preview'"
class="min-h-40 w-full overflow-y-scroll border border-gray-500 px-1"
class="min-h-40 w-full overflow-y-scroll rounded bg-gray-200 border border-gray-300 px-3 py-2"
:text="modelValue" />
<div class="flex justify-end pt-3">
<slot />
</div>
</div>
</div>
</template>

0 comments on commit 18f898a

Please sign in to comment.