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, navigation-logo, navigation-user): Add navigation, navigation-logo & navigation-user components. #6873

Merged
merged 84 commits into from May 22, 2023

Conversation

anveshmekala
Copy link
Contributor

@anveshmekala anveshmekala commented Apr 27, 2023

Related Issue: #6531

Summary

This PR adds the following components:

  • calcite-navigation
  • calcite-navigation-user
  • calcite-navigation-logo

Co-authored by @macandcheese
Extracted from #6829

calcite-navigation

Usage

Basic

<calcite-shell>
  <calcite-navigation slot="header">
    <calcite-chip-group slot="content-center">
      <calcite-chip>nav item 1</calcite-chip>
      <calcite-chip>nav item 2</calcite-chip>
      <calcite-chip>nav item 3</calcite-chip>
    </calcite-chip-group>
  </calcite-navigation>
</calcite-shell>

Properties

Property Attribute Description Type Default
label (required) label When navigationAction is true, specifies the label of the calcite-action. string undefined
navigationAction navigation-action When true, displays a calcite-action and emits a calciteNavActionSelect event on selection change. boolean false

Events

Event Description Type
calciteNavigationActionSelect When navigationAction is true, emits when the displayed action selection changes. CustomEvent<void>

Methods

setFocus() => Promise<void>

When navigation-action is true, sets focus on the component's action element.

Returns

Type: Promise<void>

CSS Custom Properties

Name Description
--calcite-navigation-background Specifies the background color of the component.
--calcite-navigation-border-color Specifies the border color of the component.
--calcite-navigation-width Specifies the width of the component's content area.

Dependencies

Depends on


calcite-navigation-logo

Usage

Basic

<calcite-navigation-logo active thumbnail="./_assets/images/esri-logo.svg"></calcite-navigation-user>

Properties

Property Attribute Description Type Default
active active When true, the component is highlighted. boolean undefined
description description A description for the component, which displays below the heading. string undefined
heading heading Specifies heading text for the component, such as a product or organization name. string undefined
href href Specifies the URL destination of the component, which can be set as an absolute or relative path. string undefined
label label Describes the appearance or function of the thumbnail. If no label is provided, context will not be provided to assistive technologies. string undefined
rel rel Defines the relationship between the href value and the current document. string undefined
target target Specifies where to open the linked document defined in the href property. string undefined
thumbnail thumbnail Specifies the src to an image. string undefined

Methods

setFocus() => Promise<void>

Sets focus on the component.

Returns

Type: Promise<void>


calcite-navigation-user

Usage

Basic

<calcite-navigation-user full-name="Jhon Doe" user-id="Jhon123" active></calcite-navigation-user>

Properties

Property Attribute Description Type Default
active active When true, the component is highlighted. boolean undefined
fullName full-name Specifies the full name of the user. string undefined
label label Describes the appearance of the avatar. If no label is provided, context will not be provided to assistive technologies. string undefined
textDisabled text-disabled When true, hides the fullName and username contents. boolean false
thumbnail thumbnail Specifies thesrc to an image (remember to add a token if the user is private). string undefined
userId user-id Specifies the unique id of the user. string undefined
username username Specifies the username of the user. string undefined

Methods

setFocus() => Promise<void>

Sets focus on the component.

Returns

Type: Promise<void>

Dependencies

Depends on

@github-actions github-actions bot added the enhancement Issues tied to a new feature or request. label Apr 27, 2023
@anveshmekala anveshmekala marked this pull request as ready for review April 27, 2023 20:29
@anveshmekala anveshmekala requested a review from a team as a code owner April 27, 2023 20:29
@anveshmekala anveshmekala added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Apr 27, 2023
Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

Initial review! LOoking good! 👀

src/components/nav-logo/nav-logo.tsx Outdated Show resolved Hide resolved
src/components/nav-logo/nav-logo.tsx Outdated Show resolved Hide resolved
src/components/nav-logo/nav-logo.tsx Outdated Show resolved Hide resolved
src/components/nav-logo/nav-logo.tsx Outdated Show resolved Hide resolved
src/components/nav-logo/nav-logo.tsx Outdated Show resolved Hide resolved
src/components/nav/nav.tsx Outdated Show resolved Hide resolved
src/components/nav/nav.tsx Outdated Show resolved Hide resolved
src/components/nav/nav.tsx Outdated Show resolved Hide resolved
src/components/nav/nav.tsx Outdated Show resolved Hide resolved
stencil.config.ts Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a better way to use assets in demo pages? Maybe we can use url if these are publicly available to not include in project.

