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: add capability in FluentPersona for the name to appear before or after initials. #1750

Merged
merged 8 commits into from
Mar 30, 2024

Conversation

subratb
Copy link
Contributor

@subratb subratb commented Mar 27, 2024

Pull Request

πŸ“– Description

feat: add capability in FluentPersona for the name to appear before or after initials.

🎫 Issues

#1735

πŸ‘©β€πŸ’» Reviewer Notes

Unit test was updated to test the change. Demo application FluentPersona section was also updated with example.

πŸ“‘ Test Plan

A new unit test was added.

βœ… Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Sorry, something went wrong.

Subrat Bisoyi added 2 commits March 27, 2024 12:36

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…r after initials
… dev
@vnbaaij
Copy link
Collaborator

vnbaaij commented Mar 27, 2024

Hi,

Thanks for contributing. One thing though...for this functionality I think it is better to use 'Start' and 'End' instead of 'Left' and 'Right' because we also support RTL layouts with these components.
In the config you have added now, if you set the initials to left and use RTL, they would actualy be on the right.

@if (OnDismissClick.HasDelegate)
{
<div class="close">
<FluentIcon Value="@(new CoreIcons.Regular.Size24.Dismiss())" Width="12px" Title="@DismissTitle" OnClick="OnDismissClick" />
<FluentIcon Value="@(new CoreIcons.Regular.Size24.Dismiss())" Width="12px" Title="@DismissTitle" OnClick="OnDismissClick"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, don't remove this space.

/// Gets or sets the position of the image.
/// </summary>
[Parameter]
public PersonaImagePosition? ImagePosition { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be more logical to follow the "same philosophy" used by React:
by calling the new attribute TextPosition.

https://react.fluentui.dev/?path=/docs/components-persona--default#text-alignment

/// <summary>
/// The tooltip is positioned to the left of the anchor element.
/// </summary>
Left,
Copy link
Collaborator

Choose a reason for hiding this comment

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

As in my previous comment, and to follow Vincent's logic, it's probably better to use the names Before and After.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We use start/end throughout the library (icon slots, alignment, ...) so I would stick with that. Don't recall we use before/after anywhere

/// Gets or sets the position of the image.
/// </summary>
[Parameter]
public PersonaImagePosition? ImagePosition { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wouldn't put a nullable property, but with a default value of "Right/After".

Copy link
Collaborator

Choose a reason for hiding this comment

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

End πŸ˜‰

</div>
</FluentPresenceBadge>
</div>
@if (!ImagePosition.HasValue || ImagePosition == PersonaImagePosition.Left)
Copy link
Collaborator

Choose a reason for hiding this comment

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

To avoid duplicating code in this file (depending on the value of ImagePosition), you could use CSS like this, based on a new position attribute to be defined on the div "main".

<div id="@Id" class="@ClassValue" position="@ImagePosition.ToAttributeValue()" ...
.fluent-persona[position='before'] .name {
    order: 1;
    margin-inline-end: 16px;
}

.fluent-persona[position='before'] .close {
    order: 2;
}

.fluent-persona[position='before'] .initials {
    order: 3;
}

What do you think? Possible (to be verified if no side effects are detected).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. It is cleaner. We might have to revisit this if the goal is feature-parity with fluentui react.

subratb and others added 4 commits March 28, 2024 08:26
…r after initials. Code review feedback completed.
@subratb
Copy link
Contributor Author

subratb commented Mar 30, 2024

@microsoft-github-policy-service agree

@vnbaaij vnbaaij merged commit 0e07edf into microsoft:dev Mar 30, 2024
3 checks passed
@@ -62,4 +62,11 @@

</ItemGroup>

<ItemGroup>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove these new lines. Not required in this csproj.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sent #1769.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants