-
Notifications
You must be signed in to change notification settings - Fork 311
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
[WV-659] & [WV-660] VoterPositionEntryAndDisplay && VoterPositionEditNameAndPhotoModal #4228
Open
itcreativeusa
wants to merge
2
commits into
wevote:develop
Choose a base branch
from
itcreativeusa:wv-659-open-modal-on-input-click
base: develop
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.
+820
−13
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Select, MenuItem, FormControl, Typography } from '@mui/material'; | ||
import { withStyles } from '@mui/styles'; | ||
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; | ||
import DesignTokenColors from '../../common/components/Style/DesignTokenColors'; | ||
|
||
const ActivityPostPublicDropdown = (props) => { | ||
const { visibilityIsPublic, onVisibilityChange, classes } = props; | ||
|
||
const handleVisibilityChange = (event) => { | ||
const { value } = event.target; | ||
onVisibilityChange(value === 'Public'); | ||
}; | ||
|
||
return ( | ||
<FormControl className={classes.formControl} aria-labelledby="opinion-visibility-label"> | ||
<div className={classes.container}> | ||
<Typography | ||
id="opinion-visibility-label" | ||
className={classes.label} | ||
component="label" | ||
> | ||
Opinion visible to: | ||
</Typography> | ||
<Select | ||
value={visibilityIsPublic ? 'Public' : 'Friends Only'} | ||
onChange={handleVisibilityChange} | ||
className={classes.selectVisibility} | ||
disableUnderline | ||
IconComponent={ArrowDropDownIcon} | ||
aria-label="Select visibility for your opinion" | ||
> | ||
<MenuItem value="Public" className={classes.menuItem}> | ||
Public | ||
</MenuItem> | ||
<MenuItem value="Friends Only" className={classes.menuItem}> | ||
My friends | ||
</MenuItem> | ||
</Select> | ||
</div> | ||
</FormControl> | ||
); | ||
}; | ||
|
||
ActivityPostPublicDropdown.propTypes = { | ||
visibilityIsPublic: PropTypes.bool.isRequired, | ||
onVisibilityChange: PropTypes.func.isRequired, | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
const styles = () => ({ | ||
formControl: { | ||
width: '100%', | ||
}, | ||
container: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
}, | ||
label: { | ||
fontFamily: 'Poppins', | ||
fontSize: '13px', | ||
fontWeight: '400', | ||
lineHeight: '19.5px', | ||
color: DesignTokenColors.neutralUI900, | ||
marginRight: '8px', | ||
}, | ||
selectVisibility: { | ||
fontFamily: 'Nunito', | ||
fontSize: '16px', | ||
fontWeight: '400', | ||
lineHeight: '21.82px', | ||
color: DesignTokenColors.neutralUI900, | ||
padding: '0 8px', | ||
border: 'none', | ||
boxShadow: 'none', | ||
outline: 'none', | ||
'&:focus': { | ||
outline: 'none', | ||
boxShadow: 'none', | ||
}, | ||
'& .MuiOutlinedInput-notchedOutline': { | ||
border: 'none', | ||
}, | ||
}, | ||
menuItem: { | ||
fontFamily: 'Nunito', | ||
fontSize: '16px', | ||
fontWeight: '400', | ||
lineHeight: '21.82px', | ||
color: DesignTokenColors.neutralUI900, | ||
}, | ||
}); | ||
|
||
export default withStyles(styles)(ActivityPostPublicDropdown); |
170 changes: 170 additions & 0 deletions
170
src/js/components/PositionItem/VoterPositionEditNameAndPhotoModal.jsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import React, { useState } from 'react'; | ||
import { Dialog, DialogTitle, DialogContent, Button, TextField, IconButton } from '@mui/material'; | ||
import { withStyles } from '@mui/styles'; | ||
import PropTypes from 'prop-types'; | ||
import { Close as CloseIcon } from '@mui/icons-material'; | ||
import DesignTokenColors from '../../common/components/Style/DesignTokenColors'; | ||
|
||
const styles = { | ||
modalContent: { | ||
padding: '20px', | ||
}, | ||
uploadSection: { | ||
alignItems: 'center', | ||
border: `3px dashed ${DesignTokenColors.neutral100}`, | ||
borderRadius: '8px', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
marginBottom: '20px', | ||
padding: '20px', | ||
}, | ||
profilePhoto: { | ||
alignItems: 'center', | ||
backgroundColor: DesignTokenColors.neutral50, | ||
borderRadius: '50%', | ||
display: 'flex', | ||
height: '80px', | ||
justifyContent: 'center', | ||
marginBottom: '10px', | ||
width: '80px', | ||
}, | ||
formField: { | ||
color: DesignTokenColors.neutral100, | ||
marginBottom: '15px', | ||
}, | ||
a: { | ||
color: DesignTokenColors.primary500, | ||
}, | ||
closeButton: { | ||
color: DesignTokenColors.neutral100, | ||
position: 'absolute', | ||
right: '8px', | ||
top: '8px', | ||
}, | ||
}; | ||
|
||
const VoterPositionEditNameAndPhotoModal = ({ show, toggleModal, classes }) => { | ||
const [firstName, setFirstName] = useState(''); | ||
const [lastName, setLastName] = useState(''); | ||
const [website, setWebsite] = useState(''); | ||
const [description, setDescription] = useState(''); | ||
const [photo, setPhoto] = useState(null); | ||
|
||
const handlePhotoUpload = (event) => { | ||
const file = event.target.files[0]; | ||
if (file && file.type.startsWith('image/')) { | ||
const reader = new FileReader(); | ||
reader.onload = (e) => setPhoto(e.target.result); | ||
reader.readAsDataURL(file); | ||
} else { | ||
alert('Please upload a valid image file.'); | ||
} | ||
}; | ||
|
||
const handleSave = () => { | ||
if (!firstName.trim() || !lastName.trim()) { | ||
alert('First and Last name are required.'); | ||
return; | ||
} | ||
if (website && !website.startsWith('http')) { | ||
alert('Please enter a valid URL starting with http or https.'); | ||
return; | ||
} | ||
// Add logic to save details | ||
toggleModal(); | ||
}; | ||
|
||
return ( | ||
<Dialog open={show} onClose={toggleModal} maxWidth="sm" fullWidth> | ||
<DialogTitle> | ||
Name & Photo Settings | ||
<IconButton | ||
aria-label="close" | ||
className={classes.closeButton} | ||
onClick={toggleModal} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</DialogTitle> | ||
<DialogContent className={classes.modalContent}> | ||
<p> | ||
We are serious about protecting your information. We are non-profit and never sell information. | ||
{' '} | ||
<a href="/frequently-asked-questions" target="_blank" rel="noopener noreferrer" className={classes.a}> | ||
Frequently Asked Questions. | ||
</a> | ||
</p> | ||
<div className={classes.uploadSection}> | ||
<div className={classes.profilePhoto}> | ||
{photo ? <img src={photo} alt="Profile" style={{ width: '100%', borderRadius: '50%' }} /> : 'Upload'} | ||
</div> | ||
<input | ||
type="file" | ||
accept="image/*" | ||
onChange={handlePhotoUpload} | ||
style={{ display: 'none' }} | ||
id="upload-photo" | ||
/> | ||
<label htmlFor="upload-photo"> | ||
<Button variant="outlined" component="span"> | ||
Upload Profile Photo | ||
</Button> | ||
</label> | ||
</div> | ||
<TextField | ||
label="First Name" | ||
value={firstName} | ||
onChange={(e) => setFirstName(e.target.value)} | ||
fullWidth | ||
variant="outlined" | ||
className={classes.formField} | ||
/> | ||
<TextField | ||
label="Last Name" | ||
value={lastName} | ||
onChange={(e) => setLastName(e.target.value)} | ||
fullWidth | ||
variant="outlined" | ||
className={classes.formField} | ||
/> | ||
<TextField | ||
label="Name Shown with Endorsements" | ||
value={`${firstName} ${lastName}`} | ||
fullWidth | ||
variant="outlined" | ||
className={classes.formField} | ||
disabled | ||
/> | ||
<TextField | ||
label="Your Website" | ||
value={website} | ||
onChange={(e) => setWebsite(e.target.value)} | ||
fullWidth | ||
variant="outlined" | ||
className={classes.formField} | ||
/> | ||
<TextField | ||
label="Description Shown with Endorsements" | ||
value={description} | ||
onChange={(e) => setDescription(e.target.value)} | ||
fullWidth | ||
variant="outlined" | ||
className={classes.formField} | ||
multiline | ||
rows={3} | ||
/> | ||
<Button variant="contained" color="primary" onClick={handleSave} fullWidth> | ||
Save | ||
</Button> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
VoterPositionEditNameAndPhotoModal.propTypes = { | ||
show: PropTypes.bool.isRequired, | ||
toggleModal: PropTypes.func.isRequired, | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(VoterPositionEditNameAndPhotoModal); |
Oops, something went wrong.
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.
Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.