-
Notifications
You must be signed in to change notification settings - Fork 76
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b63dce
fix(navigation-logo): adding heading level
josercarcamo 929a2cf
Merge branch 'main' into josercarcamo/7075-heading-level-nav-logo
josercarcamo 41ae331
Merge branch 'main' into josercarcamo/7075-heading-level-nav-logo
josercarcamo 2f393e9
fix(navigation-logo): Refactors code to remove wrapping span and unne…
josercarcamo 0bf0fad
Merge branch 'josercarcamo/7075-heading-level-nav-logo' of github.com…
josercarcamo 36b2d47
feat(navigation-logo): Changing comment for headingLevel to be consis…
josercarcamo eebdd9b
feat(navigation-logo): adding test cases and 'key' attribute per code…
josercarcamo ce4f385
Merge branch 'main' into josercarcamo/7075-heading-level-nav-logo
josercarcamo 675f3fd
Merge branch 'main' into josercarcamo/7075-heading-level-nav-logo
josercarcamo 9acb0e0
Merge branch 'main' into josercarcamo/7075-heading-level-nav-logo
josercarcamo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,43 @@ 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]: true, | ||
[CSS.standalone]: !this.description, | ||
}} | ||
key={CSS.heading} | ||
level={headingLevel} | ||
> | ||
{heading} | ||
</Heading> | ||
) : null; | ||
|
||
const descriptionNode = description ? ( | ||
<span class={CSS.description} key={CSS.description}> | ||
{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> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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."