Created
April 14, 2022 06:16
-
-
Save eldonwilliams/85c8e31eb2bbf7a036a4222003c7af57 to your computer and use it in GitHub Desktop.
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
import { Divider, Paper, Stack, Typography } from "@mui/material"; | |
import { motion } from "framer-motion"; | |
import { useState } from "react"; | |
import StyledTextField from "./StyledTextField"; | |
const STFWrap = (props: Parameters<typeof StyledTextField>[0]) => { | |
const [focused, setFocused] = useState<boolean>(false); | |
const [inputValue, setInputValue] = useState<string>(""); | |
return ( | |
<motion.div | |
initial={{ 'maxWidth': '250px', 'width': '100%', }} | |
animate={{ 'maxWidth': focused ? '275px' : '250px', }} | |
> | |
<StyledTextField | |
{...props} | |
fullWidth | |
onFocus={() => setFocused(true)} | |
onBlur={() => setFocused(false)} | |
onChange={(event) => { | |
setInputValue(event.target.value) | |
if (props.onChange) props.onChange(event); | |
}} | |
inputProps={{ | |
style: { | |
paddingBottom: focused ? '16.5px' : '8px', | |
paddingTop: focused ? '16.5px' : '8px', | |
transition: 'all 0.2s 0s ease' | |
}, | |
}} | |
InputLabelProps={{ | |
style: { | |
transform: focused || inputValue !== "" ? '' : 'translate(14px, 8px) scale(1)', | |
}, | |
}} | |
/> | |
</motion.div> | |
); | |
} |
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
import { TextField, TextFieldProps } from "@mui/material"; | |
import React from "react"; | |
const StyledTextField: React.FC<TextFieldProps> = (props) => ( | |
<TextField | |
variant="outlined" | |
inputProps={{ style: { paddingTop: '8px', paddingBottom: '8px', } }} | |
{...props} | |
/> | |
); | |
export default StyledTextField; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment