Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/react-core/src/components/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Fragment } from 'react';
import { css } from '@patternfly/react-styles';

import { BackgroundImage } from '../BackgroundImage';
import { Brand } from '../Brand';
import { Brand, BrandProps } from '../Brand';
import { List, ListVariant } from '../List';

import { Login } from './Login';
Expand All @@ -21,6 +21,8 @@ export interface LoginPageProps extends React.HTMLProps<HTMLDivElement> {
brandImgSrc?: string;
/** Attribute that specifies the alt text of the brand image for the login page */
brandImgAlt?: string;
/** Additional props for the brand image for the login page */
brandImgProps?: BrandProps;
/** Attribute that specifies the URL of the background image for the login page */
backgroundImgSrc?: string;
/** Content rendered inside of the text component of the login page */
Expand Down Expand Up @@ -50,6 +52,7 @@ export const LoginPage: React.FunctionComponent<LoginPageProps> = ({
className = '',
brandImgSrc = '',
brandImgAlt = '',
brandImgProps,
backgroundImgSrc = '',
footerListItems = null,
textContent = '',
Expand All @@ -65,7 +68,7 @@ export const LoginPage: React.FunctionComponent<LoginPageProps> = ({
}: LoginPageProps) => {
const HeaderBrand = (
<Fragment>
<Brand src={brandImgSrc} alt={brandImgAlt} />
{(brandImgSrc || brandImgProps?.src) && <Brand src={brandImgSrc} alt={brandImgAlt} {...brandImgProps} />}
</Fragment>
);
const Header = <LoginHeader headerBrand={HeaderBrand} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@ test('check loginpage example against snapshot', () => {
);
expect(asFragment()).toMatchSnapshot();
});

test('brand is absent without brandImgSrc and brandImgProps.src', () => {
const { asFragment } = render(<LoginPage loginTitle="Log into your account" />);
expect(asFragment()).toMatchSnapshot();
});

test('brand is present with brandImgSrc prop', () => {
const { asFragment } = render(<LoginPage brandImgSrc="Brand src" loginTitle="Log into your account" />);
expect(asFragment()).toMatchSnapshot();
});

test('brandImgProps successfully renders brand with props', () => {
const { asFragment } = render(
<LoginPage brandImgProps={{ src: 'Brand src', alt: 'Pf-logo' }} loginTitle="Log into your account" />
);
expect(asFragment()).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,146 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`brand is absent without brandImgSrc and brandImgProps.src 1`] = `
<DocumentFragment>
<div
class="pf-v6-c-login"
>
<div
class="pf-v6-c-login__container"
>
<header
class="pf-v6-c-login__header"
/>
<main
class="pf-v6-c-login__main"
>
<div
class="pf-v6-c-login__main-header"
>
<h2
class="pf-v6-c-title pf-m-3xl"
data-ouia-component-id="OUIA-Generated-Title-2"
data-ouia-component-type="PF6/Title"
data-ouia-safe="true"
>
Log into your account
</h2>
</div>
<div
class="pf-v6-c-login__main-body"
/>
</main>
<footer
class="pf-v6-c-login__footer"
>
<p />
<ul
class="pf-v6-c-list"
/>
</footer>
</div>
</div>
</DocumentFragment>
`;

exports[`brand is present with brandImgSrc prop 1`] = `
<DocumentFragment>
<div
class="pf-v6-c-login"
>
<div
class="pf-v6-c-login__container"
>
<header
class="pf-v6-c-login__header"
>
<img
alt=""
class="pf-v6-c-brand"
src="Brand src"
/>
</header>
<main
class="pf-v6-c-login__main"
>
<div
class="pf-v6-c-login__main-header"
>
<h2
class="pf-v6-c-title pf-m-3xl"
data-ouia-component-id="OUIA-Generated-Title-3"
data-ouia-component-type="PF6/Title"
data-ouia-safe="true"
>
Log into your account
</h2>
</div>
<div
class="pf-v6-c-login__main-body"
/>
</main>
<footer
class="pf-v6-c-login__footer"
>
<p />
<ul
class="pf-v6-c-list"
/>
</footer>
</div>
</div>
</DocumentFragment>
`;

exports[`brandImgProps successfully renders brand with props 1`] = `
<DocumentFragment>
<div
class="pf-v6-c-login"
>
<div
class="pf-v6-c-login__container"
>
<header
class="pf-v6-c-login__header"
>
<img
alt="Pf-logo"
class="pf-v6-c-brand"
src="Brand src"
/>
</header>
<main
class="pf-v6-c-login__main"
>
<div
class="pf-v6-c-login__main-header"
>
<h2
class="pf-v6-c-title pf-m-3xl"
data-ouia-component-id="OUIA-Generated-Title-4"
data-ouia-component-type="PF6/Title"
data-ouia-safe="true"
>
Log into your account
</h2>
</div>
<div
class="pf-v6-c-login__main-body"
/>
</main>
<footer
class="pf-v6-c-login__footer"
>
<p />
<ul
class="pf-v6-c-list"
/>
</footer>
</div>
</div>
</DocumentFragment>
`;

exports[`check loginpage example against snapshot 1`] = `
<DocumentFragment>
<div
Expand Down
Loading