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

DO NOT MERGE: side nav spike exploring how to properly nest lists, add titles for all lists, fix showcase #2478

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion packages/components/src/components/hds/side-nav/base.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
}}
{{! IMPORTANT: we need to add "squishies" here (~) because otherwise the whitespace added by Ember causes the empty element to still have visible padding - See https://handlebarsjs.com/guide/expressions.html#whitespace-control }}
<div class="hds-side-nav" ...attributes>
<h2 class="sr-only" id="hds-app-side-nav-header">Application local navigation</h2>
<div class="hds-side-nav__wrapper">
{{yield to="root"}}
<div class="hds-side-nav__wrapper-header">
{{~yield to="header"~}}
</div>
<div class="hds-side-nav__wrapper-body">
{{~yield to="body"~}}
<nav aria-labelledby="hds-app-side-nav-header">
{{~yield to="body"~}}
</nav>
</div>
<div class="hds-side-nav__wrapper-footer">
{{~yield to="footer"~}}
Expand Down
29 changes: 26 additions & 3 deletions packages/components/src/components/hds/side-nav/list/back-link.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,31 @@
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}

<Hds::SideNav::List::Item>
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{#if @shouldWrapInListItem}}
<Hds::SideNav::List::Item>
<Hds::Interactive
class="hds-side-nav__list-item-link hds-side-nav__list-item-link--back-link"
@current-when={{@current-when}}
@models={{hds-link-to-models @model @models}}
@query={{hds-link-to-query @query}}
@replace={{@replace}}
@route={{@route}}
@isRouteExternal={{@isRouteExternal}}
@href={{@href}}
@isHrefExternal={{@isHrefExternal}}
...attributes
>
<Hds::Icon class="hds-side-nav__list-item-icon-leading" @name="chevron-left" />
<span class="hds-side-nav__list-item-text hds-typography-body-200 hds-font-weight-medium">
{{@text}}
</span>
</Hds::Interactive>
</Hds::SideNav::List::Item>
{{else}}
<Hds::Interactive
class="hds-side-nav__list-item-link hds-side-nav__list-item-link--back-link"
@current-when={{@current-when}}
Expand All @@ -21,4 +44,4 @@
{{@text}}
</span>
</Hds::Interactive>
</Hds::SideNav::List::Item>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { HdsInteractiveSignature } from '../../interactive/';
export interface HdsSideNavListBackLinkSignature {
Args: HdsInteractiveSignature['Args'] & {
text: string;
shouldWrapInListItem?: boolean;
};
Element: HdsInteractiveSignature['Element'];
}
Expand Down
20 changes: 13 additions & 7 deletions packages/components/src/components/hds/side-nav/list/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
SPDX-License-Identifier: MPL-2.0
}}

