File tree 4 files changed +66
-2
lines changed
4 files changed +66
-2
lines changed Original file line number Diff line number Diff line change 1
1
import Button from "./components/Button" ;
2
+ import Input from "./components/Input" ;
2
3
3
4
function App ( ) {
4
5
return (
@@ -7,16 +8,26 @@ function App() {
7
8
// background: 'rgb(47 116 192)',
8
9
height : '100vh' ,
9
10
padding : '20px' ,
11
+ display : 'flex' ,
12
+ flexDirection : 'column' ,
13
+ width : '20%' ,
10
14
} }
11
15
>
12
16
< Button
13
17
raise
14
18
>
15
19
Click me please
16
- </ Button > < br /> < br />
20
+ </ Button >
21
+ < br />
17
22
< Button >
18
23
Hello
19
24
</ Button >
25
+ < br />
26
+ < Input
27
+ placeholder = "Input"
28
+ error = "This field is required."
29
+ />
30
+ < br />
20
31
</ div >
21
32
) ;
22
33
}
Original file line number Diff line number Diff line change @@ -43,14 +43,17 @@ function Button({
43
43
letter-spacing: 0.3px;
44
44
text-transform: ${ uppercase ? 'uppercase' : '' } ;
45
45
cursor: pointer;
46
+
46
47
&:focus{
47
48
outline: none;
48
49
}
50
+
49
51
&:active{
50
52
outline: none;
51
53
box-shadow: 0 3px 0 rgb(9 30 66 / 10 %);
52
54
top: 3px;
53
55
}
56
+
54
57
&:hover{
55
58
box-shadow: ${ boxShadow ? '0 3px 5px rgb(9 30 66 / 10%), 0 0 1px rgb(9 30 66 / 31%)' : '' } ;
56
59
transform: ${ raise ? 'translate3d(0px, -2px, 0px)' : 'none' } ;
@@ -65,4 +68,5 @@ function Button({
65
68
</ StyledButton >
66
69
)
67
70
}
71
+
68
72
export default Button ;
Original file line number Diff line number Diff line change
1
+ import { InputHTMLAttributes } from "react" ;
2
+ import styled from "styled-components" ;
3
+
4
+ interface Props extends InputHTMLAttributes < HTMLInputElement > {
5
+ error ?: string ,
6
+ }
7
+
8
+ function Input ( {
9
+ error,
10
+ ...props
11
+ } : Props ) {
12
+ const StyledInput = styled . input `
13
+ padding: 8px;
14
+ border: none;
15
+ background: #fff;
16
+ border: 1px solid ${ error ? 'red' : '#c8c8c8' } ;
17
+ letter-spacing: 0.3px;
18
+ line-height: 1;
19
+ &:focus{
20
+ outline: none;
21
+ }
22
+ &::placeholder{
23
+ color: #c8c8c8s;
24
+ }
25
+ `
26
+ const ErrorWrapper = styled . small `
27
+ margin: 5px 0;
28
+ color: red;
29
+ font-size: 13px;
30
+ `
31
+
32
+ return (
33
+ < >
34
+ < StyledInput
35
+ { ...props }
36
+ />
37
+ {
38
+ error
39
+ ?
40
+ < ErrorWrapper >
41
+ { error }
42
+ </ ErrorWrapper >
43
+ : ''
44
+ }
45
+ </ >
46
+ )
47
+ }
48
+
49
+ export default Input ;
Original file line number Diff line number Diff line change 1
- export const PRIMARY_COLOR :string = ' #ff5a5f' ;
1
+ export const PRIMARY_COLOR : string = " #ff5a5f" ;
You can’t perform that action at this time.
0 commit comments