-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49e78e3
commit 34d6d52
Showing
21 changed files
with
3,176 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<div | ||
:class="[ | ||
'flex', | ||
'justify-center', | ||
{ 'w-[138px]': props.size === 'large' }, | ||
{ 'w-[80px]': props.size === 'small' }, | ||
'mr-[16px]', | ||
'overflow-hidden', | ||
]" | ||
> | ||
<img | ||
v-if="computedFileType === 'image'" | ||
:class="['w-full', 'h-auto', 'object-contain', 'rounded-[8px]']" | ||
:src="props.fileData" | ||
> | ||
<UIcon | ||
v-else-if="computedFileType === 'epub'" | ||
name="i-heroicons-book-open" | ||
class="text-dark-gray w-[40px] h-[40px]" | ||
/> | ||
<UIcon | ||
v-else | ||
name="i-heroicons-document" | ||
class="text-dark-gray w-[40px] h-[40px]" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useFileUpload } from '~/composables/useFileUpload' | ||
type FileTypes = 'image' | 'pdf' | 'epub' | 'other' | ||
const { getFileType } = useFileUpload() | ||
const props = defineProps({ | ||
fileType: { | ||
type: String as PropType<FileTypes>, | ||
default: undefined | ||
}, | ||
fileData: { type: String, default: undefined }, | ||
size: { type: String, default: 'large' } | ||
}) | ||
const computedFileType = computed(() => { | ||
// If formatted fileType is provided as a prop, use it directly | ||
if (props.fileType) { return props.fileType } | ||
// Extract MIME type from data URL | ||
const dataUrl = props.fileData || '' | ||
const mimeType = dataUrl.split(';')[0].split(':')[1] || '' | ||
// Use getFileType function to determine the file type based on MIME type | ||
return getFileType(mimeType) | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.