Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
GCL_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이승윤
2021-05-03 18:22:54 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
de126d5778ac6a68cf5fb15bd0ef1020bc2394f0
de126d57
1 parent
90ea8989
feat: Input quert state 설정
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
frontend/src/components/common/Input.js
frontend/src/components/common/Input.js
View file @
de126d5
import
React
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
styled
from
'styled-components'
;
import
{
useHistory
}
from
'react-router-dom'
;
import
{
inputColorMap
}
from
'../../lib/styles/palette'
;
const
InputBlock
=
styled
.
div
`
input {
padding:
20px
;
padding-right:
200px
;
padding:
${
props
=>
props
.
size
}
;
padding-right:
${
props
=>
props
.
width
}
;
color:
${
props
=>
inputColorMap
[
props
.
color
].
color
}
;
box-shadow: 2px 3px 28px 1px rgba(0, 0, 0, 0.1);
border: 3px solid
${
props
=>
inputColorMap
[
props
.
color
].
borderColor
}
;
...
...
@@ -20,10 +21,27 @@ const InputBlock = styled.div`
float:
${
props
=>
props
.
float
||
''
}
;
`
;
const
Input
=
({
children
,
color
,
size
,
float
})
=>
{
const
Input
=
({
color
,
size
,
float
,
width
})
=>
{
const
[
query
,
setQuery
]
=
useState
(
''
);
const
history
=
useHistory
();
return
(
<
InputBlock
color
=
{
color
}
size
=
{
size
}
float
=
{
float
}
>
<
input
placeholder
=
{
children
}
color
=
{
color
}
/
>
<
InputBlock
color
=
{
color
}
size
=
{
size
}
float
=
{
float
}
width
=
{
width
}
>
<
input
placeholder
=
"내용을 입력해 주세요."
type
=
"text"
value
=
{
query
}
onChange
=
{
e
=>
setQuery
(
e
.
target
.
value
)}
onKeyPress
=
{
e
=>
{
if
(
e
.
key
===
'Enter'
)
{
if
(
query
===
''
)
{
alert
(
'검색어를 입력 해 주세요.'
);
return
;
}
const
params
=
new
URLSearchParams
({
query
});
history
.
push
(
`?
${
params
.
toString
()}
`
);
}
}}
/
>
<
/InputBlock
>
);
};
...
...
Please
register
or
login
to post a comment