Skip to content
This repository was archived by the owner on Aug 7, 2020. It is now read-only.

Conversation

AxelPeter
Copy link
Contributor

@AxelPeter AxelPeter commented Jul 20, 2018

http://build_upgrade_navbar.ui-kit.ovh/#!/oui-angular/navbar

  • Add oui-navbar-brand
  • Add oui-navbar-dropdown
  • Add oui-navbar-link
  • Add oui-navbar-toggler
  • Add oui-navbar-notification
  • Review documentation
  • Fix tab navigation of notifications
  • Add more unit tests

Linked to ovh/ovh-ui-kit#246

const keysRegex = new RegExp([
this.KEYBOARD_KEYS.TAB,
this.KEYBOARD_KEYS.SHIFT
].join("|"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this could be replaced by a templated string

Copy link
Contributor Author

@AxelPeter AxelPeter Jul 24, 2018

Choose a reason for hiding this comment

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

Yes, it could be

const keysRegex = new RegExp(`${this.KEYBOARD_KEYS.TAB}|${this.KEYBOARD_KEYS.SHIFT}`);

but i find this formulation more readable (and more elegant) :)

const tabbableItems = this.navbarCtrl.getGroup(groupName);
const lastIndex = tabbableItems.length - 1;
const focusElement = (e, groupIndex) => {
let index = groupIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if it's the wanted behaviour but groupIndex value will be changed too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean ? With the recursive call ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@marie-j Number are passed by values and not by reference 😄 . Only Objects will be passed by reference.

// Add a delay to force focus
const delay = 50;
this.$timeout(() => {
if (this.keyboardNav && this.keyboardNav[groupName] && this.keyboardNav[groupName][index]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lodash could be used here 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Old code when we did not wanted to integrate lodash in the project.
Good find ;)

@@ -0,0 +1,119 @@
<header class="oui-navbar-menu__header oui-navbar_mobile-only"
ng-if="::!!$ctrl.headerTitle">
<h3 class="oui-navbar-menu__title" ng-bind="::$ctrl.headerTitle"></h3>
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there be a h1 and h2 before ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could even be a <p> or a <span>.
It's not important here :)

</header>
<ul class="oui-navbar-menu__body oui-navbar-list">
<li class="oui-navbar-menu__item oui-navbar-notification"
ng-repeat="menuLink in ::$ctrl.menuLinks | limitTo: $ctrl.limitTo"
Copy link
Contributor

Choose a reason for hiding this comment

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

No track by ?

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'll check to add that

oui-navbar-group-last="::$last && !$ctrl.footerTemplate && !$ctrl.footerTitle">
<div class="oui-navbar-notification__header">
<span class="oui-navbar-notification__title" ng-bind=":: menuLink.subject"></span>
<span class="oui-navbar-notification__time" ng-bind="menuLink.time"></span>
Copy link
Contributor

Choose a reason for hiding this comment

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

No :: on that one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not here, the purpose is to update the time when needed (eg. 26m ago, 2h ago, etc.).

</button>
</li>
<li class="oui-navbar-menu__item oui-navbar-notification oui-navbar-notification-placeholder"
ng-if="$ctrl.menuLinks.length === 0">
Copy link
Contributor

Choose a reason for hiding this comment

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

!$ctrl.menuLinks.length ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not here. It will be triggered if length is undefined, since $ctrl.menuLinks can be nullified.

<div class="oui-navbar-notification-placeholder__title"
ng-bind="$ctrl.translations.notification.noNotification"></div>
<div class="oui-navbar-notification-placeholder__description"
ng-bind="$ctrl.translations.notification.noNotificationDescription"></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

No :: ?

Copy link
Contributor Author

@AxelPeter AxelPeter Jul 24, 2018

Choose a reason for hiding this comment

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

I think JD forgot those ones. Since it's only for placeholder, it could be one-time binded :)

@AxelPeter
Copy link
Contributor Author

@marie-j updated :)

ng-class="::'navbar-' + $ctrl.iconClass">
<span class="oui-icon__badge"
ng-if="!!$ctrl.iconBadge"
ng-bind="$ctrl.iconBadge">
Copy link
Contributor

Choose a reason for hiding this comment

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

:: ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not here. What if the value of the badge is updated ? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is why I was asking a question 😄

const tabbableItems = this.navbarCtrl.getGroup(groupName);
const lastIndex = tabbableItems.length - 1;
const focusElement = (e, groupIndex) => {
let index = groupIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

@marie-j Number are passed by values and not by reference 😄 . Only Objects will be passed by reference.

export default {
ALT: 9,
TAB: 16,
TAB: 9,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be used elsewhere, don't we have a package for this kind of universal code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have to import a package just for 3 values ?


// Return value of "ui-sref"
getFullSref () {
return `${this.state}(${JSON.stringify(this.stateParams)})`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get this piece of code, isn't this.stateParams supposed to be a String ? If it is, maybe you could throw an error if it isn't a String

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, stateParams is an object


addItemToGroup (item, groupName) {
// Create the group if it doesn't exist
if (angular.isUndefined(this.keyboardNav[groupName])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this.keyboardNav[groupName] === undefined ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's the same :)

// Set focus to an item of a group
setFocusTo (groupName, index) {
// Add a delay to force focus
const delay = 50;
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't have another solution but this is 😒 , wouldn't autofocus work ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not the same, we don't want to autofocus on the page load

this.togglerLoaded = !!changes.togglerLinks.currentValue;
}
$onDestroy () {
this.$document
Copy link
Contributor

Choose a reason for hiding this comment

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

We've got listeners on the whole document ? What are they for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keydown for ESC and click to close opened menu :)

@AxelPeter AxelPeter requested a review from antleblanc July 24, 2018 10:59
@ovh-ux ovh-ux deleted a comment from ovh-cds Jul 24, 2018
@ovh-ux ovh-ux deleted a comment from ovh-cds Jul 24, 2018
@AxelPeter AxelPeter force-pushed the feature/upgrade-navbar branch from 5dae062 to d37011a Compare July 24, 2018 14:18
@AxelPeter
Copy link
Contributor Author

I have done a rebase for the conflicts

@ovh-ux ovh-ux deleted a comment from ovh-cds Jul 24, 2018
Copy link
Contributor

@antleblanc antleblanc left a comment

Choose a reason for hiding this comment

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

Nice job @AxelPeter!

Do not forget to squash your commits:)

@AxelPeter
Copy link
Contributor Author

@antleblanc Thanks, I know ;)

@AxelPeter AxelPeter merged commit 15ff949 into develop Jul 25, 2018
@AxelPeter AxelPeter deleted the feature/upgrade-navbar branch July 25, 2018 08:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

4 participants