Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .changeset/wicked-rooms-wear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hashicorp/design-system-components": minor
---

<!-- START components/app-header -->
`AppHeader` - return `close` callback to the `:logo` named block so the menu actions can be hidden programmatically when the component is in a mobile view.
<!-- END -->
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/>
{{/if}}

{{yield to="logo"}}
{{yield (hash close=this.close) to="logo"}}

{{#if (not this._isDesktop)}}
<Hds::AppHeader::MenuButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export interface HdsAppHeaderSignature {
a11yRefocusExcludeAllQueryParams?: boolean;
};
Blocks: {
logo?: [];
logo?: [
{
close: () => void;
},
];
globalActions?: [
{
close: () => void;
Expand Down
6 changes: 5 additions & 1 deletion showcase/app/components/mock/app/header/app-header.gts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ export default class MockAppHeaderAppHeader extends Component<MockAppHeaderAppHe

<template>
<HdsAppHeader>
<:logo>
<:logo as |actions|>
<HdsAppHeaderHomeLink
@icon="hashicorp"
@text="HashiCorp home menu"
@isIconOnly={{true}}
@href="#"
@isHrefExternal={{false}}
{{on "click" actions.close}}
/>
</:logo>

<:globalActions as |actions|>
{{#if this.showOrgPicker}}
<HdsDropdown @enableCollisionDetection={{true}} as |dd|>
Expand All @@ -62,6 +65,7 @@ export default class MockAppHeaderAppHeader extends Component<MockAppHeaderAppHe
</HdsDropdown>
{{/if}}
</:globalActions>

<:utilityActions as |actions|>
{{#if this.showRegionPicker}}
<HdsDropdown @enableCollisionDetection={{true}} as |dd|>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,28 @@ module('Integration | Component | hds/app-header/index', function (hooks) {
test('it should hide the actions when the "close" function is called in mobile view', async function (assert) {
await render(hbs`
<Hds::AppHeader id='test-app-header' @breakpoint='10000px'>
<:globalActions as |actions|>
<:logo as |actions|>
<Hds::AppHeader::HomeLink
@icon="hashicorp"
@text="HashiCorp"
id="test-home-link"
{{on "click" actions.close}}
/>
</:logo>
<:globalActions as |actions|>
<Hds::Button id='test-global-action' {{on 'click' actions.close}} @text="Global action" />
</:globalActions>
<:utilityActions as |actions|>
<Hds::Button id='test-utility-action' {{on 'click' actions.close}} @text="Utility action" />
<:utilityActions as |actions|>
<Hds::Button id='test-utility-action' {{on 'click' actions.close}} @text="Utility action" />
</:utilityActions>
</Hds::AppHeader>`);

// test logo actions close
await click('.hds-app-header__menu-button');
assert.dom('#test-app-header').hasClass('hds-app-header--menu-is-open');
await click('#test-home-link');
assert.dom('#test-app-header').hasClass('hds-app-header--menu-is-closed');

// test global actions close
await click('.hds-app-header__menu-button');
assert.dom('#test-app-header').hasClass('hds-app-header--menu-is-open');
Expand Down