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

fix: add detail-line part attribute to person component #2999

Merged
merged 10 commits into from
Feb 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('mgt-person - tests', () => {
<img alt="Photo for Megan Bowen" src="">
</div>
<div class=" details-wrapper ">
<div class="line1" role="presentation" aria-label="Megan Bowen">Megan Bowen</div>
<div class="line2" role="presentation" aria-label="Auditor">Auditor</div>
<div class="line1" part="detail-line" role="presentation" aria-label="Megan Bowen">Megan Bowen</div>
<div class="line2" part="detail-line" role="presentation" aria-label="Auditor">Auditor</div>
</div>
</div>`,
{ ignoreAttributes: ['src'] }
Expand All @@ -46,13 +46,15 @@ describe('mgt-person - tests', () => {
<div
aria-label="Megan Bowen"
class="line1"
part="detail-line"
role="presentation"
>
Megan Bowen
</div>
<div
aria-label="Auditor"
class="line2"
part="detail-line"
role="presentation"
>
Auditor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,14 +869,14 @@ export class MgtPerson extends MgtTemplatedTaskComponent {
// Render the line1 template
const template = this.renderTemplate('line1', { person });
details.push(html`
<div class="line1" @click=${() =>
<div class="line1" part="detail-line" @click=${() =>
this.handleLine1Clicked()} role="presentation" aria-label="${line1text}">${template}</div>
`);
} else {
// Render the line1 property value
if (line1text) {
details.push(html`
<div class="line1" @click=${() =>
<div class="line1" part="detail-line" @click=${() =>
this.handleLine1Clicked()} role="presentation" aria-label="${line1text}">${line1text}</div>
`);
}
Expand All @@ -889,14 +889,14 @@ export class MgtPerson extends MgtTemplatedTaskComponent {
// Render the line2 template
const template = this.renderTemplate('line2', { person });
details.push(html`
<div class="line2" @click=${() =>
<div class="line2" part="detail-line" @click=${() =>
this.handleLine2Clicked()} role="presentation" aria-label="${text}">${template}</div>
`);
} else {
// Render the line2 property value
if (text) {
details.push(html`
<div class="line2" @click=${() =>
<div class="line2" part="detail-line" @click=${() =>
this.handleLine2Clicked()} role="presentation" aria-label="${text}">${text}</div>
`);
}
Expand All @@ -910,14 +910,14 @@ export class MgtPerson extends MgtTemplatedTaskComponent {
// Render the line3 template
const template = this.renderTemplate('line3', { person });
details.push(html`
<div class="line3" @click=${() =>
<div class="line3" part="detail-line" @click=${() =>
this.handleLine3Clicked()} role="presentation" aria-label="${text}">${template}</div>
`);
} else {
// Render the line3 property value
if (text) {
details.push(html`
<div class="line3" @click=${() =>
<div class="line3" part="detail-line" @click=${() =>
this.handleLine3Clicked()} role="presentation" aria-label="${text}">${text}</div>
`);
}
Expand All @@ -931,14 +931,14 @@ export class MgtPerson extends MgtTemplatedTaskComponent {
// Render the line4 template
const template = this.renderTemplate('line4', { person });
details.push(html`
<div class="line4" @click=${() =>
<div class="line4" part="detail-line" @click=${() =>
this.handleLine4Clicked()} role="presentation" aria-label="${text}">${template}</div>
`);
} else {
// Render the line4 property value
if (text) {
details.push(html`
<div class="line4" @click=${() =>
<div class="line4" part="detail-line" @click=${() =>
this.handleLine4Clicked()} role="presentation" aria-label="${text}">${text}</div>
`);
}
Expand Down
18 changes: 18 additions & 0 deletions stories/components/person/person.style.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,21 @@ export const customCSSProperties = () => html`
<mgt-person class="person" vertical-layout person-query="me" view="fourlines" avatar-type="initials" id="dnd"
show-presence></mgt-person>
`;

export const personDetailPart = () => html`
<style>
mgt-person::part(detail-line) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: var(--person-details-wrapper-width)
}

mgt-person {
--person-details-wrapper-width: 150px;
}
</style>

<mgt-person person-query="me" view="threelines" line3-property="email"></mgt-person>

`;
Loading