Skip to content

feat(LoginPage): added headerUtilities prop for language selector example#7793

Merged
tlabaj merged 5 commits intopatternfly:mainfrom
andyyvo:iss7228
Aug 23, 2022
Merged

feat(LoginPage): added headerUtilities prop for language selector example#7793
tlabaj merged 5 commits intopatternfly:mainfrom
andyyvo:iss7228

Conversation

@andyyvo
Copy link
Copy Markdown
Contributor

@andyyvo andyyvo commented Aug 4, 2022

What: Closes #7228 .

How: Added a headerUtilities prop in LoginMainHeader.tsx using the styling properties discussed by @mcoker and @mcarrano. Updated LoginPage.tsx with a loginHeaderUtils prop. Created an example (LoginPageLanguageSelect.tsx) to demonstrate the new Select component. This example does not change the language of the login page at the moment.

Additional issues: N/A.

@patternfly-build
Copy link
Copy Markdown
Collaborator

patternfly-build commented Aug 4, 2022

Copy link
Copy Markdown
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good @andyyvo . But just one request. For a language selector, it's standard practice to show language names in their native language and character set, i.e., Espanol rather than Spanish, and Asian languages in their native font. It there an easy way to do this? I believe we had a code example in PatternFly 3 that implemented this menu.

Copy link
Copy Markdown
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome!! Just a few nits/questions - the only thing I think really needs updating is the initially selected language ("English" in the demo) being the selected item in the menu, too. Linked to another demo that shows how that might be wired up.

title?: string;
/** Subtitle that contains the Text, URL, and URL Text for the Login Main Header */
subtitle?: string;
/** Select menu that renders next to the Login Title for the Login Main Header */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - FWIW this could contain anything (likely actions of some sort), and it isn't always by the title, it's below the subtitle on small screens. I wonder if we could just describe this as a place for actions, such as a language selector, or something like that?

