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

Revert "Revert "Added feedback form and sitemap to the footer"" #327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REACT_APP_FORMSPREE_FORM_CODE = moqgpayj
REACT_APP_GITHUB_REPO_URL = https://github.com/shravan20/github-readme-quotes
REACT_APP_CONTACT_EMAIL = [email protected]
104 changes: 101 additions & 3 deletions frontend/package-lock.json

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

5 changes: 5 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@formspree/react": "^2.5.1",
"@material-ui/core": "^4.11.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.3.0",
"dotenv": "^16.4.5",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-icons": "^5.3.0",
Expand Down Expand Up @@ -37,5 +39,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"dotenv-webpack": "^8.1.0"
}
}
72 changes: 72 additions & 0 deletions frontend/src/components/Footer/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from "react";
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';
import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import Link from '@material-ui/core/Link';
import Paper from '@material-ui/core/Paper';
import { useForm } from '@formspree/react';
import ResponseSuccess from "./ResponseSuccess";


const GITHUB_REPO_URL = process.env.REACT_APP_GITHUB_REPO_URL || 'https://github.com/shravan20/github-readme-quotes';
const CONTACT_EMAIL = process.env.REACT_APP_CONTACT_EMAIL || '[email protected]';

const Footer = () => {
const [state, handleSubmitFormspree] = useForm(process.env.REACT_APP_FORMSPREE_FORM_CODE);
return (
<Grid container>
<Grid item xs={12} md={6}>
{state.succeeded && <ResponseSuccess />}
<Box id="feedback-form">
{!state.succeeded && <form onSubmit={handleSubmitFormspree}>
<Grid container>
<Grid item xs={12}>
<Typography variant="h5" gutterBottom color="primary">
<Box sx={{ fontWeight: 'bold' }} display='inline'>
Drop us a message:
</Box>
</Typography>
</Grid>
<Grid item xs={12} sm={6}>
<TextField id="name" label="Your Name" name="name" variant="outlined" required style={{ marginBottom: '10px' }} />
</Grid>
<Grid item xs={12} sm={6}>
<TextField id="email" label="E-mail Address" name="email" type="email" required variant="outlined" style={{ marginBottom: '10px' }} />
</Grid>
<Grid item xs={12}>
<TextField id="message" label="Message" variant="outlined" name="message" fullWidth multiline required style={{ marginBottom: '10px' }} />
</Grid>
<Grid item xs={12}>
<Button type="submit" disabled={state.submitting} variant="contained" color="primary" size="large" fullWidth>
SEND US A MESSAGE
</Button>
</Grid>
</Grid>
</form>}
</Box>
</Grid>
<Grid item xs={12} md={6}>
<Paper id="sitemap" style={{ marginLeft: '30px', height: '90%', padding: '20px' }} elevation={9}>
<Typography variant="h5" gutterBottom color="primary">
<Box sx={{ fontWeight: 'bold' }} display='inline'>
Sitemap
</Box>
</Typography>
<Link href={`${GITHUB_REPO_URL}`} display="block" style={{ marginBottom: '10px' }} color="textSecondary">
About Us
</Link>
<Link href={`mailto:${CONTACT_EMAIL}`} display="block" style={{ marginBottom: '10px' }} color="textSecondary">
Contact Us
</Link>
<Link href={`${GITHUB_REPO_URL}/blob/main/LICENSE`} display="block" style={{ marginBottom: '10px' }} color="textSecondary">
Terms and Conditions
</Link>
</Paper>
</Grid>
</Grid>
)
}

export default Footer;
26 changes: 26 additions & 0 deletions frontend/src/components/Footer/ResponseSuccess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import Paper from '@material-ui/core/Paper';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import PropTypes from 'prop-types';

const useStyles = makeStyles((theme) => ({
paper: {
height: '90%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#DBE2E9',
},
}));
Comment on lines +7 to +15
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance style consistency using theme spacing

While the styles are well-defined, consider using theme spacing for consistency with Material-UI's design system. This will make the component more adaptable to theme changes.

Consider applying this diff to use theme spacing:

 const useStyles = makeStyles((theme) => ({
   paper: {
-    height: '90%',
+    height: `calc(100% - ${theme.spacing(2)}px)`,
     display: 'flex',
     alignItems: 'center',
     justifyContent: 'center',
     backgroundColor: '#DBE2E9',
+    padding: theme.spacing(2),
   },
 }));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const useStyles = makeStyles((theme) => ({
paper: {
height: '90%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#DBE2E9',
},
}));
const useStyles = makeStyles((theme) => ({
paper: {
height: `calc(100% - ${theme.spacing(2)}px)`,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#DBE2E9',
padding: theme.spacing(2),
},
}));


function ResponseSuccess(){
const classes = useStyles();
return (<Paper className={classes.paper}>
<Typography variant="h6" color="primary" gutterBottom>Your response has been recorded successfully!</Typography>
</Paper>)
}
Comment on lines +17 to +22
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance component flexibility and accessibility

The component structure is good, but consider these improvements:

  1. Make the success message configurable via props for better reusability.
  2. Add an aria-label to the Paper component for better accessibility.

Apply this diff to implement these suggestions:

-function ResponseSuccess(){
+function ResponseSuccess({ message = "Your response has been recorded successfully!" }){
     const classes = useStyles();
-    return (<Paper className={classes.paper}>
-        <Typography variant="h6" color="primary" gutterBottom>Your response has been recorded successfully!</Typography>
+    return (<Paper className={classes.paper} aria-label="Success message">
+        <Typography variant="h6" color="primary" gutterBottom>{message}</Typography>
     </Paper>)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function ResponseSuccess(){
const classes = useStyles();
return (<Paper className={classes.paper}>
<Typography variant="h6" color="primary" gutterBottom>Your response has been recorded successfully!</Typography>
</Paper>)
}
function ResponseSuccess({ message = "Your response has been recorded successfully!" }){
const classes = useStyles();
return (<Paper className={classes.paper} aria-label="Success message">
<Typography variant="h6" color="primary" gutterBottom>{message}</Typography>
</Paper>)
}


ResponseSuccess.propTypes = {};

export default ResponseSuccess;
Comment on lines +24 to +26
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add PropTypes for message prop

Now that we've added a message prop to the component, it's important to define its PropTypes for better documentation and type checking.

Apply this diff to add PropTypes for the message prop:

+import PropTypes from 'prop-types';

 function ResponseSuccess({ message = "Your response has been recorded successfully!" }){
   // ... component code ...
 }

-ResponseSuccess.propTypes = {};
+ResponseSuccess.propTypes = {
+  message: PropTypes.string
+};

 export default ResponseSuccess;

Committable suggestion was skipped due to low confidence.

2 changes: 2 additions & 0 deletions frontend/src/components/Pages/Home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { themes, animations, layouts, fonts, colorValues, quoteTypes } from '../
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
import ContributorsCard from '../../ContributorsCard/ContributorCard'
import Footer from '../../Footer/Footer';
const Home = () => {

const [theme, setTheme] = useState(themes[0]);
Expand Down Expand Up @@ -146,6 +147,7 @@ const Home = () => {
}
</Grid>
<ContributorsCard />
<Footer/>
</React.Fragment>
)
}
Expand Down