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

feat(navigation-logo): add heading level #9054

Merged
merged 10 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions packages/calcite-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -1311,7 +1311,7 @@ export namespace Components {
*/
"activeRange": "start" | "end";
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -1771,7 +1771,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -2144,7 +2144,7 @@ export namespace Components {
*/
"form": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -3264,6 +3264,10 @@ export namespace Components {
* Specifies heading text for the component, such as a product or organization name.
*/
"heading": string;
/**
* Specifies the heading level of the component's heading for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
* Specifies the URL destination of the component, which can be set as an absolute or relative path.
*/
Expand Down Expand Up @@ -3486,7 +3490,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -3556,7 +3560,7 @@ export namespace Components {
*/
"getSelectedItems": () => Promise<Map<string, HTMLCalcitePickListItemElement>>;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -3586,7 +3590,7 @@ export namespace Components {
*/
"groupTitle": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
}
Expand Down Expand Up @@ -3680,7 +3684,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -5176,7 +5180,7 @@ export namespace Components {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -5204,7 +5208,7 @@ export namespace Components {
*/
"closed": boolean;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel": HeadingLevel;
/**
Expand Down Expand Up @@ -7974,7 +7978,7 @@ declare namespace LocalJSX {
*/
"heading": string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -8743,7 +8747,7 @@ declare namespace LocalJSX {
*/
"activeRange"?: "start" | "end";
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -9225,7 +9229,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -9617,7 +9621,7 @@ declare namespace LocalJSX {
*/
"form"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -10825,6 +10829,10 @@ declare namespace LocalJSX {
* Specifies heading text for the component, such as a product or organization name.
*/
"heading"?: string;
/**
* Specifies the heading level of the component's heading for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
* Specifies the URL destination of the component, which can be set as an absolute or relative path.
*/
Expand Down Expand Up @@ -11045,7 +11053,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -11112,7 +11120,7 @@ declare namespace LocalJSX {
*/
"filteredItems"?: HTMLCalcitePickListItemElement[];
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -11145,7 +11153,7 @@ declare namespace LocalJSX {
*/
"groupTitle"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
}
Expand Down Expand Up @@ -11254,7 +11262,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -12788,7 +12796,7 @@ declare namespace LocalJSX {
*/
"heading"?: string;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down Expand Up @@ -12820,7 +12828,7 @@ declare namespace LocalJSX {
*/
"closed"?: boolean;
/**
* Specifies the number at which section headings should start.
* Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling.
*/
"headingLevel"?: HeadingLevel;
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { html } from "../../../support/formatting";
import { accessible, focusable, hidden, reflects, renders } from "../../tests/commonTests";
import { accessible, focusable, hidden, reflects, renders, defaults } from "../../tests/commonTests";

describe("calcite-navigation-logo", () => {
describe("renders", () => {
Expand Down Expand Up @@ -32,10 +32,39 @@ describe("calcite-navigation-logo", () => {
propertyName: "target",
value: "_self",
},
{
propertyName: "headingLevel",
value: 1,
},
]);
});

describe("is focusable", () => {
focusable(html`<calcite-navigation-logo href=" " heading="esri"></calcite-navigation-logo>`);
});

describe("defaults", () => {
defaults("calcite-navigation-logo", [
{
propertyName: "active",
defaultValue: undefined,
},
{
propertyName: "href",
defaultValue: undefined,
},
{
propertyName: "rel",
defaultValue: undefined,
},
{
propertyName: "target",
defaultValue: undefined,
},
{
propertyName: "headingLevel",
defaultValue: undefined,
},
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ export const withHref_TestOnly = (): string => html`
</calcite-navigation-logo>
</calcite-navigation>
`;

export const headingLevel_TestOnly = (): string => html`
<calcite-navigation-logo
heading="ArcGIS Online"
heading-level="1"
description="City of AcmeCo"
thumbnail="${placeholderImage({ width: 50, height: 50 })}"
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
setComponentLoaded,
setUpLoadableComponent,
} from "../../utils/loadable";
import { Heading, HeadingLevel } from "../functional/Heading";

@Component({
tag: "calcite-navigation-logo",
Expand Down Expand Up @@ -59,6 +60,11 @@ export class CalciteNavigationLogo implements LoadableComponent {
/** Specifies the `src` to an image. */
@Prop() thumbnail: string;

/**
* Specifies the heading level of the component's heading for proper document structure, without affecting visual styling.
*/
@Prop({ reflect: true }) headingLevel: HeadingLevel;

//--------------------------------------------------------------------------
//
// Public Methods
Expand Down Expand Up @@ -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} key={CSS.container}>
{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>
);
Expand Down
6 changes: 6 additions & 0 deletions packages/calcite-components/src/demos/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ <h3>
<calcite-navigation-logo heading="Walt's Chips" slot="logo"> </calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-color-brand: #bf390f">
<calcite-navigation-logo heading="Walt's Chips with Level" heading-level="3" slot="logo">
</calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-color-brand: #bf390f">
<calcite-navigation-logo slot="logo" icon="link-chart"> </calcite-navigation-logo>
Expand Down
Loading