@@ -12,13 +12,16 @@ export interface LoginMainHeaderProps extends React.HTMLProps<HTMLDivElement> {
title?: string;
/** Subtitle that contains the Text, URL, and URL Text for the Login Main Header */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of scope but what does URL and URL Text refer to? This is a generic "description" element in core, and rendered as a <p>. Seems like it might be worth updating this prop to description (like the modal component) since subtitle implies it might be a heading element or something - it would be invalid invalid to pass a heading there currently since you can't put a heading in a <p>. On that, we might also consider just making this a <div> in both core and react. If that seems valid, I can open an issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. I could definitely see the user placing a hyperlink URL here. If you do open up that issue, feel free to tag me so I can make a react issue to update the prop name and usage

loginTitle: string;
/** Subtitle for the Login Main Body Header of the LoginPage */
loginSubtitle?: string;
/** Header utilities for the Login Main Body Header of the LoginPage */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - we might consider updating these descriptions to use sentence case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I update this for all of the descriptions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - even our component names are lower cased when used in a sentence

const [selectedHeaderUtils, setSelectedHeaderUtils] = React.useState<string | SelectOption>();

const headerUtilsOptions = [
<SelectOption key={0} value="English" />,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be selected in the menu, too? FWIW I found this filterable table demo that has "status" as initially selected, and if you open the menu, it's selected in the menu, too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it!

Copy link
Copy Markdown
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good so far! In addition to what has been commented already, I had some suggested changes/comments below.

Comment thread packages/react-core/src/components/LoginPage/LoginPage.tsx Outdated
Comment thread packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx Outdated
Comment thread packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx Outdated
Comment thread packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx Outdated
Comment thread packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx Outdated
Comment thread packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx Outdated
@andyyvo
Copy link
Copy Markdown
Contributor Author

andyyvo commented Aug 16, 2022

per @thatblindgeye also removed backgroundImgAlt on the other examples

Copy link
Copy Markdown
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcoker @mcarrano since the header utilities is technically a container for any action, I wonder if we want to specifically name the example "With language selector". A more generic name may be appropriate. Maybe we could add a description above the example to mention the header utilities should be used to add a language selector .

@mcoker
Copy link
Copy Markdown
Contributor

mcoker commented Aug 17, 2022

@tlabaj sounds good to me. The language selector could also be a demo. Seems like the show/hide password is maybe a demo, too?

@thatblindgeye
Copy link
Copy Markdown
Contributor

After a convo with Andy yesterday and looking into things a bit, the backgroundImgAlt prop on the LoginPage component isn't doing what it's intended to do, though it also seems unnecessary since the BackgroundImage component seems like it's meant strictly as decorative content. Since the alt attribute is being applied to a div in the BackgroundImage component, that alt text isn't being utilized in anyway that I can tell (not announced by screen reader nor rendering as text if the image fails to load).

I can open a separate issue (and mark it as a breaking change if necessary), but two possible options are:

  1. Remove the backgroundImgAlt prop from LoginPage (breaking, though not urgent so waiting for a breaking change release should be okay)
  2. If we intend for consumers to use the BackgroundImage component in a way that "alt text" should be exposed for assistive technologies, adding role="img" to BackgroundImage and using aria-label instead of the alt attribute for the alt text in LoginPage (possibly breaking, depending if consumers are utilizing this alt attribute?)

Copy link
Copy Markdown
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

```ts file='./LoginPageShowHidePassword.tsx' isFullscreen
```

### With language selector
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still suggest renaming this example and adding a description about how actions can be used for a language selector.
cc @mcarrano

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with that if it would clarify what this example is illustrating.

@nicolethoen
Copy link
Copy Markdown
Contributor

After a convo with Andy yesterday and looking into things a bit, the backgroundImgAlt prop on the LoginPage component isn't doing what it's intended to do, though it also seems unnecessary since the BackgroundImage component seems like it's meant strictly as decorative content. Since the alt attribute is being applied to a div in the BackgroundImage component, that alt text isn't being utilized in anyway that I can tell (not announced by screen reader nor rendering as text if the image fails to load).

I can open a separate issue (and mark it as a breaking change if necessary), but two possible options are:

  1. Remove the backgroundImgAlt prop from LoginPage (breaking, though not urgent so waiting for a breaking change release should be okay)
  2. If we intend for consumers to use the BackgroundImage component in a way that "alt text" should be exposed for assistive technologies, adding role="img" to BackgroundImage and using aria-label instead of the alt attribute for the alt text in LoginPage (possibly breaking, depending if consumers are utilizing this alt attribute?)

@thatblindgeye I think you can open a breaking change follow up issue to remove the backgroundImgAlt

Copy link
Copy Markdown
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than comments above, looks good! Will open a follow up issue based on the above as well.

@tlabaj
Copy link
Copy Markdown
Contributor

tlabaj commented Aug 18, 2022

@thatblindgeye I do not know which would be the better solution. Maybe open the breaking and pretty much copy the comment you have above and list both options. When we are implementing solution we can discus further. Or maybe get @jessiehuff's opinion in he issue.

Copy link
Copy Markdown
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Thanks @andyyvo !

loginSubtitle?: string;
/** Content rendered inside of Login Main Footer Band to display a sign up for account message */
/** Header utilities for the login main body header of the login page */
headerUtilities?: React.ReactNode;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we label this one beta? Then we can merge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlabaj how do I label something as beta?

Copy link
Copy Markdown
Contributor

@tlabaj tlabaj Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andyyvo You just need to but the @beta at the beginning of the prop description. This give us the flexibility to improve on API (including breaking change) if need be. Once we decide feature is stable, we promote it out of beta and remove the tag.
/** @beta Header utilities for the login main body header of the login page */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tlabaj would you also like to see this on the LoginMainHeader.tsx prop as well?

Copy link
Copy Markdown
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tlabaj tlabaj merged commit b902b2c into patternfly:main Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Login page - add example with language selector

7 participants