-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added textinput component and styled login and signup pages
- Loading branch information
1 parent
b32b6d2
commit 164e65b
Showing
7 changed files
with
138 additions
and
5,938 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
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
Empty file.
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
import React from 'react'; | ||
import { InputWrapper, StyledInput, StyledLabel } from './styles'; | ||
|
||
interface TextInputProps { | ||
label: string; | ||
id: string; | ||
type: string; | ||
value: string; | ||
placeholder: string; | ||
onChange: (s: string) => void; | ||
isVisible?: boolean; | ||
toggleVisibility?: () => void; | ||
} | ||
|
||
const TextInput: React.FC<TextInputProps> = ({ | ||
label, | ||
id, | ||
type, | ||
placeholder, | ||
onChange, | ||
isVisible, | ||
value, | ||
toggleVisibility, | ||
}) => { | ||
const inputType = type === 'password' && isVisible ? 'text' : type; | ||
|
||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
onChange(event.target.value); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<InputWrapper> | ||
{label && <StyledLabel htmlFor={id}>{label}</StyledLabel>} | ||
<StyledInput | ||
id={id} | ||
type={inputType} | ||
placeholder={placeholder} | ||
value={value} | ||
onChange={handleChange} | ||
/> | ||
</InputWrapper> | ||
{type === 'password' && toggleVisibility && ( | ||
<button | ||
type="button" | ||
onClick={toggleVisibility} | ||
style={{ | ||
marginBottom: '10px', | ||
}} | ||
> | ||
{isVisible ? 'Hide' : 'Show'} | ||
</button> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TextInput; |
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,27 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const InputWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
margin-bottom: 1rem; | ||
`; | ||
|
||
export const StyledLabel = styled.label` | ||
font-size: 1rem; | ||
font-weight: 500; | ||
margin-bottom: 0.5rem; | ||
color: darkgreen; | ||
`; | ||
|
||
export const StyledInput = styled.input` | ||
padding: 0.75rem; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
font-size: 1rem; | ||
transition: border-color 0.3s ease; | ||
&:focus { | ||
border-color: green; | ||
outline: none; | ||
} | ||
`; |
Oops, something went wrong.