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): Adds icon and iconFlipRtl properties #8054

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@
@apply bg-foreground-3;
}

.image {
.image,
.icon {
@apply flex h-7 m-0 px-4;
}

.image ~ .container {
.image ~ .icon {
@apply ps-0;
}

.image ~ .container,
.icon ~ .container {
@apply ps-0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export class CalciteNavigationLogo implements LoadableComponent {
/** Specifies the URL destination of the component, which can be set as an absolute or relative path.*/
@Prop({ reflect: true }) href: string;

/** Specifies an icon to display. */
@Prop({ reflect: true }) icon: string;

/** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
@Prop({ reflect: true }) iconFlipRtl = false;

/** Describes the appearance or function of the `thumbnail`. If no label is provided, context will not be provided to assistive technologies. */
@Prop() label: string;

Expand Down Expand Up @@ -96,12 +102,17 @@ export class CalciteNavigationLogo implements LoadableComponent {
//
// --------------------------------------------------------------------------

private renderIcon(): VNode {
return <calcite-icon class={CSS.icon} flipRtl={this.iconFlipRtl} icon={this.icon} scale="l" />;
macandcheese marked this conversation as resolved.
Show resolved Hide resolved
}

render(): VNode {
const { heading, description, 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 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const CSS = {
anchor: "anchor",
image: "image",
standalone: "standalone",
icon: "icon",
};
54 changes: 52 additions & 2 deletions packages/calcite-components/src/demos/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,16 @@ <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-ui-brand: #bf390f">
<calcite-navigation-logo slot="logo" icon="link-chart"> </calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo heading="Walt's Chips" slot="logo" icon="link-chart"> </calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo heading="Walt's Chips" description="Eastern Potato Chip Company" slot="logo">
Expand All @@ -348,6 +358,17 @@ <h3>
</calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo
heading="Walt's Chips"
description="Eastern Potato Chip Company"
slot="logo"
icon="link-chart"
>
</calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo
Expand Down Expand Up @@ -384,7 +405,24 @@ <h3>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo active description="Eastern Potato Chip Company" slot="logo">
<calcite-navigation-logo
icon="layer"
active
heading="Walt's Chips"
description="Eastern Potato Chip Company"
slot="logo"
>
</calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo icon="pin-plus" active heading="Walt's Chips" slot="logo"> </calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo active icon="layer" description="Eastern Potato Chip Company" slot="logo">
</calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
Expand All @@ -400,7 +438,19 @@ <h3>
</calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>

<calcite-shell>
<calcite-navigation slot="header" style="--calcite-ui-brand: #bf390f">
<calcite-navigation-logo
active
heading="Walt's Chips"
icon="address-book"
description="Eastern Potato Chip Company"
slot="logo"
thumbnail="./_assets/images/acme-logo.svg"
>
</calcite-navigation-logo>
</calcite-navigation>
</calcite-shell>
<div id="calcite-navigation-user" class="text-box">
<h2><code>calcite-navigation-user</code></h2>
<h3>
Expand Down
Loading