-
Notifications
You must be signed in to change notification settings - Fork 381
Expand file tree
/
Copy pathLoginPageBasic.tsx
More file actions
131 lines (120 loc) · 4.81 KB
/
LoginPageBasic.tsx
File metadata and controls
131 lines (120 loc) · 4.81 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { Fragment, useState } from 'react';
import brandImg from '../../assets/PF-IconLogo.svg';
import {
LoginFooterItem,
LoginForm,
LoginMainFooterBandItem,
LoginMainFooterLinksItem,
LoginPage,
ListItem,
ListVariant,
Button
} from '@patternfly/react-core';
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
import GoogleIcon from '@patternfly/react-icons/dist/esm/icons/google-icon';
import GithubIcon from '@patternfly/react-icons/dist/esm/icons/github-icon';
import DropboxIcon from '@patternfly/react-icons/dist/esm/icons/dropbox-icon';
import FacebookSquareIcon from '@patternfly/react-icons/dist/esm/icons/facebook-square-icon';
import GitlabIcon from '@patternfly/react-icons/dist/esm/icons/gitlab-icon';
export const SimpleLoginPage: React.FunctionComponent = () => {
const [showHelperText, setShowHelperText] = useState(false);
const [username, setUsername] = useState('');
const [isValidUsername, setIsValidUsername] = useState(true);
const [password, setPassword] = useState('');
const [isValidPassword, setIsValidPassword] = useState(true);
const [isRememberMeChecked, setIsRememberMeChecked] = useState(false);
const handleUsernameChange = (_event: React.FormEvent<HTMLInputElement>, value: string) => {
setUsername(value);
};
const handlePasswordChange = (_event: React.FormEvent<HTMLInputElement>, value: string) => {
setPassword(value);
};
const onRememberMeClick = () => {
setIsRememberMeChecked(!isRememberMeChecked);
};
const onLoginButtonClick = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
event.preventDefault();
setIsValidUsername(!!username);
setIsValidPassword(!!password);
setShowHelperText(!username || !password);
};
const socialMediaLoginContent = (
<Fragment>
<LoginMainFooterLinksItem>
<Button variant="plain" aria-label="Login with Google" icon={<GoogleIcon />} />
</LoginMainFooterLinksItem>
<LoginMainFooterLinksItem>
<Button variant="plain" aria-label="Login with Github" icon={<GithubIcon />} />
</LoginMainFooterLinksItem>
<LoginMainFooterLinksItem>
<Button variant="plain" aria-label="Login with Dropbox" icon={<DropboxIcon />} />
</LoginMainFooterLinksItem>
<LoginMainFooterLinksItem>
<Button variant="plain" aria-label="Login with Facebook" icon={<FacebookSquareIcon />} />
</LoginMainFooterLinksItem>
<LoginMainFooterLinksItem>
<Button variant="plain" aria-label="Login with Gitlab" icon={<GitlabIcon />} />
</LoginMainFooterLinksItem>
</Fragment>
);
const signUpForAccountMessage = (
<LoginMainFooterBandItem>
Need an account? <a href="https://www.patternfly.org/">Sign up.</a>
</LoginMainFooterBandItem>
);
const forgotCredentials = (
<LoginMainFooterBandItem>
<a href="https://www.patternfly.org/">Forgot username or password?</a>
</LoginMainFooterBandItem>
);
const listItem = (
<Fragment>
<ListItem>
<LoginFooterItem href="https://www.patternfly.org/">Terms of Use </LoginFooterItem>
</ListItem>
<ListItem>
<LoginFooterItem href="https://www.patternfly.org/">Help</LoginFooterItem>
</ListItem>
<ListItem>
<LoginFooterItem href="https://www.patternfly.org/">Privacy Policy</LoginFooterItem>
</ListItem>
</Fragment>
);
const loginForm = (
<LoginForm
showHelperText={showHelperText}
helperText="Invalid login credentials."
helperTextIcon={<ExclamationCircleIcon />}
usernameLabel="Username"
usernameValue={username}
onChangeUsername={handleUsernameChange}
isValidUsername={isValidUsername}
passwordLabel="Password"
passwordValue={password}
onChangePassword={handlePasswordChange}
isValidPassword={isValidPassword}
rememberMeLabel="Keep me logged in for 30 days."
isRememberMeChecked={isRememberMeChecked}
onChangeRememberMe={onRememberMeClick}
onLoginButtonClick={onLoginButtonClick}
loginButtonLabel="Log in"
/>
);
return (
<LoginPage
footerListVariants={ListVariant.inline}
brandImgProps={{ src: brandImg, alt: 'PatternFly logo', className: 'pf-m-hover' }}
backgroundImgSrc="/assets/images/pf-background.svg"
footerListItems={listItem}
textContent="This is placeholder text only. Use this area to place any information or introductory message about your application that may be relevant to users."
loginTitle="Log in to your account"
loginSubtitle="Enter your single sign-on LDAP credentials."
socialMediaLoginContent={socialMediaLoginContent}
socialMediaLoginAriaLabel="Log in with social media"
signUpForAccountMessage={signUpForAccountMessage}
forgotCredentials={forgotCredentials}
>
{loginForm}
</LoginPage>
);
};