How to add sliding animation MUI using CSS - css

I am facing an issue of adding the slide animation on the question and answer. I want on click of the radio button the slide effect comes and next question comes with Slideup animation.
<Grid item xs={12} sm={8} md={8}>
<Slide direction="up"
in={checked}
appear={true}
mountOnEnter
unmountOnExit
timeout={{ enter: 1000 , exit: checked ? 1 : 900}}
>
<Card variant="outlined" sx={{ bgcolor: "#bea"}} elevation={0}>
<CardContent>
<form onSubmit= {handleSubmit}>
<CardActions>
<Button type="submit" color="warning" variant="outlined" disabled={currentQuestion===0} className={classes.button} onClick={previousQuestion}>
Previous</Button>
</CardActions>
<FormControl component='fieldset' className={classes.formControl}
data-hidden={questions[currentQuestion].number !==
currentQuestion[questions[currentQuestion] .number]} >
<FormLabel component='legend'>
{questions[currentQuestion].question}
</FormLabel>
<FormLabel component='legend'>
{questions[currentQuestion].description}
</FormLabel>
<RadioGroup
aria-label='quiz'
name='quiz'
value={questions[currentQuestion].value}
checked={checked}
onChange={(e)=> handleRadioChange(questions[currentQuestion].number, e)}
sx={{
color: pink[800],
'&.Mui-checked': {
color: blue[600],
},
}}>
{options.map((option) => (
<FormControlLabel
key={option.score}
value={option.score}
control={<Radio sx={{
color: pink[800],
'&.Mui-checked': {
color: blue[600],
},
}}/>}
label={option.label}
/>
))}
</RadioGroup>
</FormControl>
<CardActions>
<Button type="submit" variant="contained" color="primary" className={classes.button} disabled={currentQuestion != 5} onClick={handleSubmit}>
Submit
</Button>
</CardActions>
</form>
</CardContent>
</Card>
</Slide>
This is not working smoothly. So please help. The problem is on click of previous button the value disappeared. The slide effect is not flawless.

Related

How to Resize Modal height and width in react-bootstrap?

I'm trying to use React Bootstrap Modal in my application but the dialog is too small, and I want to make it bigger. How can I achieve that ? I already finished the Code but i think the css doesn't work
Here's the code:
<Modal show={showModal} onHide={handleClose} className='modalSize'>
<Modal.Body >
<Row>
<Col lg={6}>
<img
className
src= {modalData.picture}
/>
</Col>
<Col lg={6}>
<h1>{modalData.name}</h1>
<h1>{modalData.position}</h1>
</Col>
</Row>
</Modal.Body>
</Modal>
CSS :
.modalSize{
width: 100% !important;
}
From the react-bootstrap docs: Size
You can add a parameter for the size of the modal just using size="lg" as below
function Example() {
const [smShow, setSmShow] = useState(false);
const [lgShow, setLgShow] = useState(false);
return (
<>
<Button onClick={() => setSmShow(true)} className="me-2">
Small modal
</Button>
<Button onClick={() => setLgShow(true)}>Large modal</Button>
<Modal
size="sm"
show={smShow}
onHide={() => setSmShow(false)}
aria-labelledby="example-modal-sizes-title-sm"
>
<Modal.Header closeButton>
<Modal.Title id="example-modal-sizes-title-sm">
Small Modal
</Modal.Title>
</Modal.Header>
<Modal.Body>...</Modal.Body>
</Modal>
<Modal
size="lg"
show={lgShow}
onHide={() => setLgShow(false)}
aria-labelledby="example-modal-sizes-title-lg"
>
<Modal.Header closeButton>
<Modal.Title id="example-modal-sizes-title-lg">
Large Modal
</Modal.Title>
</Modal.Header>
<Modal.Body>...</Modal.Body>
</Modal>
</>
);
}

Mui text field error exclamation mark not coming properly when error helper text is large

I am using material UI version 5.4 and I have a sign-in form and applied validations on it. Validation is appearing properly but my problem is when I placed a long texted error message the exclamation mark is coming below outlined text field of the MUI material.
Here is the screenshot:
And here is the code:
<Box
component="form"
role="form"
sx={{
"& .MuiFormHelperText-root": { color: "#d32f2f" },
"& .MuiInputLabel-formControl": { paddingTop: "5px" },
}}
>
<Box mb={2}>
<TextField
type="email"
label="Email"
variant="standard"
fullWidth
onChange={(e) => emailHandler(e)}
error={emailError}
helperText={emailError ? emailErrorMessage : ""}
/>
</Box>
<Box mb={2}>
<TextField
margin="dense"
type="password"
label="Password"
variant="standard"
fullWidth
onChange={(e) => passwordHandler(e)}
error={passwordError}
helperText={passwordError ? passwordErrorMessage : ""}
/>
</Box>
<Box>
<span style={{ color: "#d32f2f", fontSize: "12px" }}>{error}</span>
</Box>
<Typography variant="button" color="info" to="/forgot-password" component={Link}>
Forgot Password?
</Typography>
<Box mt={4} mb={1}>
<Button variant="gradient" color="newColor" fullWidth onClick={signInHandler}>
sign in
</Button>
</Box>
<Box mt={3} mb={1} textAlign="center">
<Typography variant="button" color="text">
Don&apos;t have an account?{" "}
<Typography
onClick={() => {
navigate("/sign-up", { replace: true });
}}
style={{ cursor: "pointer" }}
variant="button"
color="info"
fontWeight="medium"
textGradient
>
Sign Up
</Typography>
</Typography>
</Box>
</Box>
How can I solve this styling issue?

how to remove border-right/Left of material-ui Textfield?

