-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathExample3Page.js
More file actions
77 lines (72 loc) · 2.3 KB
/
Copy pathExample3Page.js
File metadata and controls
77 lines (72 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React, { useState } from 'react';
import styled from 'styled-components';
const Wrapper = styled.div`
height: 100vh;
background-color: #0E76A8;
display: flex;
align-items: center;
justify-content: center;
`;
const Box = styled.div`
height: 500px;
width: 500px;
text-align: center;
box-shadow: 5px 5px 10px #333;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: white;
border-radius: 16px;
`;
const Input = styled.input`
border-radius: 8px;
font-size: 16px;
padding: 8px;
border: 2px solid #0E76A8;
outline-width: 0;
text-align: center;
`;
export const Example3Page = () => {
const MAX_LENGTH = 15;
const [firstNameInputValue, setFirstNameInputValue] = useState('');
const [lastNameInputValue, setLastNameInputValue] = useState('');
return (
<Wrapper>
<Box>
<Input
type="text"
value={firstNameInputValue}
onChange={e => setFirstNameInputValue(e.target.value)}
maxLength={MAX_LENGTH}
className="input-large"
id="first-name-input"
data-cy="input-first-name"
/>
<p>
You have
<span data-cy="first-name-chars-left-count">
{MAX_LENGTH - firstNameInputValue.length}
</span>
characters left
</p>
<Input
type="text"
value={lastNameInputValue}
onChange={e => setLastNameInputValue(e.target.value)}
maxLength={MAX_LENGTH}
className="input-large"
id="last-name-input"
data-cy="input-last-name"
/>
<p>
You have
<span data-cy="last-name-chars-left-count">
{MAX_LENGTH - lastNameInputValue.length}
</span>
characters left
</p>
</Box>
</Wrapper>
);
}