chore: better Prettier config for easier reviews
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
export const FileIcon: React.FC = () => {
|
||||
return (
|
||||
<svg
|
||||
className='fill-current text-black dark:text-white'
|
||||
width='21'
|
||||
height='26'
|
||||
viewBox='0 0 21 26'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
className="fill-current text-black dark:text-white"
|
||||
width="21"
|
||||
height="26"
|
||||
viewBox="0 0 21 26"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path d='M2.625 0C1.92881 0 1.26113 0.273928 0.768845 0.761522C0.276562 1.24912 0 1.91044 0 2.6V23.4C0 24.0896 0.276562 24.7509 0.768845 25.2385C1.26113 25.7261 1.92881 26 2.625 26H18.375C19.0712 26 19.7389 25.7261 20.2312 25.2385C20.7234 24.7509 21 24.0896 21 23.4V7.8L13.125 0H2.625ZM13.125 9.1H11.8125V2.6L18.375 9.1H13.125Z' />
|
||||
<path d="M2.625 0C1.92881 0 1.26113 0.273928 0.768845 0.761522C0.276562 1.24912 0 1.91044 0 2.6V23.4C0 24.0896 0.276562 24.7509 0.768845 25.2385C1.26113 25.7261 1.92881 26 2.625 26H18.375C19.0712 26 19.7389 25.7261 20.2312 25.2385C20.7234 24.7509 21 24.0896 21 23.4V7.8L13.125 0H2.625ZM13.125 9.1H11.8125V2.6L18.375 9.1H13.125Z" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import axios from 'axios'
|
||||
import prettyBytes from 'pretty-bytes'
|
||||
import { DownloadIcon } from '@heroicons/react/solid'
|
||||
import { useState, useEffect } from "react"
|
||||
import axios from "axios"
|
||||
import prettyBytes from "pretty-bytes"
|
||||
import { DownloadIcon } from "@heroicons/react/solid"
|
||||
|
||||
import type { MessageWithMember } from '../../../../../models/Message'
|
||||
import { Loader } from '../../../../design/Loader'
|
||||
import { FileIcon } from './FileIcon'
|
||||
import { api } from '../../../../../tools/api'
|
||||
import type { MessageWithMember } from "../../../../../models/Message"
|
||||
import { Loader } from "../../../../design/Loader"
|
||||
import { FileIcon } from "./FileIcon"
|
||||
import { api } from "../../../../../tools/api"
|
||||
|
||||
const supportedImageMimetype = [
|
||||
'image/png',
|
||||
'image/jpg',
|
||||
'image/jpeg',
|
||||
'image/gif'
|
||||
"image/png",
|
||||
"image/jpg",
|
||||
"image/jpeg",
|
||||
"image/gif",
|
||||
]
|
||||
|
||||
export interface FileData {
|
||||
@ -34,8 +34,8 @@ export const MessageFile: React.FC<MessageContentProps> = (props) => {
|
||||
|
||||
const fetchData = async (): Promise<void> => {
|
||||
const { data } = await api.get(message.value, {
|
||||
responseType: 'blob',
|
||||
cancelToken: ourRequest.token
|
||||
responseType: "blob",
|
||||
cancelToken: ourRequest.token,
|
||||
})
|
||||
const fileURL = URL.createObjectURL(data)
|
||||
setFile({ blob: data, url: fileURL })
|
||||
@ -52,27 +52,27 @@ export const MessageFile: React.FC<MessageContentProps> = (props) => {
|
||||
}
|
||||
if (supportedImageMimetype.includes(message.mimetype)) {
|
||||
return (
|
||||
<a href={file.url} target='_blank' rel='noreferrer'>
|
||||
<a href={file.url} target="_blank" rel="noreferrer">
|
||||
<img
|
||||
data-cy={`message-file-image-${message.id}`}
|
||||
className='max-h-80 sm:max-w-xs'
|
||||
className="max-h-80 sm:max-w-xs"
|
||||
src={file.url}
|
||||
alt={message.value}
|
||||
/>
|
||||
</a>
|
||||
)
|
||||
}
|
||||
if (message.mimetype.startsWith('audio/')) {
|
||||
if (message.mimetype.startsWith("audio/")) {
|
||||
return (
|
||||
<audio controls data-cy={`message-file-audio-${message.id}`}>
|
||||
<source src={file.url} type={message.mimetype} />
|
||||
</audio>
|
||||
)
|
||||
}
|
||||
if (message.mimetype.startsWith('video/')) {
|
||||
if (message.mimetype.startsWith("video/")) {
|
||||
return (
|
||||
<video
|
||||
className='max-h-80 max-w-xs'
|
||||
className="max-h-80 max-w-xs"
|
||||
controls
|
||||
data-cy={`message-file-video-${message.id}`}
|
||||
>
|
||||
@ -82,17 +82,17 @@ export const MessageFile: React.FC<MessageContentProps> = (props) => {
|
||||
}
|
||||
return (
|
||||
<a href={file.url} download data-cy={`message-file-download-${message.id}`}>
|
||||
<div className='flex items-center'>
|
||||
<div className='flex items-center'>
|
||||
<div className="flex items-center">
|
||||
<div className="flex items-center">
|
||||
<div>
|
||||
<FileIcon />
|
||||
</div>
|
||||
<div className='ml-4'>
|
||||
<div className="ml-4">
|
||||
<p>{file.blob.type}</p>
|
||||
<p className='mt-1'>{prettyBytes(file.blob.size)}</p>
|
||||
<p className="mt-1">{prettyBytes(file.blob.size)}</p>
|
||||
</div>
|
||||
</div>
|
||||
<DownloadIcon className='ml-4 h-8 w-8' />
|
||||
<DownloadIcon className="ml-4 h-8 w-8" />
|
||||
</div>
|
||||
</a>
|
||||
)
|
||||
|
@ -1 +1 @@
|
||||
export * from './MessageFile'
|
||||
export * from "./MessageFile"
|
||||
|
Reference in New Issue
Block a user