Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add title component #105

Merged
merged 8 commits into from
May 1, 2020

Conversation

eamahanna
Copy link
Contributor

PR Description

This PR adds the Title component. This component may be used through out an application, and is included in the USWDS Header Component: https://designsystem.digital.gov/components/header/

Screen Shot 2020-04-24 at 2 01 30 PM

For Reviewers

Should this component be composed in an alternate manner to make it more reuse-able?

To test this component execute the following commands in the react-uswds repo:

yarn install
yarn storybook

Navigate to the Title component.

@eamahanna eamahanna requested a review from haworku April 24, 2020 22:02
@eamahanna eamahanna linked an issue Apr 24, 2020 that may be closed by this pull request
return (
<div className={classes}>
<em className="usa-logo__text">
<a href={link}>{title}</a>
Copy link
Contributor

@haworku haworku Apr 27, 2020

Choose a reason for hiding this comment

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

A couple things.

  • 🤔 This very much feels like it should be a <h1>. I wonder why em is being used by the uswds design team... Found discussion of the em versus h1 in their docs which links here.
  • As written, link prop could be undefined - we should probably not wrap the text in an anchor tag in the first place for those cases.

@trussworks-infra-zz
Copy link

trussworks-infra-zz commented Apr 27, 2020

Warnings
⚠️ Please add a changelog entry for your changes.

Generated by 🚫 dangerJS against 4c0efe4


return (
<div className={classes}>
<h1 className="usa-logo__text">{title}</h1>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<h1 className="usa-logo__text">{title}</h1>
link?
<h1 className="usa-logo__text">
<a href={link}>{title}</a>
</h1>
: <h1 className="usa-logo__text">{title}</h1>

Oops! My comment was unclear. What you had before was good, just conditionally display the link. Only include it when it exists. If it doesn't exist, leave it out .

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should avoid rendering <a> in general since we don't know what kind of routing a user is using. Also if we do want to render <a> we need to allow for element attributes to be passed in

Copy link
Contributor

@suzubara suzubara left a comment

Choose a reason for hiding this comment

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

Sorry it took me awhile to get to this 🤦‍♀️ I have some suggestions:

  • Should we call this component HeaderTitle or maybe HeaderLogo? I'm thinking for clarity purposes, because this component does not exist outside of the context of the header on the USWDS site, and so it may not work as expected if it's not rendered inside of the header. Or it could be located inside components/Header.
  • Here are my 2 cents on h1 vs em: by default we should render <em class="usa-logo__text"> in this component since that follows the examples from https://designsystem.digital.gov/components/header/ . However the name of that CSS class implies there could be another type of logo, such as an image. So we might want to think about how to allow other kinds of titles/logos to be passed in (such as an h1 or an image) in the future. Call me crazy but we could go as far as creating a Logo component which renders the <div class="usa-logo"> for positioning, and a TextLogo component which renders <em class="usa-logo__text"> for default text styling.
  • Since the purpose of this component is to render its contents, IMO the title should be passed in as children instead of a prop. So rendering this component would look like
<Title>Test Title</Title>

@eamahanna
Copy link
Contributor Author

Sorry it took me awhile to get to this 🤦‍♀️ I have some suggestions:

  • Should we call this component HeaderTitle or maybe HeaderLogo? I'm thinking for clarity purposes, because this component does not exist outside of the context of the header on the USWDS site, and so it may not work as expected if it's not rendered inside of the header. Or it could be located inside components/Header.
  • Here are my 2 cents on h1 vs em: by default we should render <em class="usa-logo__text"> in this component since that follows the examples from https://designsystem.digital.gov/components/header/ . However the name of that CSS class implies there could be another type of logo, such as an image. So we might want to think about how to allow other kinds of titles/logos to be passed in (such as an h1 or an image) in the future. Call me crazy but we could go as far as creating a Logo component which renders the <div class="usa-logo"> for positioning, and a TextLogo component which renders <em class="usa-logo__text"> for default text styling.
  • Since the purpose of this component is to render its contents, IMO the title should be passed in as children instead of a prop. So rendering this component would look like
<Title>Test Title</Title>

When I merge this branch into my main header branch, I will move the title into the header folder.

src/components/Title/Title.test.tsx Outdated Show resolved Hide resolved
src/components/Title/Title.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@suzubara suzubara left a comment

Choose a reason for hiding this comment

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

🔥

src/components/Title/Title.tsx Outdated Show resolved Hide resolved
@eamahanna eamahanna changed the base branch from develop to em-create-header-component-#83 May 1, 2020 15:57
@eamahanna eamahanna merged commit ee10946 into em-create-header-component-#83 May 1, 2020
@eamahanna eamahanna deleted the em-title-component-#83 branch May 1, 2020 16:18
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.

USWDS Component: Header
4 participants