Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔎 Increase thumbnails size #2556

Merged
Merged
Show file tree
Hide file tree
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
27 changes: 25 additions & 2 deletions twake/frontend/src/app/components/file/file-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type PropsType = {
onRemove?: () => void;
className?: string;
large?: boolean;
xlarge?: boolean;
};

export default ({
Expand All @@ -43,6 +44,7 @@ export default ({
status,
onRemove,
large,
xlarge,
}: PropsType) => {
const { companyId, workspaceId } = RouterService.getStateFromRoute();
const [file, setFile] = useState<DataFileType>(_file);
Expand Down Expand Up @@ -109,13 +111,34 @@ export default ({
}
};

const computedWidth = file.thumbnail_ratio * 200;
let computedHeight = 200;
let computedWidth = file.thumbnail_ratio * 200;
const isMediaFile = ['image', 'video'].includes(file.type);

if (xlarge) {
computedWidth = Math.max(
160,
Math.min(
Math.min(messageFile.metadata?.thumbnails?.[0]?.width || 600, 600),
file.thumbnail_ratio * document.body.clientHeight * 0.5,
),
);
computedHeight = Math.max(
200,
Math.min(
Math.min(
messageFile.metadata?.thumbnails?.[0]?.height || 10000,
document.body.clientHeight * 0.5,
),
computedWidth / file.thumbnail_ratio,
),
);
}

return (
<div
className={classNames(classNameArguments)}
style={large ? { width: computedWidth } : {}}
style={large ? { width: computedWidth, height: computedHeight } : {}}
onClick={() => companyId && onClickFile()}
>
{large && <LargePreview file={file} />}
Expand Down
5 changes: 3 additions & 2 deletions twake/frontend/src/app/components/file/file.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
}

&.large-view {
height: 200px;
max-width: 400px;
min-height: 200px;
max-height: 500px;
max-width: 90%;
min-width: 160px;
position: relative;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ export default () => {
key={file.metadata?.external_id || file.id}
type={'message'}
file={file}
xlarge={files.length === 1 && (files[0].metadata?.thumbnails?.length || 0) > 0}
large={
//If all the documents are images
files.length <= 6 &&
files.filter(
file =>
file.metadata?.source === 'internal' &&
(file.metadata?.thumbnails?.length || 0) > 0
(file.metadata?.thumbnails?.length || 0) > 0,
).length === files.length
}
onRemove={() => setFiles(files.filter(f => f.id !== file.id))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ type PropsType = {
onRemove?: () => void;
type: 'input' | 'message';
large?: boolean;
xlarge?: boolean;
};

export default ({ file, onRemove, type, large }: PropsType) => {
export default ({ file, onRemove, type, large, xlarge }: PropsType) => {
const { getOnePendingFile } = useUpload();

const id =
Expand Down Expand Up @@ -68,6 +69,7 @@ export default ({ file, onRemove, type, large }: PropsType) => {
file={formatedFile}
messageFile={file}
large={large}
xlarge={xlarge}
status={status}
progress={progress}
onRemove={onRemove}
Expand Down