Debian Codegraph @

node/@patternfly/react-core/src/components/LoginPage/LoginPage.tsx

raw
1 import { Fragment } from 'react';
2 import { css } from '@patternfly/react-styles';
3
4 import { BackgroundImage } from '../BackgroundImage';
5 import { Brand, BrandProps } from '../Brand';
6 import { List, ListVariant } from '../List';
7
8 import { Login } from './Login';
9 import { LoginHeader } from './LoginHeader';
10 import { LoginFooter } from './LoginFooter';
11 import { LoginMainHeader } from './LoginMainHeader';
12 import { LoginMainBody } from './LoginMainBody';
13 import { LoginMainFooter } from './LoginMainFooter';
14
15 export interface LoginPageProps extends React.HTMLProps<HTMLDivElement> {
16 /** Anything that can be rendered inside of the login page (e.g. <LoginPageForm>) */
17 children?: React.ReactNode;
18 /** Additional classes added to the login page */
19 className?: string;
20 /** Attribute that specifies the URL of the brand image for the login page */
21 brandImgSrc?: string;
22 /** Attribute that specifies the alt text of the brand image for the login page */
23 brandImgAlt?: string;
24 /** Additional props for the brand image for the login page */
25 brandImgProps?: BrandProps;
26 /** Attribute that specifies the URL of the background image for the login page */
27 backgroundImgSrc?: string;
28 /** Content rendered inside of the text component of the login page */
29 textContent?: string;
30 /** Items rendered inside of the footer list component of the login page */
31 footerListItems?: React.ReactNode;
32 /** Adds list variant styles for the footer list component of the login page. The only current value is'inline' */
33 footerListVariants?: ListVariant.inline;
34 /** Title for the login main body header of the login page */
35 loginTitle: string;
36 /** Subtitle for the login main body header of the login page */
37 loginSubtitle?: string;
38 /** Header utilities for the login main body header of the login page */
39 headerUtilities?: React.ReactNode;
40 /** Content rendered inside of login main footer band to display a sign up for account message */
41 signUpForAccountMessage?: React.ReactNode;
42 /** Content rendered inside of login main footer band to display a forgot credentials link. */
43 forgotCredentials?: React.ReactNode;
44 /** Content rendered inside of social media login footer section */
45 socialMediaLoginContent?: React.ReactNode;
46 /** Adds an accessible name to the social media login list. */
47 socialMediaLoginAriaLabel?: string;
48 }
49
50 export const LoginPage: React.FunctionComponent<LoginPageProps> = ({
51 children = null,
52 className = '',
53 brandImgSrc = '',
54 brandImgAlt = '',
55 brandImgProps,
56 backgroundImgSrc = '',
57 footerListItems = null,
58 textContent = '',
59 footerListVariants,
60 loginTitle,
61 loginSubtitle,
62 headerUtilities,
63 signUpForAccountMessage = null,
64 forgotCredentials = null,
65 socialMediaLoginContent = null,
66 socialMediaLoginAriaLabel,
67 ...props
68 }: LoginPageProps) => {
69 const HeaderBrand = (
70 <Fragment>
71 {(brandImgSrc || brandImgProps?.src) && <Brand src={brandImgSrc} alt={brandImgAlt} {...brandImgProps} />}
72 </Fragment>
73 );
74 const Header = <LoginHeader headerBrand={HeaderBrand} />;
75 const Footer = (
76 <LoginFooter>
77 <p>{textContent}</p>
78 <List variant={footerListVariants}>{footerListItems}</List>
79 </LoginFooter>
80 );
81
82 return (
83 <Fragment>
84 {backgroundImgSrc && <BackgroundImage src={backgroundImgSrc} />}
85 <Login header={Header} footer={Footer} className={css(className)} {...props}>
86 <LoginMainHeader title={loginTitle} subtitle={loginSubtitle} headerUtilities={headerUtilities} />
87 <LoginMainBody>{children}</LoginMainBody>
88 {(socialMediaLoginContent || forgotCredentials || signUpForAccountMessage) && (
89 <LoginMainFooter
90 socialMediaLoginContent={socialMediaLoginContent}
91 socialMediaLoginAriaLabel={socialMediaLoginAriaLabel}
92 forgotCredentials={forgotCredentials}
93 signUpForAccountMessage={signUpForAccountMessage}
94 />
95 )}
96 </Login>
97 </Fragment>
98 );
99 };
100 LoginPage.displayName = 'LoginPage';