how can i remove to "border-left" of the first textfield and 'border-right' of the last textfield
<ButtonGroup variant="outlined" aria-label="outlined button group">
<TextField label="text" color="secondary" focused />
<TextField label="text" color="secondary" focused />
<TextField label="text" color="secondary" focused />
</ButtonGroup>
Use InputProps to apply class to TextField.
<ButtonGroup variant="outlined" aria-label="outlined button group">
<TextField
label="text"
color="secondary"
focused
InputProps={{
classes: {
notchedOutline: "left"
}
}}
/>
<TextField label="text" color="secondary" focused />
<TextField
label="text"
color="secondary"
focused
InputProps={{
classes: {
notchedOutline: "right"
}
}}
/>
</ButtonGroup>
Create CSS file and then import in your component.
CSS:
.left {
border-left: none !important;
}
.right {
border-right: none !important;
}

Animation is not applied when hovering sidebar

I use chakra ui.
When I hover the sidebar, the sidebar extends to the right.
I am using transition, but the animation is not applied. It is a bit choppy.
I am using transition="all 0.3s" but no animation happens when hover is applied.
I don't know why.If anyone can help me understand, I would appreciate your help.
code
enter link description here
<Flex
background="blue.50"
flexDirection="column"
height="100vh"
justifyContent="space-between"
onMouseEnter={() => setState((prevState) => !prevState)}
onMouseLeave={() => setState((prevState) => !prevState)}
position="fixed"
width={state ? "204px" : "54px"}
zIndex={10}
>
<Box transition="all 0.3s">
<HStack p={3}>
<Flex alignItems="center">
<Image
display={state ? "none" : "inline-block"}
height="24px"
src={""}
transition="all 0.3s ease-in-out"
/>
<Image
display={state ? "inline-block" : "none"}
src={"chakra_logo.png"}
/>
</Flex>
<Text display={state ? "inline-block" : "none"} fontSize="xs">
logo
</Text>
</HStack>
<VStack mt={3} spacing={0}>
<Box _hover={{ backgroundColor: "gray.200" }} width="full">
<Link>
<a>
<HStack p={3}>
<BiSearchAlt />
<Text display={state ? "inline-block" : "none"} fontSize="sm">
search
</Text>
</HStack>
</a>
</Link>
</Box>
<Box _hover={{ backgroundColor: "gray.200" }} width="full">
<Link>
<a>
<HStack p={3}>
<AiOutlineSetting />
<Text display={state ? "inline-block" : "none"} fontSize="sm">
setting
</Text>
</HStack>
</a>
</Link>
</Box>
</VStack>
</Box>
<VStack mb={2} spacing={0}>
<Box mb={2} px={3} width="full">
<Divider borderColor="gray.300" />
</Box>
<Box _hover={{ backgroundColor: "gray.200" }} p={3} width="full">
<HStack>
<Image
alt="MyImage"
src={""}
width="24px"
/>
</HStack>
</Box>
</VStack>
</Flex>
You need to add CSS transition to main Flex also:
<Flex
background="blue.50"
flexDirection="column"
height="100vh"
justifyContent="space-between"
onMouseEnter={() => setState((prevState) => !prevState)}
onMouseLeave={() => setState((prevState) => !prevState)}
position="fixed"
width={state ? "204px" : "54px"}
zIndex={10}
transition={"all .2s ease"}
>...

How to align different react components?

I want to achieve the given style.
Currently, I have
<Box display="flex" flexDirection="row" alignItems="center" width={1}>
<Box flexGrow="1">
<Typography variant="h6">
{subscription.PlanName}
<Box
px={1}
py={0.5}
color={"primary.contrastText"}
className={classes.success}
display="flex"
alignItems="center"
justifyContent="space-between"
>
{subscription.Status}
</Box>
</Typography>
<Typography variant="caption" component="div">Purchased on: <b>{moment(subscription.StartDate).format("DD-MM-YYYY")}</b></Typography>
<Typography variant="caption" component="div">Expiring on: <b>{moment(subscription.EndDate).format("DD-MM-YYYY")}</b></Typography>
</Box>
<Box>
<Button
variant="outlined"
color="primary"
onClick={Actions.openBillingDrawer}>
UPDATE CREDITS
</Button>
</Box>
<Box>
<Button
variant="contained"
color="primary"
onClick={Actions.openBillingDrawer}>
UPGRADE PLAN
</Button>
</Box>
Also, the UPDATE CREDITS button is different from which I am currently using. Please provide the correct button for that too.
it is not exactly your goal, but its a good place to start. You've got the right separation of boxes, right size of the green box and a iconButton:
<Box
display="flex"
flexDirection="row"
alignItems="center"
width={1}
justifyContent="space-between"
>
<Box>
<Box display="flex" alignItems="flex-end" margin="5px 0">
<Typography variant="h4" style={{ lineHeight: "0.8" }}>
Basic Plan
</Typography>
<Box
color="primary.contrastText"
bgcolor="success.main"
fontSize="8px"
padding="2px 4px"
marginLeft="6px"
>
ACTIVE
</Box>
</Box>
<Typography variant="caption" component="div" color="textSecondary">
Purchased on: <b>01-01-2020</b>
</Typography>
<Typography variant="caption" component="div" color="textSecondary">
Expiring on: <b>02-02-2020</b>
</Typography>
</Box>
<Box>
<Button
variant="outlined"
color="primary"
endIcon={<ArrowDropDownIcon />}
>
UPDATE CREDITS
</Button>
<Button variant="contained" color="primary">
UPGRADE PLAN
</Button>
</Box>
</Box>

Resources