-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create custom component for default inputs for easier refactoring
- Loading branch information
1 parent
1ce302a
commit b5bc263
Showing
6 changed files
with
53 additions
and
17 deletions.
There are no files selected for viewing
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,41 @@ | ||
import React from "react"; | ||
|
||
interface DefaultInputProps { | ||
customStyle?: React.CSSProperties; | ||
width?: number | string; | ||
textAlign?: "left" | "center" | "right"; | ||
type?: string; | ||
value?: string | number; | ||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
placeholder?: string; | ||
} | ||
|
||
const DefaultInput: React.FC<DefaultInputProps> = ({ | ||
customStyle, | ||
width, | ||
textAlign = "left", | ||
type, | ||
value, | ||
onChange, | ||
placeholder, | ||
}) => { | ||
const baseStyle: React.CSSProperties = { | ||
textAlign, | ||
width: width || "100%", | ||
boxShadow: "var(--shadow)", | ||
...customStyle, | ||
}; | ||
|
||
return ( | ||
<input | ||
className="default-input" | ||
placeholder={placeholder} | ||
style={baseStyle} | ||
type={type} | ||
value={value} | ||
onChange={onChange} | ||
/> | ||
); | ||
}; | ||
|
||
export default DefaultInput; |
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
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
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