|
| 1 | +import styled from 'styled-components'; |
1 | 2 | import { AttachmentType, getExtensionForDisplay } from '../../types/Attachment';
|
2 | 3 | import { StagedAttachmentsCloseButton } from './StagedAttachementsCloseButton';
|
| 4 | +import { LucideIcon } from '../icon/LucideIcon'; |
| 5 | +import { LUCIDE_ICONS_UNICODE } from '../icon/lucide'; |
3 | 6 |
|
4 | 7 | type Props = {
|
5 | 8 | attachment: AttachmentType;
|
6 | 9 | onClose: (attachment: AttachmentType) => void;
|
7 | 10 | };
|
8 | 11 |
|
| 12 | +const StyledIconExtension = styled.div` |
| 13 | + font-size: var(--font-size-sm); |
| 14 | + letter-spacing: 0.2px; |
| 15 | + text-transform: uppercase; |
| 16 | +
|
| 17 | + // Along with flow layout in parent item, centers text |
| 18 | + text-align: center; |
| 19 | + margin-inline-start: auto; |
| 20 | + margin-inline-end: auto; |
| 21 | +
|
| 22 | + // We don't have much room for text here, cut it off without ellipse |
| 23 | + overflow-x: hidden; |
| 24 | + white-space: nowrap; |
| 25 | + text-overflow: clip; |
| 26 | +
|
| 27 | + color: var(--text-primary-color); |
| 28 | +`; |
| 29 | + |
| 30 | +const StyledFilename = styled.div` |
| 31 | + text-align: center; |
| 32 | + font-size: var(--font-size-sm); |
| 33 | +
|
| 34 | + white-space: break-spaces; |
| 35 | + overflow: hidden; |
| 36 | + display: -webkit-box; |
| 37 | + -webkit-line-clamp: 2; |
| 38 | + -webkit-box-orient: vertical; |
| 39 | + text-overflow: ellipsis; |
| 40 | + margin-inline: var(--margins-xs); |
| 41 | +`; |
| 42 | + |
| 43 | +const StyledGenericAttachment = styled.div` |
| 44 | + height: 120px; |
| 45 | + width: 120px; |
| 46 | + margin: 1px; |
| 47 | + display: flex; |
| 48 | + flex-direction: column; |
| 49 | + justify-content: center; |
| 50 | + position: relative; |
| 51 | + border-radius: 4px; |
| 52 | + gap: var(--margins-sm); |
| 53 | + box-shadow: inset 0px 0px 0px 1px var(--border-color); |
| 54 | + background-color: var(--message-link-preview-background-color); |
| 55 | + text-align: center; |
| 56 | +`; |
| 57 | + |
9 | 58 | export function StagedGenericAttachment(props: Props) {
|
10 | 59 | const { attachment, onClose } = props;
|
11 | 60 | const { fileName, contentType } = attachment;
|
12 | 61 | const extension = getExtensionForDisplay({ contentType, fileName });
|
13 | 62 |
|
14 | 63 | return (
|
15 |
| - <div className="module-staged-generic-attachment"> |
| 64 | + <StyledGenericAttachment> |
16 | 65 | <StagedAttachmentsCloseButton
|
17 | 66 | onClick={() => {
|
18 | 67 | onClose?.(attachment);
|
19 | 68 | }}
|
20 | 69 | />
|
21 |
| - <div className="module-staged-generic-attachment__icon"> |
22 |
| - {extension ? ( |
23 |
| - <div className="module-staged-generic-attachment__icon__extension">{extension}</div> |
24 |
| - ) : null} |
25 |
| - </div> |
26 |
| - <div className="module-staged-generic-attachment__filename">{fileName}</div> |
27 |
| - </div> |
| 70 | + <LucideIcon |
| 71 | + iconSize="large" |
| 72 | + unicode={LUCIDE_ICONS_UNICODE.FILE} |
| 73 | + iconColor="var(--text-primary-color)" |
| 74 | + /> |
| 75 | + {extension ? <StyledIconExtension>{extension.slice(0, 4)}</StyledIconExtension> : null} |
| 76 | + |
| 77 | + <StyledFilename>{fileName}</StyledFilename> |
| 78 | + </StyledGenericAttachment> |
28 | 79 | );
|
29 | 80 | }
|
0 commit comments