diff --git a/.changeset/dry-spiders-tell.md b/.changeset/dry-spiders-tell.md new file mode 100644 index 00000000000..b07bd07ac90 --- /dev/null +++ b/.changeset/dry-spiders-tell.md @@ -0,0 +1,6 @@ +--- +"@hashicorp/design-system-components": minor +--- + +`AppHeader` - Refactored the Home Link, removed the `@ariaLabel` argument, added +`@text` (should replace `@ariaLabel`) and `@isIconOnly` arguments. diff --git a/packages/components/src/components/hds/app-header/home-link.hbs b/packages/components/src/components/hds/app-header/home-link.hbs index 9235f453019..9521f6f6b45 100644 --- a/packages/components/src/components/hds/app-header/home-link.hbs +++ b/packages/components/src/components/hds/app-header/home-link.hbs @@ -14,7 +14,10 @@ @href={{@href}} @isHrefExternal={{@isHrefExternal}} ...attributes - aria-label={{this.ariaLabel}} + aria-label={{if this.isIconOnly this.text null}} > + {{#unless this.isIconOnly}} + {{this.text}} + {{/unless}} \ No newline at end of file diff --git a/packages/components/src/components/hds/app-header/home-link.ts b/packages/components/src/components/hds/app-header/home-link.ts index fcf3da1469d..bb53d175014 100644 --- a/packages/components/src/components/hds/app-header/home-link.ts +++ b/packages/components/src/components/hds/app-header/home-link.ts @@ -12,21 +12,37 @@ import type { HdsInteractiveSignature } from '../interactive/'; export interface HdsAppHeaderHomeLinkSignature { Args: HdsInteractiveSignature['Args'] & { icon: HdsIconSignature['Args']['name']; + isIconOnly?: boolean; color?: string; - ariaLabel: string; + text: string; }; Element: HdsInteractiveSignature['Element']; } export default class HdsAppHeaderHomeLink extends Component { - get ariaLabel(): string { - const { ariaLabel } = this.args; + get text(): string { + const { text } = this.args; assert( - '@ariaLabel for "Hds::AppHeader::HomeLink" ("Logo") must have a valid value', - ariaLabel !== undefined + '@text for "Hds::AppHeader::HomeLink" must have a valid value', + text !== undefined ); - return ariaLabel; + return text; + } + + get icon(): HdsIconSignature['Args']['name'] { + const { icon } = this.args; + + assert( + '@icon name for "Hds::AppHeader::HomeLink" must be provided', + icon !== undefined + ); + + return icon; + } + + get isIconOnly(): boolean { + return this.args.isIconOnly ?? true; } } diff --git a/packages/components/src/styles/components/app-header.scss b/packages/components/src/styles/components/app-header.scss index d0fe7094aee..298ef3c17e2 100644 --- a/packages/components/src/styles/components/app-header.scss +++ b/packages/components/src/styles/components/app-header.scss @@ -102,6 +102,7 @@ .hds-app-header__utility-actions { display: flex; gap: inherit; + align-items: center; } // Dropdown & Button color theming overrides @@ -144,12 +145,11 @@ .hds-app-header__home-link { @include hds-interactive-dark-theme($add-visible-border: false); display: flex; + gap: 8px; align-items: center; justify-content: center; - - // Set home link container size: - width: var(--token-app-header-home-link-size); - height: var(--token-app-header-home-link-size); + padding: 3px; + text-decoration: none; // disabled state: &:disabled, diff --git a/showcase/app/components/mock/app/header/app-header.gts b/showcase/app/components/mock/app/header/app-header.gts index e40f42b1cd2..528f41be5d6 100644 --- a/showcase/app/components/mock/app/header/app-header.gts +++ b/showcase/app/components/mock/app/header/app-header.gts @@ -46,7 +46,8 @@ export default class MockAppHeaderAppHeader extends Component diff --git a/showcase/app/templates/components/app-header/index.hbs b/showcase/app/templates/components/app-header/index.hbs index 17eaf5839c5..839b7c5d688 100644 --- a/showcase/app/templates/components/app-header/index.hbs +++ b/showcase/app/templates/components/app-header/index.hbs @@ -1,6 +1,6 @@ {{! - Copyright (c) HashiCorp, Inc. - SPDX-License-Identifier: MPL-2.0 +Copyright (c) HashiCorp, Inc. +SPDX-License-Identifier: MPL-2.0 }} {{page-title "AppHeader Component"}} @@ -14,8 +14,8 @@ With generic content - - + + <:logo> @@ -32,18 +32,18 @@ - - + + With typical child component content - - + + <:logo> - + <:globalActions> @@ -75,12 +75,12 @@ - + - + <:logo> - + <:globalActions> @@ -114,12 +114,12 @@ - + - + <:logo> - + <:globalActions> @@ -160,18 +160,18 @@ - - + + With long content - - + + <:logo> - + <:globalActions> @@ -202,12 +202,12 @@ - + - + <:logo> - + <:globalActions> @@ -238,18 +238,105 @@ - - + + + + + + With text + + + + + + <:logo> + + + <:utilityActions> + + + + + Account Settings + + + + + + + + <:logo> + + + <:globalActions> + + + + organizationName + + + + <:utilityActions> + + + + Documentation + Tutorials + Terraform Provider + Changelog + + Create support ticket + Give feedback + + + + + + + Account Settings + + + + + + + + <:logo> + + + <:utilityActions> + + + + + + + + <:logo> + + + <:globalActions> + + + + + + Options - - + + <:logo> - + <:globalActions> @@ -281,13 +368,12 @@ - + - - + {{! For some reason, Ember tests don't play well with iframes (URL not found) so we can't take snapshots of these examples in Percy }}
@@ -337,14 +423,14 @@ Base elements - SideNav::Header::HomeLink + AppHeader::HomeLink Content
- +
@@ -352,7 +438,7 @@
@@ -360,14 +446,42 @@ + With text + + + +
+ +
+
+ + +
+ +
+
+
+ States - {{#let (array "default" "hover" "active" "focus" "disabled") as |states|}} + {{#let (array "default" "hover" "active" "focus") as |states|}} {{#each states as |state|}}
- +
{{/each}} @@ -375,13 +489,13 @@
- {{#let (array "default" "hover" "active" "focus" "disabled") as |states|}} + {{#let (array "default" "hover" "active" "focus") as |states|}} {{#each states as |state|}}
+ + {{#let (array "default" "hover" "active" "focus") as |states|}} + {{#each states as |state|}} + +
+ +
+
+ {{/each}} + {{/let}} +
+ Buttons within AppHeader @@ -421,20 +553,20 @@ States - + {{! Notice: we use a non-standard way to showcase the states to reduce the (visual) complexity of this matrix }} {{#each @model.TOGGLE_STATES as |state|}} - + {{capitalize state}} - + {{/each}} - + Open - + {{#each @model.TOGGLE_BUTTON_COLORS as |color|}} {{#each @model.TOGGLE_STATES as |state|}} - + {{#if (eq state "disabled")}}
@@ -444,17 +576,17 @@
{{/if}} -
+ {{/each}} - +
-
+ {{#each @model.TOGGLE_STATES as |state|}} - + {{#if (eq state "disabled")}}
@@ -469,17 +601,17 @@ />
{{/if}} -
+ {{/each}} - +
-
+ {{#each @model.TOGGLE_STATES as |state|}} - + {{#if (eq state "disabled")}}
@@ -489,17 +621,17 @@
{{/if}} -
+ {{/each}} - +
-
+ {{#each @model.TOGGLE_STATES as |state|}} - + {{#if (eq state "disabled")}}
{{/if}} -
+ {{/each}} - +
-
+ {{/each}} {{#each @model.TOGGLE_STATES as |state|}} - +
-
+ {{/each}} - +
-
+ {{#each @model.TOGGLE_STATES as |state|}} - +
-
+ {{/each}} - +
-
+ {{#each @model.TOGGLE_STATES as |state|}} - +
-
+ {{/each}} - +
-
+ - +
@@ -620,6 +752,6 @@
-
+
\ No newline at end of file diff --git a/showcase/tests/integration/components/hds/app-header/home-link-test.js b/showcase/tests/integration/components/hds/app-header/home-link-test.js index 7a7de5238f1..e35487b1216 100644 --- a/showcase/tests/integration/components/hds/app-header/home-link-test.js +++ b/showcase/tests/integration/components/hds/app-header/home-link-test.js @@ -19,7 +19,7 @@ module('Integration | Component | hds/app-header/home-link', function (hooks) { await render( hbs``, ); @@ -32,7 +32,7 @@ module('Integration | Component | hds/app-header/home-link', function (hooks) { await render( hbs``, @@ -48,7 +48,7 @@ module('Integration | Component | hds/app-header/home-link', function (hooks) { await render( hbs``, @@ -58,11 +58,24 @@ module('Integration | Component | hds/app-header/home-link', function (hooks) { .hasAttribute('fill', 'var(--token-color-boundary-brand)'); }); + test('it renders the logo with text when @isIconOnly is false', async function (assert) { + await render( + hbs``, + ); + assert.dom('.hds-text').exists(); + }); + // ASSERTIONS - test('it should throw an assertion if @ariaLabel is missing/has no value', async function (assert) { + test('it should throw an assertion if @text is missing/has no value', async function (assert) { const errorMessage = - '@ariaLabel for "Hds::AppHeader::HomeLink" ("Logo") must have a valid value'; + '@text for "Hds::AppHeader::HomeLink" must have a valid value'; assert.expect(2); setupOnerror(function (error) { assert.strictEqual(error.message, `Assertion Failed: ${errorMessage}`);