-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add title component #105
Conversation
src/components/Title/Title.tsx
Outdated
return ( | ||
<div className={classes}> | ||
<em className="usa-logo__text"> | ||
<a href={link}>{title}</a> |
There was a problem hiding this comment.
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 whyFound discussion of theem
is being used by the uswds design team...em
versush1
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.
src/components/Title/Title.tsx
Outdated
|
||
return ( | ||
<div className={classes}> | ||
<h1 className="usa-logo__text">{title}</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<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 .
There was a problem hiding this comment.
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
There was a problem hiding this 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 maybeHeaderLogo
? 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 insidecomponents/Header
. - Here are my 2 cents on
h1
vsem
: 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 aLogo
component which renders the<div class="usa-logo">
for positioning, and aTextLogo
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
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/
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:
Navigate to the Title component.