Skip to content

Commit

Permalink
fix: add spaces to presence hover text in mgt-person (#2693)
Browse files Browse the repository at this point in the history
* fix: add spaces to presence hover text

* use localized strings to map availability

* add all supported presence states

* use sentence-casing

* map activity to presence rather than availability

* remove iteration, use the nullish coalescing operator

Co-authored-by: Gavin Barron <gavinbarron@microsoft.com>

* update lit imports, remove unused util function

---------

Co-authored-by: Gavin Barron <gavinbarron@microsoft.com>
  • Loading branch information
Mnickii and gavinbarron authored Sep 20, 2023
1 parent ba381c8 commit f50e6ab
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
22 changes: 19 additions & 3 deletions packages/mgt-components/src/components/mgt-person/mgt-person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
mgtHtml
} from '@microsoft/mgt-element';
import { Contact, Presence } from '@microsoft/microsoft-graph-types';
import { html, TemplateResult } from 'lit';
import { html, TemplateResult, nothing } from 'lit';
import { property, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { findPeople, getEmailFromGraphEntity } from '../../graph/graph.people';
Expand Down Expand Up @@ -753,6 +753,7 @@ export class MgtPerson extends MgtTemplatedComponent {
const { activity, availability } = presence;
switch (availability) {
case 'Available':
case 'AvailableIdle':
switch (activity) {
case 'OutOfOffice':
presenceIcon = getSvg(SvgIcon.PresenceOofAvailable);
Expand All @@ -765,6 +766,7 @@ export class MgtPerson extends MgtTemplatedComponent {
}
break;
case 'Busy':
case 'BusyIdle':
switch (activity) {
case 'OutOfOffice':
case 'OnACall':
Expand All @@ -785,6 +787,9 @@ export class MgtPerson extends MgtTemplatedComponent {
case 'OutOfOffice':
presenceIcon = getSvg(SvgIcon.PresenceOofDnd);
break;
case 'Presenting':
case 'Focusing':
case 'UrgentInterruptionsOnly':
default:
presenceIcon = getSvg(SvgIcon.PresenceDnd);
break;
Expand All @@ -796,6 +801,14 @@ export class MgtPerson extends MgtTemplatedComponent {
case 'OutOfOffice':
presenceIcon = getSvg(SvgIcon.PresenceOofAway);
break;
case 'AwayLastSeenTime':
default:
presenceIcon = getSvg(SvgIcon.PresenceAway);
break;
}
break;
case 'BeRightBack':
switch (activity) {
default:
presenceIcon = getSvg(SvgIcon.PresenceAway);
break;
Expand All @@ -807,6 +820,7 @@ export class MgtPerson extends MgtTemplatedComponent {
presenceIcon = getSvg(SvgIcon.PresenceOffline);
break;
case 'OutOfOffice':
case 'OffWork':
presenceIcon = getSvg(SvgIcon.PresenceOofAway);
break;
default:
Expand All @@ -825,11 +839,13 @@ export class MgtPerson extends MgtTemplatedComponent {
oneline: this.isOneLine()
});

const formattedActivity = (this.strings[activity] as string) ?? nothing;

return html`
<span
class="${presenceWrapperClasses}"
title="${availability}"
aria-label="${availability}"
title="${formattedActivity}"
aria-label="${formattedActivity}"
role="img">
${presenceIcon}
</span>
Expand Down
31 changes: 31 additions & 0 deletions packages/mgt-components/src/components/mgt-person/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,38 @@
* -------------------------------------------------------------------------------------------
*/

const availabilityMap = {
Available: 'Available',
Away: 'Away',
Busy: 'Busy',
DoNotDisturb: 'Do not disturb',
Offline: 'Offline',
BeRightBack: 'Be right back',
PresenceUnknown: 'Presence unknown',
AvailableIdle: 'Available idle',
BusyIdle: 'Busy idle'
};

const activityMap = {
Available: 'Available',
Away: 'Away',
BeRightBack: 'Be right back',
Busy: 'Busy',
DoNotDisturb: 'Do not disturb',
InACall: 'In a call',
InAConferenceCall: 'In a conference call',
Inactive: 'Inactive',
InAMeeting: 'In a meeting',
Offline: 'Offline',
OffWork: 'Off work',
OutOfOffice: 'Out of office',
PresenceUnknown: 'Presence unknown',
Presenting: 'Presenting',
UrgentInterruptionsOnly: 'Urgent interruptions only'
};

export const strings = {
...activityMap,
photoFor: 'Photo for',
emailAddress: 'Email address',
initials: 'Initials'
Expand Down

0 comments on commit f50e6ab

Please sign in to comment.