src/components/nav-logo/nav-logo.scss Outdated Show resolved Hide resolved
src/components/nav/nav.tsx Outdated Show resolved Hide resolved
@anveshmekala anveshmekala added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Apr 29, 2023
@anveshmekala anveshmekala changed the title feat(navigation, navigation-logo, navigation-user): Add nav, nav-logo & nav-user components. feat(navigation, navigation-logo, navigation-user): Add navigation, navigation-logo & navigation-user components. May 19, 2023
@anveshmekala anveshmekala added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 19, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

Awesome stuff, @anveshmekala!

Once the setFocus and navigation action prop/event renames are addressed, this should be good to merge!

src/components/navigation-logo/navgation-logo.tsx Outdated Show resolved Hide resolved
render(): VNode {
return (
<Host>
<a href={this.href} tabindex={0}>
Copy link
Member

Choose a reason for hiding this comment

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

No need to set tabindex here as anchor's is 0 by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the tabIndex still needs to be set here because the default 0 is applied only when href has a valid value or an empty string. I tried adding empty string which results in reload of page. Later changed to "#" which affects a11y instructions.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe you could do tabindex={!this.href ? 0 : null}. href should be a required prop though right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tabindex={!this.href ? 0 : null} this will over-ride the default tabindex value 0 with null when href is defined and href is not a required prop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we add rel & target prop here?

Copy link
Member

Choose a reason for hiding this comment

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

If that's the case, it should probably follow calcite-button logic and render either a button or a anchor depending on the existence of href.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't think href should be a required attribute for logo. Is there an added advantage of rendering a button when href is undefined besides click event being emitted on Space keydown ?

Copy link
Member

Choose a reason for hiding this comment

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

I think it would just be a11y concerns. An anchor should take you somewhere (either on the page or off) whereas as button should perform some action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when href is undefined & text-enabled is false , VoiceOver is reads out the logo as {label} name, image.
when href is undefined & text-enabled is true , VoiceOver focuses the image reading the instruction as {label} name, image and then user can move on to the text which is read out.

The only time VoiceOver recognizes logo as link is when user adds href. When both href and label are undefined , the instructions recognizes logo as clickable element.

Tested with VoicOver and safari 16.4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

synced-up with kitty today.

Updates regarding navigation-logo a11y:

  • tabindex default value is removed because logo shouldn't be in the focus order when href is null value.
  • AT user should be able to hear out image (if label is defined), heading & description context.
  • Screen readers will recognize logo as link if href is defined.

src/components/navigation-logo/navgation-logo.tsx Outdated Show resolved Hide resolved
src/components/navigation-logo/navgation-logo.tsx Outdated Show resolved Hide resolved
src/components/navigation-user/usage/Basic.md Show resolved Hide resolved
expect(eventSpy).toHaveReceivedEventTimes(1);

await page.keyboard.press("Space");
await page.waitForChanges();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think waitForChanges is needed here as it wasn't needed for Enter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests are failing without waitForChanges on Space key . I see that waitForChanges is added in many other instances on Space keydown.

src/components/navigation/navigation.tsx Outdated Show resolved Hide resolved
src/components/navigation/navigation.tsx Outdated Show resolved Hide resolved
src/utils/dom.ts Outdated Show resolved Hide resolved
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

Awesome stuff, @anveshmekala!

Once the setFocus and navigation action prop/event renames are addressed, this should be good to merge!

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

Nice! 👍 💯

@Prop() label: string;

/** Specifies the subtext to display, such as an organization or application description. */
@Prop() subtext: string;
Copy link
Member

Choose a reason for hiding this comment

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

Should this maybe be named description to be consistent with other props?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can use description here considering we change the text attribute to something like name or label.

cc @jcfranco

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to heading and description. Wondering if we should drop textEnabled prop and render heading & description if provided by the user.

return (
<Host>
<button aria-label={this.label}>
<calcite-avatar
Copy link
Member

Choose a reason for hiding this comment

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

note: I wonder if it might make more sense to just have them slot the <calcite-avatar> instead of this component having all the same props?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for having a separate component is to restrict the users from setting the scale which can cause layout issues in navigation context me thinks. We can considering re-using avatar component by rendering username & fullName in the DOM and adjusting scaling based on CSS selectors to identify if its slotted inside navigation component.

WDYT @macandcheese @jcfranco

Copy link
Member

Choose a reason for hiding this comment

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

We could always modify the scale of the avatar onslotchange.

@anveshmekala anveshmekala added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 22, 2023
@anveshmekala anveshmekala added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 22, 2023
@anveshmekala anveshmekala added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels May 22, 2023
@anveshmekala anveshmekala merged commit 167f9f8 into master May 22, 2023
15 checks passed
@anveshmekala anveshmekala deleted the anveshmekala/6531-feat-navigation-component branch May 22, 2023 19:09
@github-actions github-actions bot added this to the 2023 May Priorities milestone May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues tied to a new feature or request. pr ready for visual snapshots Adding this label will run visual snapshot testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants