-
Notifications
You must be signed in to change notification settings - Fork 7
#63 - Add Visual affordance for required photo upload on /setup page #67
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
Open
AndrewHUNGNguyen
wants to merge
1
commit into
DEVxNetwork:main
Choose a base branch
from
AndrewHUNGNguyen:#63-Add-Vis-Afford-Photo-Upload
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,11 @@ type NametagProps = { | |
| forcedEditMode?: boolean | ||
| onDataChange?: (data: NametagData) => void | ||
| readOnly?: boolean | ||
| validationErrors?: { | ||
| profilePhoto?: boolean | ||
| fullName?: boolean | ||
| } | ||
| showRequiredAsterisks?: boolean | ||
| } | ||
|
|
||
| export const Nametag = ({ | ||
|
|
@@ -34,7 +39,9 @@ export const Nametag = ({ | |
| initialEditing = false, | ||
| forcedEditMode = false, | ||
| onDataChange, | ||
| readOnly = false | ||
| readOnly = false, | ||
| validationErrors = {}, | ||
| showRequiredAsterisks = false | ||
| }: NametagProps) => { | ||
| const [isEditing, setIsEditing] = useState(initialEditing || forcedEditMode) | ||
| const [formData, setFormData] = useState<NametagData>(data) | ||
|
|
@@ -212,7 +219,10 @@ export const Nametag = ({ | |
| </SaveButtonWrapper> | ||
| )} | ||
| <NametagLeft> | ||
| <PhotoFrame onClick={readOnly ? undefined : () => fileInputRef.current?.click()}> | ||
| <PhotoFrame | ||
| onClick={readOnly ? undefined : () => fileInputRef.current?.click()} | ||
| $error={validationErrors.profilePhoto} | ||
| > | ||
| {uploading ? ( | ||
| <PlaceholderAvatar>Loading...</PlaceholderAvatar> | ||
| ) : formData.profilePhoto ? ( | ||
|
|
@@ -228,6 +238,12 @@ export const Nametag = ({ | |
| </PhotoOverlay> | ||
| )} | ||
| </PhotoFrame> | ||
| {showRequiredAsterisks && ( | ||
| <PhotoRequiredLabel> | ||
| Profile Photo <RequiredAsterisk>*</RequiredAsterisk> | ||
| </PhotoRequiredLabel> | ||
| )} | ||
| {validationErrors.profilePhoto && <FieldError>Please upload a profile photo</FieldError>} | ||
| {!readOnly && ( | ||
| <input | ||
| type="file" | ||
|
|
@@ -241,9 +257,16 @@ export const Nametag = ({ | |
|
|
||
| <NametagRight> | ||
| <NametagInputGroup> | ||
| <NametagLabel>HELLO my name is</NametagLabel> | ||
| <NametagLabel> | ||
| HELLO my name is | ||
| {showRequiredAsterisks && <RequiredAsterisk> *</RequiredAsterisk>} | ||
| </NametagLabel> | ||
| <InputWithHelpContainer> | ||
| <NametagInputWrapper $fontSize="1.5rem" $fontWeight="700"> | ||
| <NametagInputWrapper | ||
| $fontSize="1.5rem" | ||
| $fontWeight="700" | ||
| $error={validationErrors.fullName} | ||
| > | ||
| <TextInput | ||
| variant="secondary" | ||
| size="default" | ||
|
|
@@ -256,10 +279,11 @@ export const Nametag = ({ | |
| } | ||
| }} | ||
| placeholder="Your Name" | ||
| required | ||
| error={validationErrors.fullName} | ||
| /> | ||
| </NametagInputWrapper> | ||
| </InputWithHelpContainer> | ||
| {validationErrors.fullName && <FieldError>Please enter your name</FieldError>} | ||
| </NametagInputGroup> | ||
|
|
||
| <NametagInputGroup> | ||
|
|
@@ -277,7 +301,6 @@ export const Nametag = ({ | |
| } | ||
| }} | ||
| placeholder="Title" | ||
| required | ||
| /> | ||
| </NametagInputWrapper> | ||
| <HelpInfoButton>Your job title or role.</HelpInfoButton> | ||
|
|
@@ -299,7 +322,6 @@ export const Nametag = ({ | |
| } | ||
| }} | ||
| placeholder="Affiliation" | ||
| required | ||
| /> | ||
| </NametagInputWrapper> | ||
| <HelpInfoButton>Your company, organization, or school name.</HelpInfoButton> | ||
|
|
@@ -533,16 +555,17 @@ const PhotoOverlay = styled.div` | |
| pointer-events: none; | ||
| ` | ||
|
|
||
| const PhotoFrame = styled.div` | ||
| const PhotoFrame = styled.div<{ $error?: boolean }>` | ||
| width: 120px; | ||
| height: 120px; | ||
| border-radius: 8px; | ||
| overflow: hidden; | ||
| background-color: rgba(255, 255, 255, 0.1); | ||
| border: 2px solid rgba(255, 255, 255, 0.3); | ||
| border: 2px solid ${(props) => (props.$error ? "var(--error-color)" : "rgba(255, 255, 255, 0.3)")}; | ||
| box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); | ||
| cursor: pointer; | ||
| position: relative; | ||
| transition: border-color 0.2s ease; | ||
|
|
||
| &:hover ${PhotoOverlay} { | ||
| opacity: 1; | ||
|
|
@@ -600,27 +623,34 @@ const InputWithHelpContainer = styled.div` | |
| position: relative; | ||
| ` | ||
|
|
||
| const NametagInputWrapper = styled.div<{ $fontSize?: string; $fontWeight?: string }>` | ||
| const NametagInputWrapper = styled.div<{ | ||
| $fontSize?: string | ||
| $fontWeight?: string | ||
| $error?: boolean | ||
| }>` | ||
| flex: 1; | ||
| width: 100%; | ||
|
|
||
| input { | ||
| background: transparent; | ||
| border: none; | ||
| border-bottom: 2px solid rgba(255, 255, 255, 0.2); | ||
| border-bottom: 2px solid | ||
| ${(props) => (props.$error ? "var(--error-color)" : "rgba(255, 255, 255, 0.2)")}; | ||
| padding: 0.25rem 0; | ||
| font-size: ${(props) => props.$fontSize || "1rem"}; | ||
| font-weight: ${(props) => props.$fontWeight || "normal"}; | ||
| color: rgba(255, 255, 255, 0.95); | ||
| width: 100%; | ||
| transition: border-bottom-color 0.2s ease; | ||
|
|
||
| &::placeholder { | ||
| color: rgba(255, 255, 255, 0.5); | ||
| } | ||
|
|
||
| &:focus { | ||
| outline: none; | ||
| border-bottom-color: rgba(156, 163, 255, 0.8); | ||
| border-bottom-color: ${(props) => | ||
| props.$error ? "var(--error-color)" : "rgba(156, 163, 255, 0.8)"}; | ||
| background: rgba(255, 255, 255, 0.05); | ||
| } | ||
| } | ||
|
|
@@ -632,3 +662,23 @@ const NametagDisplayText = styled.div<{ $fontSize?: string; $fontWeight?: string | |
| color: rgba(255, 255, 255, 0.95); | ||
| padding: 0.25rem 0; | ||
| ` | ||
|
|
||
| const RequiredAsterisk = styled.span` | ||
| color: var(--error-color); | ||
| font-weight: 700; | ||
| ` | ||
|
|
||
| const PhotoRequiredLabel = styled.div` | ||
| color: rgba(255, 255, 255, 0.7); | ||
| font-size: 0.75rem; | ||
| font-weight: 500; | ||
| text-align: center; | ||
| margin-top: 0.5rem; | ||
| ` | ||
|
|
||
| const FieldError = styled.p` | ||
| color: var(--error-color); | ||
| font-size: 0.75rem; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. font-size here is not consistent with font-size in TextInput. |
||
| font-weight: 500; | ||
| margin-top: 0.5rem; | ||
| ` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define a
handlePhotoFrameClickhandler function and implement the logic there.