Skip to content

Commit

Permalink
Merge pull request #25 from jspsych/frontend
Browse files Browse the repository at this point in the history
Updates to frontend increasing usability
  • Loading branch information
vzhang03 authored Aug 12, 2024
2 parents 7c2bfe0 + 974243d commit 39c28ec
Show file tree
Hide file tree
Showing 19 changed files with 731 additions and 151 deletions.
6 changes: 6 additions & 0 deletions .changeset/poor-pumas-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"frontend": patch
"@jspsych/metadata": patch
---

Updating frontend to be more user-friendly with major edits to UI, updating metadata to support this with more specific get methods
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 102 additions & 2 deletions packages/frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ html, body {
overflow-y: auto; /* Adds vertical scroll if content exceeds max-height */
}

.popup-content form {
display: flex;
flex-direction: column;
gap: 16px; /* Adjust as needed */
align-items: center;
justify-content: center;
}

.popup-submit {
flex: 0 1 auto; /* Size based on content */
margin: auto; /* Centers the button horizontally */
}

.delete-button {
display: inline-flex; /* Makes the button only as wide as its content */
align-items: center; /* Centers the content vertically within the button */
Expand Down Expand Up @@ -158,17 +171,104 @@ html, body {
/* .promptFormSurvey label {
} */

.promptFormSurvey input {
.promptFormSurvey input, .authorInput {
margin-left: 10px;
padding: 5px;
border: 1px solid #ccc;
border-radius: 4px;
}

.promptFormSubmit {
width: fit-content;
}

.authorFormAddAuthors, .authorFormSubmit {
margin: 15px;
}

.authorLabel {
margin-left: 10px;
}

.pageDescription {
margin-bottom: 32px;
}
}


/* Preview page */

.preview-header {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}

.previewButton {
margin: 10px;
padding: 0px;
width: 22px;
height: 22px;
border-radius: 5px;
background: none;
}

/* Button Container */

.backSubmitButtonContainer {
display: flex;
flex-direction: row;
gap: 15px;
}

/* HoverPopup */
.hover-popup {
white-space: normal; /* Allows text to wrap */
word-wrap: break-word; /* Ensures long words or URLs wrap to the next line */
}

.hover-popup-title-container {
padding: 5px;
display: flex;
flex-direction: row;
}

.hover-popup-title-container button:first-of-type {
margin-right: 4px; /* Adjust the margin to make the gap smaller */
}

.hover-popup-title-container button:last-of-type {
margin-left: 4px; /* Optional: Adjust if needed for symmetry */
}

.delete-button-hover {
/* display: inline-flex; */
padding: 5px 5px;
align-items: center; /* Centers the content vertically within the button */
justify-content: center; /* Centers the content horizontally within the button */
}


.delete-button-hover img {
width: 20px; /* Larger image size */
height: 20px; /* Larger image size */
}

.expand-button {
padding-left: 12px;
padding-right: 12px;
}

.variable-item-hover-popup, .field-item-hover-popup, .author-item-hover-popup {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 1px solid #e0e0e0; /* Even lighter gray border */
border-radius: 10px; /* Optional: add rounded corners */
gap: 5px;
/* padding-left: 8px;
padding-right: 8px; */
margin-bottom: 10px;
}

6 changes: 4 additions & 2 deletions packages/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import './App.css'
function App() {
const [jsPsychMetadata] = useState(new JsPsychMetadata()); // metadata objct
const [ metadataString, setMetadataString ] = useState(JSON.stringify(jsPsychMetadata.getMetadata(), null, 2)); // this is the metadata string that willl keep track of metadata
const [ page, setPage ] = useState('upload'); // page logic
const [ page, setPage ] = useState('upload'); // page logic, change back to upload when done working with preview page
// const [ fileList, setFileList ] = useState<File[]>([]); -> this allows to download and save

// whenever updates will just call pretty version
Expand All @@ -21,8 +21,10 @@ function App() {
switch (page) {
case 'upload':
return <Upload jsPsychMetadata={jsPsychMetadata} setPage={setPage} updateMetadataString={updateMetadataString} />; // NEED TO PASS IN UPDATE METADATA SO THAT WILL UPDATE STRING WHEN LOADING
case 'upload-data':
return <Upload jsPsychMetadata={jsPsychMetadata} setPage={setPage} updateMetadataString={updateMetadataString} startScreen={"data"}/>; // NEED TO PASS IN UPDATE METADATA SO THAT WILL UPDATE STRING WHEN LOADING
case 'viewOptions':
return <ViewOptions jsPsychMetadata={jsPsychMetadata} metadataString={metadataString} updateMetadataString={updateMetadataString}/>; // NEED TO PASS SETPAGE ELEMENT
return <ViewOptions jsPsychMetadata={jsPsychMetadata} metadataString={metadataString} updateMetadataString={updateMetadataString} setPage={setPage}/>; // NEED TO PASS SETPAGE ELEMENT
default:
console.warn("uncaught page render:", page);
return <Upload jsPsychMetadata={jsPsychMetadata} setPage={setPage} updateMetadataString={updateMetadataString} />; // NEED TO PASS IN UPDATE METADATA SO THAT WILL UPDATE STRING WHEN LOADING
Expand Down
14 changes: 14 additions & 0 deletions packages/frontend/src/assets/downarrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/frontend/src/assets/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/frontend/src/assets/uparrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 39c28ec

Please sign in to comment.