Commit 2d02169d authored by Verónica Silva's avatar Verónica Silva

ContactModal component and set dynamically ContactForm colors

parent 6cac9a62
...@@ -8,6 +8,8 @@ import ArrowForwardIosRoundedIcon from "@mui/icons-material/ArrowForwardIosRound ...@@ -8,6 +8,8 @@ import ArrowForwardIosRoundedIcon from "@mui/icons-material/ArrowForwardIosRound
import theme from "../assets/styles/myTheme" import theme from "../assets/styles/myTheme"
import ContactModal from "./ContactModal"
const myPalette = theme.palette const myPalette = theme.palette
const CustomButton = styled(Button)(({ theme }) => ({ const CustomButton = styled(Button)(({ theme }) => ({
...@@ -21,22 +23,31 @@ const CustomButton = styled(Button)(({ theme }) => ({ ...@@ -21,22 +23,31 @@ const CustomButton = styled(Button)(({ theme }) => ({
}, },
})) }))
ContactButton.propTypes = {
children: PropTypes.string.isRequired,
width: PropTypes.string,
}
function ContactButton({ children, width }) { function ContactButton({ children, width }) {
const [open, setOpen] = React.useState(false)
const handleOpen = () => setOpen(true)
const handleClose = (value) => setOpen(value)
return ( return (
<CustomButton <>
variant="contained" <CustomButton
type="submit" variant="contained"
sx={{ mt: 1, mb: 2, width: width }} type="submit"
endIcon={<ArrowForwardIosRoundedIcon />} sx={{ mt: 1, mb: 2, width: width }}
> endIcon={<ArrowForwardIosRoundedIcon />}
{ children } onClick={handleOpen}
</CustomButton> >
{ children }
</CustomButton >
<ContactModal handleModalClose={handleClose} open={open}/>
</>
) )
} }
ContactButton.propTypes = {
children: PropTypes.string.isRequired,
width: PropTypes.string,
}
export default ContactButton export default ContactButton
import React from "react" import React from "react"
import PropTypes from "prop-types"
import TextField from "@mui/material/TextField" import TextField from "@mui/material/TextField"
import Box from "@mui/material/Box" import Box from "@mui/material/Box"
import { withStyles } from "@material-ui/core" import { styled } from "@mui/material/styles"
import ContactButton from "./ContactButton" import ContactButton from "./ContactButton"
import theme from "../assets/styles/myTheme" const CustomTextField = styled(TextField)(({ theme, borderColor, textColor }) => ({
"& label.Mui-focused": {
const myPalette = theme.palette color: textColor,
},
const CustomTextField = withStyles({ "& .MuiInput-underline:after": {
root: { borderBottomColor: borderColor,
"& label.Mui-focused": { },
color: "white", "& .MuiOutlinedInput-root": {
"& fieldset": {
borderColor: borderColor,
}, },
"& .MuiInput-underline:after": { "&:hover fieldset": {
borderBottomColor: myPalette.primary.main, borderColor: borderColor,
}, },
"& .MuiOutlinedInput-root": { "&.Mui-focused fieldset": {
"& fieldset": { borderColor: borderColor,
borderColor: myPalette.primary.main,
},
"&:hover fieldset": {
borderColor: myPalette.primary.main,
},
"&.Mui-focused fieldset": {
borderColor: myPalette.primary.main,
},
}, },
}, },
})(TextField) }))
function FormFooter() { function FormFooter({borderColor, textColor}) {
const handleSubmit = (event) => { const handleSubmit = (event) => {
event.preventDefault() event.preventDefault()
const data = new FormData(event.currentTarget) const data = new FormData(event.currentTarget)
...@@ -45,7 +42,9 @@ function FormFooter() { ...@@ -45,7 +42,9 @@ function FormFooter() {
return ( return (
<Box component="form" onSubmit={handleSubmit} noValidate> <Box component="form" onSubmit={handleSubmit} noValidate>
<CustomTextField <CustomTextField
borderColor={borderColor}
textColor={textColor}
margin="normal" margin="normal"
required required
fullWidth fullWidth
...@@ -53,12 +52,10 @@ function FormFooter() { ...@@ -53,12 +52,10 @@ function FormFooter() {
label="Nombre" label="Nombre"
name="name" name="name"
autoComplete="name" autoComplete="name"
autoFocus
InputLabelProps={{
style: { color: myPalette.primary.contrastText},
}}
/> />
<CustomTextField <CustomTextField
borderColor={borderColor}
textColor={textColor}
margin="normal" margin="normal"
required required
fullWidth fullWidth
...@@ -67,11 +64,10 @@ function FormFooter() { ...@@ -67,11 +64,10 @@ function FormFooter() {
type="email" type="email"
id="email" id="email"
autoComplete="email" autoComplete="email"
InputLabelProps={{
style: { color: myPalette.primary.contrastText},
}}
/> />
<CustomTextField <CustomTextField
borderColor={borderColor}
textColor={textColor}
margin="normal" margin="normal"
required required
fullWidth fullWidth
...@@ -80,9 +76,6 @@ function FormFooter() { ...@@ -80,9 +76,6 @@ function FormFooter() {
type="number" type="number"
id="phone" id="phone"
autoComplete="phone" autoComplete="phone"
InputLabelProps={{
style: { color: myPalette.primary.contrastText},
}}
/> />
<ContactButton width="100%"> <ContactButton width="100%">
Contáctanos Contáctanos
...@@ -91,4 +84,9 @@ function FormFooter() { ...@@ -91,4 +84,9 @@ function FormFooter() {
) )
} }
FormFooter.propTypes = {
borderColor: PropTypes.string.isRequired,
textColor: PropTypes.string.isRequired,
}
export default FormFooter export default FormFooter
import * as React from "react"
import PropTypes from "prop-types"
import Backdrop from "@mui/material/Backdrop"
import Box from "@mui/material/Box"
import Modal from "@mui/material/Modal"
import Fade from "@mui/material/Fade"
import Typography from "@mui/material/Typography"
import theme from "../assets/styles/myTheme"
import ContactForm from "./ContactForm"
const myPalette = theme.palette
const style = {
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 400,
bgcolor: "background.paper",
boxShadow: 24,
borderRadius: "0px 20px 0px 0px",
p: 4,
"&:focus": {
outline: "none",
}
}
function ContactModal({ open, handleModalClose }) {
const handleClose = () => {
handleModalClose(false)
}
return (
<div>
<Modal
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
open={open}
onClose={handleClose}
closeAfterTransition
BackdropComponent={Backdrop}
BackdropProps={{
timeout: 500,
}}
>
<Fade in={open}>
<Box sx={style}>
<Typography id="transition-modal-title" variant="h6" component="h2">
Text in a modal
</Typography>
<ContactForm borderColor={myPalette.primary.main} textColor={myPalette.primary.main} />
</Box>
</Fade>
</Modal>
</div>
)
}
ContactModal.propTypes = {
open: PropTypes.bool.isRequired,
handleModalClose: PropTypes.func.isRequired,
}
export default ContactModal
...@@ -10,7 +10,7 @@ import List from "@mui/material/List" ...@@ -10,7 +10,7 @@ import List from "@mui/material/List"
import ListItem from "@mui/material/ListItem" import ListItem from "@mui/material/ListItem"
import ListItemText from "@mui/material/ListItemText" import ListItemText from "@mui/material/ListItemText"
import FormFooter from "./FormFooter" import ContactForm from "./ContactForm"
import { FooterContainer, NavLinkFooter } from "../assets/styles/styled" import { FooterContainer, NavLinkFooter } from "../assets/styles/styled"
import myTheme from "../assets/styles/myTheme" import myTheme from "../assets/styles/myTheme"
...@@ -50,7 +50,7 @@ function Footer() { ...@@ -50,7 +50,7 @@ function Footer() {
<Typography component="h5" className={classes.title}> <Typography component="h5" className={classes.title}>
Contáctanos Contáctanos
</Typography> </Typography>
<FormFooter /> <ContactForm borderColor={myPalette.primary.main} textColor={myPalette.primary.contrastText}/>
</Grid> </Grid>
<Grid item xs={12} sm={12} md={3}> <Grid item xs={12} sm={12} md={3}>
<Typography component="h5" className={classes.title}> <Typography component="h5" className={classes.title}>
......
...@@ -11,7 +11,7 @@ import ContactButton from "./ContactButton" ...@@ -11,7 +11,7 @@ import ContactButton from "./ContactButton"
const myPalette = myTheme.palette const myPalette = myTheme.palette
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles(() => ({
container: { container: {
height: "80vh", height: "80vh",
width: "100%", width: "100%",
......
...@@ -76,6 +76,6 @@ function Navbar(props) { ...@@ -76,6 +76,6 @@ function Navbar(props) {
</AppBar> </AppBar>
</HideOnScroll> </HideOnScroll>
) )
}; }
export default Navbar export default Navbar
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment