Skip to content

Commit 663ddfa

Browse files
committed
fixed conflict
2 parents c1a0927 + 24c1232 commit 663ddfa

File tree

11 files changed

+322
-175
lines changed

11 files changed

+322
-175
lines changed

index.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
<!-- <mgt-mock-provider></mgt-mock-provider> -->
3333

3434
<mgt-login></mgt-login>
35-
<mgt-person person-query="me" show-name show-email person-card="hover"></mgt-person>
35+
<mgt-person person-query="me" show-name show-email person-card="click"></mgt-person>
3636
<mgt-people-picker></mgt-people-picker>
37-
<mgt-tasks data-source="todo"></mgt-tasks>
38-
<mgt-agenda group-by-day></mgt-agenda>
39-
<mgt-people></mgt-people>
4037
</body>
4138
</html>

src/components/baseComponent.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8-
import { LitElement } from 'lit-element';
8+
import { LitElement, PropertyValues } from 'lit-element';
99
/**
1010
* BaseComponent extends LitElement including ShadowRoot toggle and fireCustomEvent features
1111
*
@@ -45,7 +45,7 @@ export abstract class MgtBaseComponent extends LitElement {
4545
}
4646

4747
/**
48-
* Recieve ShadowRoot Disabled value
48+
* Receive ShadowRoot Disabled value
4949
*
5050
* @returns boolean _useShadowRoot value
5151
* @memberof MgtBaseComponent
@@ -81,4 +81,22 @@ export abstract class MgtBaseComponent extends LitElement {
8181
protected createRenderRoot() {
8282
return this.isShadowRootDisabled() ? this : super.createRenderRoot();
8383
}
84+
85+
/**
86+
* Invoked whenever the element is updated. Implement to perform
87+
* post-updating tasks via DOM APIs, for example, focusing an element.
88+
*
89+
* Setting properties inside this method will trigger the element to update
90+
* again after this update cycle completes.
91+
*
92+
* * @param changedProperties Map of changed properties with old values
93+
*/
94+
protected updated(changedProperties: PropertyValues) {
95+
super.updated(changedProperties);
96+
const event = new CustomEvent('updated', {
97+
bubbles: true,
98+
cancelable: true
99+
});
100+
this.dispatchEvent(event);
101+
}
84102
}

src/components/mgt-people-picker/mgt-people-picker.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ mgt-people-picker .people-person {
113113
border-radius: 15px;
114114
height: 24px;
115115
white-space: nowrap;
116-
overflow: hidden;
117116
text-overflow: ellipsis;
118117
}
119118

@@ -192,7 +191,6 @@ mgt-people-picker .remove-person-button-secondary {
192191
mgt-people-picker .person-display-name {
193192
max-width: 100px;
194193
white-space: nowrap;
195-
overflow: hidden;
196194
text-overflow: ellipsis;
197195
margin-left: 8px;
198196
font-family: Segoe UI;
@@ -207,6 +205,7 @@ mgt-people-picker .person-display-name {
207205
mgt-person {
208206
--avatar-size-s: 32px;
209207
margin-left: 12px;
208+
cursor: default;
210209
}
211210
.selected-person {
212211
--avatar-size-s: 24px;

src/components/mgt-people-picker/mgt-people-picker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,11 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
415415
${this.selectedPeople.slice(0, this.selectedPeople.length).map(
416416
person =>
417417
html`
418-
<li class="people-person">
418+
<div class="people-person">
419419
${this.renderTemplate('selected-person', { person }, `selected-${person.id}`) ||
420420
this.renderSelectedPerson(person)}
421421
<div class="CloseIcon" @click="${() => this.removePerson(person)}">\uE711</div>
422-
</li>
422+
</div>
423423
`
424424
)}
425425
`;
@@ -561,7 +561,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
561561
.personDetails=${person}
562562
.personImage=${'@'}
563563
show-name
564-
person-card="hover"
564+
person-card="click"
565565
></mgt-person>
566566
`;
567567
}

src/components/mgt-person-card/mgt-person-card.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $color: var(--color, #{$ms-color-neutralDark});
2727

2828
.details {
2929
margin-left: 14px;
30+
line-height: 1.15;
3031

3132
.display-name {
3233
font-size: 27.3103px;
@@ -56,6 +57,7 @@ $color: var(--color, #{$ms-color-neutralDark});
5657

5758
.icon {
5859
margin: 0 22px 0 0;
60+
cursor: pointer;
5961
}
6062
.icon:hover {
6163
opacity: 0.6;
@@ -118,6 +120,7 @@ $color: var(--color, #{$ms-color-neutralDark});
118120
}
119121
.link-subtitle {
120122
color: #3078cd;
123+
cursor: pointer;
121124
}
122125
.link-subtitle:hover {
123126
opacity: 0.6;

src/components/mgt-person/mgt-person.scss

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,6 @@ mgt-person .user-email {
137137
-ms-grid-row: 2;
138138
}
139139

140-
.root .flyout {
141-
display: none;
142-
position: absolute;
143-
z-index: 1;
144-
opacity: 0;
145-
transition-property: opacity;
146-
transition-duration: 0.1s;
140+
.flyout {
147141
padding: 8px;
148142
}
149-
150-
.root .flyout.visible {
151-
display: inline-block;
152-
opacity: 1;
153-
&.openLeft {
154-
right: 0;
155-
}
156-
}

src/components/mgt-person/mgt-person.ts

Lines changed: 45 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
*/
77

88
import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';
9-
import { customElement, html, property, PropertyValues } from 'lit-element';
9+
import { customElement, html, property, PropertyValues, TemplateResult } from 'lit-element';
1010
import { classMap } from 'lit-html/directives/class-map';
11+
import { styleMap } from 'lit-html/directives/style-map';
1112
import { Providers } from '../../Providers';
1213
import { ProviderState } from '../../providers/IProvider';
1314
import '../../styles/fabric-icon-font';
1415
import { getEmailFromGraphEntity } from '../../utils/GraphHelpers';
1516
import { MgtPersonCard } from '../mgt-person-card/mgt-person-card';
17+
import '../sub-components/mgt-flyout/mgt-flyout';
1618
import { MgtTemplatedComponent } from '../templatedComponent';
1719
import { PersonCardInteraction } from './../PersonCardInteraction';
1820
import { styles } from './mgt-person-css';
@@ -116,13 +118,11 @@ export class MgtPerson extends MgtTemplatedComponent {
116118
})
117119
public personCardInteraction: PersonCardInteraction = PersonCardInteraction.none;
118120

119-
@property({ attribute: false }) private _isPersonCardVisible: boolean = false;
120-
@property({ attribute: false }) private _personCardShouldRender: boolean = false;
121+
@property({ attribute: false }) private isPersonCardVisible: boolean = false;
122+
@property({ attribute: false }) private personCardShouldRender: boolean = false;
121123

122124
private _mouseLeaveTimeout;
123125
private _mouseEnterTimeout;
124-
private _openLeft: boolean = false;
125-
private _openUp: boolean = false;
126126

127127
/**
128128
* Synchronizes property values when attributes change.
@@ -174,11 +174,11 @@ export class MgtPerson extends MgtTemplatedComponent {
174174
return html`
175175
<div
176176
class="root"
177-
@mouseenter=${this._handleMouseEnter}
178-
@mouseleave=${this._handleMouseLeave}
179-
@click=${this._handleMouseClick}
177+
@mouseenter=${this.handleMouseEnter}
178+
@mouseleave=${this.handleMouseLeave}
179+
@click=${this.handleMouseClick}
180180
>
181-
${person} ${this.renderPersonCard(image)}
181+
${this.renderFlyout(person)}
182182
</div>
183183
`;
184184
}
@@ -288,40 +288,41 @@ export class MgtPerson extends MgtTemplatedComponent {
288288
this.requestUpdate();
289289
}
290290

291-
private _handleMouseClick() {
292-
if (this.personCardInteraction === PersonCardInteraction.click && !this._isPersonCardVisible) {
293-
this._showPersonCard();
291+
private handleMouseClick() {
292+
if (this.personCardInteraction === PersonCardInteraction.click && !this.isPersonCardVisible) {
293+
this.showPersonCard();
294294
} else {
295-
this._hidePersonCard();
295+
this.hidePersonCard();
296296
}
297297
}
298298

299-
private _handleMouseEnter(e: MouseEvent) {
299+
private handleMouseEnter(e: MouseEvent) {
300300
clearTimeout(this._mouseEnterTimeout);
301301
clearTimeout(this._mouseLeaveTimeout);
302302
if (this.personCardInteraction !== PersonCardInteraction.hover) {
303303
return;
304304
}
305-
this._mouseEnterTimeout = setTimeout(this._showPersonCard.bind(this), 500);
305+
this._mouseEnterTimeout = setTimeout(this.showPersonCard.bind(this), 500);
306306
}
307307

308-
private _handleMouseLeave(e: MouseEvent) {
308+
private handleMouseLeave(e: MouseEvent) {
309309
clearTimeout(this._mouseEnterTimeout);
310310
clearTimeout(this._mouseLeaveTimeout);
311-
this._mouseLeaveTimeout = setTimeout(this._hidePersonCard.bind(this), 500);
311+
this._mouseLeaveTimeout = setTimeout(this.hidePersonCard.bind(this), 500);
312312
}
313313

314-
private _showPersonCard() {
315-
if (!this._personCardShouldRender) {
316-
this._personCardShouldRender = true;
314+
private showPersonCard() {
315+
if (!this.personCardShouldRender) {
316+
this.personCardShouldRender = true;
317317
}
318318

319-
this._isPersonCardVisible = true;
319+
this.isPersonCardVisible = true;
320320
}
321321

322-
private _hidePersonCard() {
323-
this._isPersonCardVisible = false;
324-
const personCard = this.querySelector('mgt-person-card') as MgtPersonCard;
322+
private hidePersonCard() {
323+
this.isPersonCardVisible = false;
324+
const personCard = (this.querySelector('mgt-person-card') ||
325+
this.renderRoot.querySelector('mgt-person-card')) as MgtPersonCard;
325326
if (personCard) {
326327
personCard.isExpanded = false;
327328
}
@@ -336,44 +337,28 @@ export class MgtPerson extends MgtTemplatedComponent {
336337
return null;
337338
}
338339

339-
private renderPersonCard(image: string) {
340-
// ensure person card is only rendered when needed
341-
if (this.personCardInteraction === PersonCardInteraction.none || !this._personCardShouldRender) {
342-
return;
343-
}
344-
// logic for rendering left if there is no space
345-
const personRect = this.renderRoot.querySelector('.root').getBoundingClientRect();
346-
const leftEdge = personRect.left;
347-
const rightEdge = (window.innerWidth || document.documentElement.clientWidth) - personRect.right;
348-
this._openLeft = rightEdge < leftEdge;
349-
350-
// logic for rendering up
351-
const bottomEdge = (window.innerHeight || document.documentElement.clientHeight) - personRect.bottom;
352-
this._openUp = bottomEdge < 175;
353-
354-
// find position to renderup to
355-
let customStyle = null;
356-
if (this._openUp) {
357-
const personSize = this.getBoundingClientRect().bottom - this.getBoundingClientRect().top;
358-
customStyle = `bottom: ${personSize / 2 + 8}px`;
340+
private renderFlyout(anchor: TemplateResult) {
341+
if (this.personCardInteraction === PersonCardInteraction.none) {
342+
return anchor;
359343
}
360344

361-
const flyoutClasses = {
362-
flyout: true,
363-
openLeft: this._openLeft,
364-
openUp: this._openUp,
365-
visible: this._isPersonCardVisible
366-
};
367-
if (this._isPersonCardVisible) {
368-
return html`
369-
<div style="${customStyle}" class=${classMap(flyoutClasses)}>
370-
${this.renderTemplate('person-card', { person: this.personDetails, personImage: image }) ||
371-
html`
372-
<mgt-person-card .personDetails=${this.personDetails} .personImage=${image}> </mgt-person-card>
373-
`}
374-
</div>
375-
`;
376-
}
345+
const image = this.getImage();
346+
const flyout = this.personCardShouldRender
347+
? html`
348+
<div slot="flyout" class="flyout">
349+
${this.renderTemplate('person-card', { person: this.personDetails, personImage: image }) ||
350+
html`
351+
<mgt-person-card .personDetails=${this.personDetails} .personImage=${image}> </mgt-person-card>
352+
`}
353+
</div>
354+
`
355+
: null;
356+
357+
return html`
358+
<mgt-flyout .isOpen=${this.isPersonCardVisible}>
359+
${anchor} ${flyout}
360+
</mgt-flyout>
361+
`;
377362
}
378363

379364
private renderDetails() {

src/components/mgt-tasks/mgt-tasks.scss

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,16 @@ mgt-tasks,
198198
}
199199
.Picker {
200200
background-color: white;
201-
display: block;
202-
position: absolute;
203201
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
204202
-webkit-background-clip: padding-box;
205203
-moz-background-clip: padding-box;
206204
background-clip: padding-box;
207-
width: 450px;
205+
width: 350px;
208206
color: var(--task-detail-color, black);
209-
z-index: 1;
207+
margin: 8px;
210208
mgt-people-picker {
211209
--separator-margin: 0px 10px 0px 10px;
212210
}
213-
&.Hidden {
214-
display: none;
215-
}
216211
}
217212

218213
input,

0 commit comments

Comments
 (0)