Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,41 @@
}

.tableWrapper {
height: 35rem;
height: 30rem;
@include mixins.scrollbar-dark;
}
}

.submitButton {
margin-top: 1.25rem;
/* Responsive styles for smaller desktop windows */
@media screen and (max-width: 1400px) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use your mixin

.downloadModal {
width: 60rem;

.tableWrapper {
height: 30rem;
}
}
}

@media screen and (max-width: 1024px) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use your mixin

.downloadModal {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sorta stuff could also be done in baseModal maybe so itll affect this, the upload and the preset and every other modal down the line

width: 50rem;
padding: 0 1.5rem;

.tableWrapper {
height: 30rem;
}
}
}

@media screen and (max-width: 768px) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use your mixin

.downloadModal {
width: 90vw;
max-width: 35rem;
padding: 0 1rem;

.tableWrapper {
height: 20rem;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styles from './downloadModal.module.scss';
import baseModalStyles from '@components/ui/baseModal/BaseModal.module.scss';
import { BaseModal } from '@components/ui/baseModal/BaseModal';
import { FileTable } from '@components/ui/fileTable/FileTable';
import { Button } from '@components/ui/button/Button';
Expand Down Expand Up @@ -61,7 +62,7 @@ export const DownloadModal = ({ onClose, isOpen }: DownloadModalProps) => {
<Button
onClick={downloadFiles}
textSize={'2rem'}
className={styles.submitButton}
className={baseModalStyles.submitButton}
>
Download
<img src={rightArrowIcon} alt="right arrow"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,41 @@
display: flex;
flex-direction: column;
align-items: center;
padding: 0 1rem;
max-width: 90rem;
padding: 0 2rem;
max-width: 50rem;

.formWrapper {
display: flex;
gap: 2rem;

.uploadForm {
display: flex;
flex-direction: column;
align-items: center;
width: 50%;

.title {
all: unset;
@include fonts.title-large;
}
}
.title {
all: unset;
@include fonts.title-large;
margin-bottom: 1rem;
}

.selectFiles {
display: flex;
flex-direction: column;
align-items: center;
width: 50%;
.tableWrapper {
height: 28rem;
width: 100%;
@include mixins.scrollbar-dark;
}
}

.title {
all: unset;
@include fonts.title-large;
}
/* Responsive styles for smaller desktop windows */
@media screen and (max-width: 1024px) {
.presetFilesModal {
padding: 0 1.5rem;
max-width: 40rem;

.tableWrapper {
height: 35rem;
@include mixins.scrollbar-dark;
}
.tableWrapper {
height: 28rem;
}
}
}

.submitButton {
margin-top: 1.25rem;
}
@media screen and (max-width: 768px) {
.presetFilesModal {
padding: 0 1rem;
max-width: 100vw;

}
.tableWrapper {
height: 18rem;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styles from './PresetFilesModal.module.scss';
import baseModalStyles from '@components/ui/baseModal/BaseModal.module.scss';
import { BaseModal } from '@components/ui/baseModal/BaseModal';
import { FileTable } from '@components/ui/fileTable/FileTable';
import { UploadForm } from '@components/ui/uploadForm/UploadForm';
import { Button } from '@components/ui/button/Button';
import { useState, useEffect } from 'react';
import { rightArrowIcon } from '@assets/icons';
Expand All @@ -22,8 +22,7 @@ interface PresetFilesModalProps {
export const PresetFilesModal = ({ onClose, isOpen, onSubmit, currentSources }: PresetFilesModalProps) => {
// TODO: Adjust based on preset
const [selectedFiles, setSelectedFiles] = useState<FileInformation[]>([]);
const [uploadedFiles, setUploadedFiles] = useState<File[]>([]);
const { data: files, refetch } = useFiles();
const { data: files } = useFiles();

// Pre-select files based on currentSources prop
useEffect(() => {
Expand All @@ -37,53 +36,32 @@ export const PresetFilesModal = ({ onClose, isOpen, onSubmit, currentSources }:
}, [currentSources, files]);

const handleSubmit = async () => {
if (selectedFiles.length === 0 && uploadedFiles.length === 0) {
showWarningToast('Oops!', 'Please select or upload at least one file');
if (selectedFiles.length === 0) {
showWarningToast('Oops!', 'Please select at least one file');
return;
}

const uploadPromises = uploadedFiles.map((file) => ApiUtil.uploadFile(file));
await Promise.all(uploadPromises);

const fileKeys = selectedFiles.map((file) => file.key);

const uploadedFolderNames = uploadedFiles.map((file) => {
return file.name.substring(0, file.name.lastIndexOf('.'));
});

fileKeys.push(...uploadedFolderNames);

onSubmit(fileKeys);
onClose();
refetch(); // Refetch files after upload
};

return (
<BaseModal isOpen={isOpen} onClose={onClose}>
<div className={styles.presetFilesModal}>

<div className={styles.formWrapper}>
<div className={styles.uploadForm}>
<h2 className={styles.title}>Upload your files</h2>
<UploadForm files={uploadedFiles} setFiles={setUploadedFiles} accept={'.bin'}/>
</div>

<div className={styles.selectFiles}>
<h2 className={styles.title}>...Or select existing ones</h2>
<div className={styles.tableWrapper}>
<FileTable
files={getFolders(files || [])}
selectedFiles={selectedFiles}
setSelectedFiles={setSelectedFiles}
/>
</div>
</div>
<h2 className={styles.title}>Select a file</h2>
<div className={styles.tableWrapper}>
<FileTable
files={getFolders(files || [])}
selectedFiles={selectedFiles}
setSelectedFiles={setSelectedFiles}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like even on normal screen sizes these changes eliminate the upload functionality entirely from the preset files modal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, I thought we agreed that the upload functionality wasnt necessary when clicking on the preset files in general?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, only on mobile sizes. Neccesary on desktop

/>
</div>

<Button
onClick={handleSubmit}
textSize={'2rem'}
className={styles.submitButton}
className={baseModalStyles.submitButton}
>
<span>Submit</span>
<img src={rightArrowIcon} alt="right arrow"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@use '@styles/_fonts';

@use '@styles/_mixins';

.presetListWrapper {
display: flex;
flex-direction: column;
background-color: var(--background);
width: 100%;
padding-bottom: 4rem;
padding-right: 1rem;

.title {
all: unset;
Expand All @@ -18,10 +19,64 @@

.presetList {
display: grid;
grid-template-columns: repeat(3, auto);
grid-template-columns: repeat(4, auto);
gap: 1.5rem;
width: max-content;
margin: 0 auto;
}
}

/* Responsive styles for larger screens */
@include mixins.respond-to(ultrawide) {
.presetListWrapper {
.presetList {
grid-template-columns: repeat(3, auto);
gap: 1.5rem;
}
}
}

/* Responsive styles for smaller desktop windows */
@include mixins.respond-to(desktop) {
.presetListWrapper {
padding-right: 1rem;

.presetList {
grid-template-columns: repeat(2, auto);
gap: 1.5rem;
}
}
}

@include mixins.respond-to(tablet) {
.presetListWrapper {
padding-right: 0.75rem;

.title {
margin-left: 10%;
}

.presetList {
grid-template-columns: repeat(2, auto);
gap: 1.25rem;
}
}
}

@include mixins.respond-to(mobile) {
.presetListWrapper {
padding-left: 0.5rem;
padding-right: 0.5rem;

.title {
margin-left: 0.5rem;
}

.presetList {
grid-template-columns: 1fr;
width: fit-content;
margin: 0 auto;
gap: 1rem;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ export const PresetCard = ({ image, name, description, fileCount, onClick }: Pre
</div>
</button>
);
};

};
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
@use '@styles/_fonts';


.uploadModal {
display: flex;
flex-direction: column;
align-items: center;
width: 40rem;
height: 34rem;
padding: 0 2rem;

.title {
all: unset;
@include fonts.title-large;
}
}

@media screen and (max-width: 1024px) {
.uploadModal {
width: 35rem;
padding: 0 1.5rem;
}
}

.submitButton {
margin-top: 1.25rem;
@media screen and (max-width: 768px) {
.uploadModal {
width: 90vw;
max-width: 26rem;
padding: 0 1rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useFiles } from '@lib/files/useFiles';
import { showErrorToast, showSuccessToast } from '@components/ui/toastNotification/ToastNotification';
import { rightArrowIcon } from '@assets/icons';
import styles from './uploadModal.module.scss';
import baseModalStyles from '@components/ui/baseModal/BaseModal.module.scss';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this!

Styles are all co-located. If you have styles in baseModalStyles, they are meant to apply to parts in the baseModal. When I suggested doing styles in baseModal this was because you could just apply the styles to the root directly. You should never import a different style file


interface UploadModalProps {
isOpen: boolean;
Expand Down Expand Up @@ -80,7 +81,7 @@ export const UploadModal = ({ isOpen, onClose }: UploadModalProps) => {
<Button
onClick={submitFiles}
textSize={'2rem'}
className={styles.submitButton}
className={baseModalStyles.submitButton}
disabled={files.length === 0}
>
<span>Submit</span>
Expand Down
Loading