Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/core/src/attachment/attachment.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { ReactElement, ReactNode } from 'react'
import { Icon, If, Image, Progress, Spinner, SpinnerOverlay, View } from '../'
import { bytesToSize, classNames } from '../helpers'
import { bytesToSize, classNames, windowObject } from '../helpers'
import { Text } from '../text/text'
import { CoreViewProps } from '../types'
import { IconLib } from '../icon'

export const MIME = {
export const FOLD_ATTACHMENT_MIME_TYPES = 'FOLD_ATTACHMENT_MIME_TYPES'

windowObject[FOLD_ATTACHMENT_MIME_TYPES] = {
DESCRIPTION: {
'audio/aac': 'AAC audio',
'application/x-abiword': 'AbiWorddocument',
Expand Down Expand Up @@ -78,6 +80,7 @@ export const MIME = {
'audio/3gpp': '3GPPaudio/video container',
'audio/3gpp2': '3GPP2audio/video container',
'application/x-7z-compressed': '7-ziparchive',
'task': 'Task',
},
ICON: {
'audio/aac': 'audio',
Expand Down Expand Up @@ -151,6 +154,7 @@ export const MIME = {
'audio/3gpp': 'audio',
'audio/3gpp2': 'audio',
'application/x-7z-compressed': 'paperclip',
'task': 'check',
},
}

Expand All @@ -168,7 +172,7 @@ export type AttachmentProps = {
loading?: boolean
loadingProgress?: number
label?: string
} & CoreViewProps & { href?: string }
} & CoreViewProps & { href?: string, target?: string }

export const Attachment = (props: AttachmentProps) => {
const {
Expand All @@ -195,7 +199,8 @@ export const Attachment = (props: AttachmentProps) => {
},
[props.className, size]
)
const icon: string = mime ? MIME.ICON[mime] : error ? 'warning' : 'paperclip'

const icon: string = mime ? windowObject[FOLD_ATTACHMENT_MIME_TYPES].ICON[mime] : error ? 'warning' : 'paperclip'

return (
<View
Expand Down Expand Up @@ -265,7 +270,7 @@ export const Attachment = (props: AttachmentProps) => {
as="span"
className="f-attachment__text-meta">
<span>
{MIME.DESCRIPTION[mime]}
{windowObject[FOLD_ATTACHMENT_MIME_TYPES].DESCRIPTION[mime]}
</span>
</Text>
)}
Expand Down Expand Up @@ -310,7 +315,7 @@ export const AttachmentThumb = (props: AttachmentThumbProps) => {
},
[props.className]
)
const icon: string = mime ? MIME.ICON[mime] : error ? 'warning' : 'paperclip'
const icon: string = mime ? windowObject[FOLD_ATTACHMENT_MIME_TYPES].ICON[mime] : error ? 'warning' : 'paperclip'

return (
<View
Expand Down