-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(navigation-logo): add heading level #9054
Changes from 2 commits
4b63dce
929a2cf
41ae331
2f393e9
0bf0fad
36b2d47
eebdd9b
ce4f385
675f3fd
9acb0e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { | |
setComponentLoaded, | ||
setUpLoadableComponent, | ||
} from "../../utils/loadable"; | ||
import { Heading, HeadingLevel } from "../functional/Heading"; | ||
|
||
@Component({ | ||
tag: "calcite-navigation-logo", | ||
|
@@ -59,6 +60,11 @@ export class CalciteNavigationLogo implements LoadableComponent { | |
/** Specifies the `src` to an image. */ | ||
@Prop() thumbnail: string; | ||
|
||
/** | ||
* Specifies the number at which section headings should start. | ||
*/ | ||
@Prop({ reflect: true }) headingLevel: HeadingLevel; | ||
|
||
//-------------------------------------------------------------------------- | ||
// | ||
// Public Methods | ||
|
@@ -107,34 +113,45 @@ export class CalciteNavigationLogo implements LoadableComponent { | |
return <calcite-icon class={CSS.icon} flipRtl={this.iconFlipRtl} icon={this.icon} scale="l" />; | ||
} | ||
|
||
renderHeaderContent(): VNode { | ||
const { heading, headingLevel, description } = this; | ||
const headingNode = heading ? ( | ||
<Heading class={CSS.heading} level={headingLevel}> | ||
<span | ||
aria-label={this.heading} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need an aria-label here. The heading element should already provide enough information. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove the span and add these attributes on the |
||
class={{ | ||
[CSS.heading]: true, | ||
[CSS.standalone]: !this.description, | ||
}} | ||
key={CSS.heading} | ||
> | ||
{heading} | ||
</span> | ||
</Heading> | ||
) : null; | ||
|
||
const descriptionNode = description ? ( | ||
<span aria-label={this.description} class={CSS.description} key={CSS.description}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whats the need for the aria-label here as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just trying to keep the same sematics as what was in the original code, but I've removed it. |
||
{description} | ||
</span> | ||
) : null; | ||
|
||
return headingNode || descriptionNode ? ( | ||
<div class={CSS.container}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: should we give this one a key for consistency? |
||
{headingNode} | ||
{descriptionNode} | ||
</div> | ||
) : null; | ||
} | ||
|
||
render(): VNode { | ||
const { heading, description, thumbnail } = this; | ||
const { thumbnail } = this; | ||
return ( | ||
<Host> | ||
<a class={CSS.anchor} href={this.href} rel={this.rel} target={this.target}> | ||
{thumbnail && <img alt={this.label || ""} class={CSS.image} src={thumbnail} />} | ||
{this.icon && this.renderIcon()} | ||
{(heading || description) && ( | ||
<div class={CSS.container}> | ||
{heading && ( | ||
<span | ||
aria-label={this.heading} | ||
class={{ | ||
[CSS.heading]: true, | ||
[CSS.standalone]: !this.description, | ||
}} | ||
key={CSS.heading} | ||
> | ||
{heading} | ||
</span> | ||
)} | ||
{description && ( | ||
<span aria-label={this.description} class={CSS.description} key={CSS.description}> | ||
{description} | ||
</span> | ||
)} | ||
</div> | ||
)} | ||
{this.renderHeaderContent()} | ||
</a> | ||
</Host> | ||
); | ||
|
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.
@josercarcamo Very timely! @DitwanP made similar changes across the components earlier today. CC'ing him for editorial review on the
headingLevel
doc update.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.
@josercarcamo we are going with this description for headingLevel prop everywhere else, you can also add it here as well for consistency.
"Specifies the heading level of the component's
heading
for proper document structure, without affecting visual styling."