<nav class="hds-side-nav__list-wrapper" ...attributes>
{{! <nav class="hds-side-nav__list-wrapper" ...attributes> }}
<div>
{{yield (hash ExtraBefore=(component "hds/yield"))}}
<ul class="hds-side-nav__list" role="list">
</div>
{{#let (unique-id) as |titleId|}}
<p style="margin: 0px; padding: 0px;">{{yield (hash Title=(component "hds/side-nav/list/title" id=titleId))}}</p>
<ul class="hds-side-nav__list" role="list" aria-labelledby={{titleId}}>
{{yield (hash Item=(component "hds/side-nav/list/item"))}}
{{yield
(hash
Item=(component "hds/side-nav/list/item")
BackLink=(component "hds/side-nav/list/back-link")
Title=(component "hds/side-nav/list/title")
Link=(component "hds/side-nav/list/link")
BackLink=(component "hds/side-nav/list/back-link" shouldWrapInListItem=true)
Link=(component "hds/side-nav/list/link" shouldWrapInListItem=true)
)
}}
</ul>
{{/let}}
<div>
{{yield (hash ExtraAfter=(component "hds/yield"))}}
</nav>
</div>
{{! </nav> }}
49 changes: 47 additions & 2 deletions packages/components/src/components/hds/side-nav/list/link.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,53 @@
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{#if @shouldWrapInListItem}}
<Hds::SideNav::List::Item>
<Hds::Interactive
class="hds-side-nav__list-item-link {{if @isActive 'active'}}"
@current-when={{@current-when}}
@models={{hds-link-to-models @model @models}}
@query={{hds-link-to-query @query}}
@replace={{@replace}}
@route={{@route}}
@isRouteExternal={{@isRouteExternal}}
@href={{@href}}
@isHrefExternal={{@isHrefExternal}}
...attributes
>
{{#if @icon}}
<Hds::Icon class="hds-side-nav__list-item-icon-leading" @name={{@icon}} />
{{/if}}

<Hds::SideNav::List::Item>
{{#if @text}}
<span class="hds-side-nav__list-item-text hds-typography-body-200 hds-font-weight-medium">
{{@text}}
</span>
{{/if}}

{{#if @count}}
<Hds::BadgeCount @text={{@count}} @type="inverted" @size="small" />
{{/if}}

{{#if @badge}}
<Hds::Badge @text={{@badge}} @type="inverted" @size="small" />
{{/if}}

{{yield}}

{{#if @hasSubItems}}
<span class="hds-side-nav__list-item-icon-trailing">
<Hds::Icon @name="chevron-right" />
</span>
{{/if}}
{{#if @isHrefExternal}}
<span class="hds-side-nav__list-item-icon-trailing">
<Hds::Icon @name="external-link" />
</span>
{{/if}}
</Hds::Interactive>
</Hds::SideNav::List::Item>
{{else}}
<Hds::Interactive
class="hds-side-nav__list-item-link {{if @isActive 'active'}}"
@current-when={{@current-when}}
Expand Down Expand Up @@ -47,4 +92,4 @@
</span>
{{/if}}
</Hds::Interactive>
</Hds::SideNav::List::Item>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface HdsSideNavListLinkSignature {
count?: string;
hasSubItems?: boolean;
isActive?: boolean;
shouldWrapInListItem?: boolean;
};
Blocks: {
default: [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
SPDX-License-Identifier: MPL-2.0
}}

<Hds::SideNav::List::Item>
<div class="hds-side-nav__list-title hds-typography-body-100 hds-font-weight-semibold" ...attributes>{{~yield~}}</div>
</Hds::SideNav::List::Item>
<div
class="hds-side-nav__list-title hds-typography-body-100 hds-font-weight-semibold"
id={{@id}}
...attributes
>{{~yield~}}</div>
3 changes: 3 additions & 0 deletions packages/components/src/components/hds/side-nav/list/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import TemplateOnlyComponent from '@ember/component/template-only';

export interface HdsSideNavListTitleSignature {
Args: {
id?: string;
};
Blocks: {
default: [];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

<Portal @target={{if @targetName @targetName "hds-side-nav-portal-target"}}>
<div class="hds-side-nav__content-panel" ...attributes>
<Hds::SideNav::List aria-label={{@ariaLabel}} as |ListElements|>
{{yield ListElements}}
</Hds::SideNav::List>
{{!-- <Hds::SideNav::List aria-label={{@ariaLabel}} as |ListElements|> --}}
{{yield}}
{{! </Hds::SideNav::List> }}
Comment on lines +8 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have questions about this but I think Kristin could clarify

</div>
</Portal>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import TemplateOnlyComponent from '@ember/component/template-only';

import type { HdsSideNavListSignature } from '../list/index';
// import type { HdsSideNavListSignature } from '../list/index';

// TODO! understand how this should be done "correctly"
// import type { PortalSignature } from 'ember-stargate/components/portal';
Expand All @@ -16,16 +16,17 @@ interface PortalSignature {
fallback?: 'inplace';
};
Blocks: {
default: [];
default?: [];
};
}

export interface HdsSideNavPortalSignature {
Args: PortalSignature['Args'] & {
ariaLabel?: string;
targetName?: string;
};
Blocks: HdsSideNavListSignature['Blocks'];
Blocks: {
default?: [];
};
Element: HTMLDivElement;
}

Expand Down
Loading
Loading