-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚛️ feat: add TextInput and RadioInput basic component
- Loading branch information
1 parent
75456df
commit 79cd4ce
Showing
4 changed files
with
124 additions
and
1 deletion.
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,34 @@ | ||
.input { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.5rem; | ||
color: var(--grey-100); | ||
font-size: 1rem; | ||
direction: rtl; | ||
width: 100%; | ||
|
||
.radio-buttons { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 0.5rem; | ||
width: 100%; | ||
margin: 0.5rem 0; | ||
} | ||
|
||
input[type="text"], | ||
input[type="password"], | ||
input[type="email"], | ||
input[type="number"], | ||
input[type="tel"], | ||
input[type="date"], | ||
input[type="time"] { | ||
width: 100%; | ||
outline: none; | ||
border-radius: 4px; | ||
border: 1px solid var(--grey-600, #4b5563); | ||
background: var(--grey-700, #374151); | ||
padding: 0 4px; | ||
line-height: 1rem; | ||
color: var(--grey-100); | ||
} | ||
} |
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,67 @@ | ||
import "./../../assets/styles/components/Inputs.scss"; | ||
|
||
import PropTypes from "prop-types"; | ||
|
||
function TextInput({ | ||
label, | ||
type, | ||
name, | ||
value, | ||
onChange, | ||
placeholder, | ||
required, | ||
}) { | ||
return ( | ||
<label className="input input--text"> | ||
{label} | ||
<input | ||
type={type} | ||
name={name} | ||
placeholder={placeholder} | ||
value={value} | ||
onChange={onChange} | ||
required={required} | ||
/> | ||
</label> | ||
); | ||
} | ||
TextInput.propTypes = { | ||
label: PropTypes.string.isRequired, | ||
type: PropTypes.string, | ||
name: PropTypes.string, | ||
value: PropTypes.string, | ||
onChange: PropTypes.func, | ||
placeholder: PropTypes.string, | ||
required: PropTypes.bool, | ||
}; | ||
function RadioInput({ label, name, required, valuesArr, onChange }) { | ||
return ( | ||
<label className="input input--radio"> | ||
{label} | ||
<div className="radio-buttons"> | ||
{valuesArr.map((value) => ( | ||
<div key={value}> | ||
<input | ||
type="radio" | ||
name={name} | ||
value={value} | ||
onChange={onChange} | ||
required={required} | ||
/> | ||
<span>{value}</span> | ||
</div> | ||
))} | ||
</div> | ||
</label> | ||
); | ||
} | ||
RadioInput.propTypes = { | ||
label: PropTypes.string.isRequired, | ||
name: PropTypes.string, | ||
valuesArr: PropTypes.array, | ||
onChange: PropTypes.func, | ||
required: PropTypes.bool, | ||
}; | ||
|
||
export { RadioInput }; | ||
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
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