|
|
|
|
@ -19,7 +19,9 @@ export type AttachmentPropsBase = { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const Row: FC<BoxProps> = (props) => <Box mi='neg-x2' mbe='x2' rcx-message-attachment display='flex' alignItems='center' {...props}/>; |
|
|
|
|
|
|
|
|
|
const Title: FC<BoxProps> = (props) => <Box withTruncatedText mi='x2' fontScale='c1' color='hint' {...props}></Box>; |
|
|
|
|
const TitleLink: FC<{ link: string; title?: string }> = ({ link, title }) => <Title is='a' href={`${ link }?donwload`} color={undefined} target='_blank' download={title} rel='noopener noreferrer'>{title}</Title>; |
|
|
|
|
const Text: FC<BoxProps> = (props) => <Box mbe='x4' mi='x2' fontScale='p1' color='default' {...props}></Box>; |
|
|
|
|
|
|
|
|
|
const Size: FC<BoxProps & { size: number }> = ({ size, ...props }) => { |
|
|
|
|
@ -33,9 +35,9 @@ const Collapse: FC<ButtonProps & { collapsed?: boolean }> = ({ collapsed = false |
|
|
|
|
return <Action title={collapsed ? t('Uncollapse') : t('Collapse')}icon={ !collapsed ? 'chevron-down' : 'chevron-left' }{...props} />; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const Download: FC<ButtonProps & { href: string }> = ({ title, ...props }) => { |
|
|
|
|
const Download: FC<ButtonProps & { href: string }> = ({ title, href, ...props }) => { |
|
|
|
|
const t = useTranslation(); |
|
|
|
|
return <Action icon='download' title={t('Download')} is='a' target='_blank' download={title} {...props} />; |
|
|
|
|
return <Action icon='download' href={`${ href }?download`} title={t('Download')} is='a' target='_blank' rel='noopener noreferrer' download={title} {...props} />; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const Content: FC<BoxProps> = ({ ...props }) => <Box rcx-attachment__content width='full' mb='x4' {...props} />; |
|
|
|
|
@ -53,6 +55,7 @@ const Thumb: FC<{ url: string }> = memo(({ url }) => <Box mis='x8'><Avatar { ... |
|
|
|
|
export const Attachment: FC<BoxProps> & { |
|
|
|
|
Row: FC<BoxProps>; |
|
|
|
|
Title: FC<BoxProps>; |
|
|
|
|
TitleLink: FC<{ link: string; title?: string }>; |
|
|
|
|
Text: FC<BoxProps>; |
|
|
|
|
Size: FC<BoxProps & { size: number }>; |
|
|
|
|
Collapse: FC<ButtonProps & { collapsed?: boolean }>; |
|
|
|
|
@ -78,6 +81,7 @@ Attachment.Image = Image; |
|
|
|
|
Attachment.Row = Row; |
|
|
|
|
Attachment.Title = Title; |
|
|
|
|
Attachment.Text = Text; |
|
|
|
|
Attachment.TitleLink = TitleLink; |
|
|
|
|
Attachment.Size = Size; |
|
|
|
|
|
|
|
|
|
Attachment.Thumb = Thumb; |
|
|
|
|
|