-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(apply): refactor user input components
- Loading branch information
Showing
58 changed files
with
582 additions
and
473 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "es6", | ||
"target": "esnext" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules"] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ Button.propTypes = { | |
}; | ||
|
||
Button.defaultProps = { | ||
type: "button", | ||
cancel: false, | ||
}; | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions
55
frontend/src/components/@common/MessageTextInput/MessageTextInput.js
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,55 @@ | ||
import PropTypes from "prop-types"; | ||
import Description from "../Description/Description"; | ||
import TextInput from "../TextInput/TextInput"; | ||
import styles from "./MessageTextInput.module.css"; | ||
import Label from "../Label/Label"; | ||
|
||
const MessageTextInput = ({ | ||
label, | ||
description, | ||
initialValue, | ||
value, | ||
onChange, | ||
name, | ||
maxLength, | ||
required, | ||
errorMessage, | ||
...props | ||
}) => { | ||
return ( | ||
<> | ||
<div className={styles["text-field"]}> | ||
<Label required={required}>{label}</Label> | ||
{description && <Description>{description}</Description>} | ||
<TextInput | ||
required={required} | ||
value={value} | ||
name={name} | ||
maxLength={maxLength} | ||
onChange={onChange} | ||
{...props} | ||
/> | ||
</div> | ||
<p className={styles["rule-field"]}>{errorMessage}</p> | ||
</> | ||
); | ||
}; | ||
|
||
MessageTextInput.propTypes = { | ||
label: PropTypes.string, | ||
initialValue: PropTypes.string, | ||
name: PropTypes.string.isRequired, | ||
required: PropTypes.bool, | ||
description: PropTypes.node, | ||
maxLength: PropTypes.number, | ||
errorMessage: PropTypes.string, | ||
}; | ||
|
||
MessageTextInput.defaultProps = { | ||
label: "", | ||
initialValue: "", | ||
required: false, | ||
description: "", | ||
}; | ||
|
||
export default MessageTextInput; |
1 change: 1 addition & 0 deletions
1
...nents/form/TextField/TextField.module.css → ...sageTextInput/MessageTextInput.module.css
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.text-field { | ||
display: flex; | ||
flex-direction: column; | ||
margin: 0.625rem; | ||
} | ||
|
||
.length-limit { | ||
|
33 changes: 33 additions & 0 deletions
33
frontend/src/components/@common/MessageTextInput/MessageTextInput.stories.js
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,33 @@ | ||
import React from "react"; | ||
import MessageTextInput from "./MessageTextInput"; | ||
|
||
export default { | ||
title: "form/MessageTextInput", | ||
component: MessageTextInput, | ||
}; | ||
|
||
const Template = (args) => <MessageTextInput {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
label: "이름", | ||
}; | ||
|
||
export const Required = Template.bind({}); | ||
Required.args = { | ||
label: "이름", | ||
required: true, | ||
}; | ||
|
||
export const WithDescription = Template.bind({}); | ||
WithDescription.args = { | ||
label: "이름", | ||
description: "이름을 입력하세요.", | ||
}; | ||
|
||
export const MaxLength = Template.bind({}); | ||
MaxLength.args = { | ||
label: "이름", | ||
maxLength: 30, | ||
value: "썬", | ||
}; |
58 changes: 58 additions & 0 deletions
58
frontend/src/components/@common/MessageTextarea/MessageTextarea.js
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 PropTypes from "prop-types"; | ||
import Label from "../Label/Label"; | ||
import Description from "../Description/Description"; | ||
import Textarea from "../Textarea/Textarea"; | ||
import styles from "./MessageTextarea.module.css"; | ||
|
||
const MessageTextarea = ({ | ||
label, | ||
name, | ||
value, | ||
description, | ||
handleChange, | ||
maxLength, | ||
required, | ||
errorMessage, | ||
...props | ||
}) => { | ||
return ( | ||
<> | ||
<div className={styles["text-field"]}> | ||
<Label required={required}>{label}</Label> | ||
{description && <Description>{description}</Description>} | ||
{maxLength && maxLength > 0 && ( | ||
<div className={styles["length-limit"]}> | ||
{value?.length} / {maxLength} | ||
</div> | ||
)} | ||
<Textarea | ||
name={name} | ||
required={required} | ||
value={value} | ||
onChange={handleChange} | ||
maxLength={maxLength} | ||
{...props} | ||
/> | ||
</div> | ||
<p className={styles["rule-field"]}>{errorMessage}</p> | ||
</> | ||
); | ||
}; | ||
|
||
MessageTextarea.propTypes = { | ||
label: PropTypes.string, | ||
required: PropTypes.bool, | ||
description: PropTypes.node, | ||
maxLength: PropTypes.number, | ||
initialValue: PropTypes.string, | ||
name: PropTypes.string.isRequired, | ||
}; | ||
|
||
MessageTextarea.defaultProps = { | ||
label: "", | ||
initialValue: "", | ||
required: false, | ||
description: "", | ||
}; | ||
|
||
export default MessageTextarea; |
19 changes: 19 additions & 0 deletions
19
frontend/src/components/@common/MessageTextarea/MessageTextarea.module.css
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,19 @@ | ||
.text-field { | ||
display: flex; | ||
flex-direction: column; | ||
margin: 0.625rem; | ||
} | ||
|
||
.length-limit { | ||
align-self: flex-end; | ||
color: #999999; | ||
font-size: 13px; | ||
} | ||
|
||
.rule-field { | ||
margin-left: 8px; | ||
margin-bottom: 10px; | ||
height: 12px; | ||
font-size: 12px; | ||
color: #ff0000; | ||
} |
8 changes: 4 additions & 4 deletions
8
...nents/form/TextField/TextField.stories.js → ...essageTextarea/MessageTextarea.stories.js
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
File renamed without changes.
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
File renamed without changes.
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
17 changes: 17 additions & 0 deletions
17
frontend/src/components/@common/TextInput/TextInput.module.css
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,17 @@ | ||
.text-input { | ||
padding: 12px; | ||
border: 1px solid #ced6e0; | ||
border-radius: 3px; | ||
transition-duration: 0.5s; | ||
line-height: 30px; | ||
font-size: 16px; | ||
} | ||
|
||
.text-input:focus { | ||
border: 1px solid #1e90ff; | ||
} | ||
|
||
.text-input:read-only { | ||
cursor: default; | ||
background: #ccc; | ||
} |
File renamed without changes.
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,39 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import classNames from "classnames"; | ||
import styles from "./Textarea.module.css"; | ||
|
||
const Textarea = ({ | ||
className, | ||
readOnly, | ||
value, | ||
maxLength, | ||
onChange, | ||
...props | ||
}) => { | ||
return ( | ||
<textarea | ||
value={value} | ||
onChange={onChange} | ||
maxLength={maxLength} | ||
className={classNames(styles["text-input"], className)} | ||
readOnly={readOnly} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
Textarea.propTypes = { | ||
className: PropTypes.string, | ||
readOnly: PropTypes.bool, | ||
value: PropTypes.string, | ||
maxLength: PropTypes.number, | ||
}; | ||
|
||
Textarea.defaultProps = { | ||
className: "", | ||
readOnly: false, | ||
value: "", | ||
}; | ||
|
||
export default Textarea; |
17 changes: 17 additions & 0 deletions
17
frontend/src/components/@common/Textarea/Textarea.module.css
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,17 @@ | ||
@media screen and (min-width: 513px) { | ||
textarea { | ||
min-height: 200px !important; | ||
} | ||
} | ||
|
||
.text-input { | ||
padding: 12px; | ||
border: 1px solid #ced6e0; | ||
border-radius: 3px; | ||
transition-duration: 0.5s; | ||
line-height: 30px; | ||
font-size: 16px; | ||
min-width: 100%; | ||
max-width: 100%; | ||
min-height: 100px; | ||
} |
32 changes: 32 additions & 0 deletions
32
frontend/src/components/@common/Textarea/Textarea.stories.js
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,32 @@ | ||
import React, { useState } from "react"; | ||
import Textarea from "./Textarea"; | ||
|
||
export default { | ||
title: "form/Textarea", | ||
component: Textarea, | ||
}; | ||
|
||
const Template = (args) => { | ||
const [value, setValue] = useState(""); | ||
|
||
return ( | ||
<Textarea | ||
value={value} | ||
onChange={({ target }) => setValue(target.value)} | ||
{...args} | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
maxLength: 100, | ||
}; | ||
|
||
export const ReadOnly = Template.bind({}); | ||
|
||
ReadOnly.args = { | ||
maxLength: 100, | ||
readOnly: true, | ||
value: "읽기전용 입력창입니다.", | ||
}; |
Oops, something went wrong.