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

XWIKI 21833 - Provide better controls for editing the profile picture (avatar) #2862

Merged
merged 11 commits into from
Oct 23, 2024

Conversation

tkrieck
Copy link
Contributor

@tkrieck tkrieck commented Feb 7, 2024

Jira URL

https://jira.xwiki.org/browse/XWIKI-21833

Changes

Description

  • Changes the edit photo icon on the profile picture to a link beneath said photo.
  • This was done because:
    • The current icon is a hardcoded reference to a silk icon.
    • The current icon is placed in a way that's difficult to see for new users, as it does not follow the standard icon from the IconTheme.
  • Updated the design of the profile picture to keep it aligned with the profile menu
    • Removed box shadow and paddings

Clarifications

  • I started this work because it is small enough so it could be a nice introduction to contributing code to XWiki.
  • As stated in the description we have hardcoded references to silk icon, I could try to update it to use the IconTheme, however this would need to be changed on the component AttachmentSelector so it's a deeper change.

Screenshots & Video

Before
Screenshot 2024-02-07 at 09 33 46

After
Screenshot 2024-02-07 at 10 43 34

Executed Tests

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    *

…(avatar)

* Removed hardcoded reference to a Silk icon
* Restyled the button to look like a link
* Restyled the CSS on the profile image to clean it up
Comment on lines 663 to 679
.buttonwrapper {
a.button {
background-color: inherit;
background-image: none;
border-color: unset;
border-radius: unset;
border: unset;
color: @link-color;
cursor: pointer;
display: unset;
font-size: @font-size-small;
font-weight: normal;
line-height: unset;
margin: unset;
padding: unset;
text-align: center;
vertical-align: middle;
Copy link
Contributor

@Sereza7 Sereza7 Feb 9, 2024

Choose a reason for hiding this comment

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

This is some LESS code, so you can probably use mixins https://lesscss.org/features/#mixins-feature to simplify this.
.btn; .btn-default;
will probably do the trick :)
See for example

input.button, .buttonwrapper button, .buttonwrapper a {
background-image: none; // XWIKI-7870
.btn;
.btn-primary;
}
.buttonwrapper input.secondary, .buttonwrapper button.secondary, .buttonwrapper a.secondary {
.btn-default;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Forgot to explain it in the first comment, but IMO this is a button (action links very close to buttons semantically), so we should use a button presentation. .btn-default is pretty easy on the eye with the Iceberg color theme.

A lot of 'buttons' in the XWiki UI are not HTML buttons but actually action links on which we put these styles from bootstrap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I tried using this mixin however IMO this causes the button to grab too much attention, that's why I was unsetting a lot of styles back to their defaults. As far as I know, we don't have a "tertiary" button style, have we?

Screenshot 2024-02-13 at 13 56 50

Copy link
Contributor

Choose a reason for hiding this comment

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

No we don't have a tertiary button style.
Even the secondary button style is just the default color scheme ^^'
With this mixing, a nice thing is that you will probably need to unset less properties, and be consistent for all the ones you don't want to reset.
E.g. font-size, line-height, font-weight probably do not need to be unset anymore. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, I will update these styles with the mixin and probably adjust it a little bit. Thanks!

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 updated the styles a little bit using mixins and indeed the CSS is better managed this way. However, in doing so the styles didn't quite fit the photo above it, they seemed a little "sparse" and unintegrated. So I did a few more changes in the styles to keep them contained in a single element. IMO, it looks better while still maintaining the overall look of the theme. What do you think?

I also took some screenshots with different color themes to check them out.

Default Iceberg:
Screenshot 2024-02-14 at 07 56 16

Other themes:
Screenshot 2024-02-14 at 07 56 31
Screenshot 2024-02-14 at 07 56 47
Screenshot 2024-02-14 at 07 57 10
Screenshot 2024-02-14 at 07 57 23
Screenshot 2024-02-14 at 07 59 30

One thing I noticed (but unrelated to this Jira) is that we have quite a few of button styles hurting our consistency, I will open a new Jira for this.

Screenshot 2024-02-14 at 08 06 46

Copy link
Contributor

Choose a reason for hiding this comment

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

So I did a few more changes in the styles to keep them contained in a single element.

Looking great!
Just as a side note, in order to keep two blocks together visually, you can "merge" their boxes by removing top/bottom padding and the border-radius in the right corners. See the styles of the Settings menu just under the picture for example.

One thing I noticed (but unrelated to this Jira) is that we have quite a few of button styles hurting our consistency, I will open a new Jira for this.

Looking forward to more detail about this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just as a side note, in order to keep two blocks together visually, you can "merge" their boxes by removing top/bottom padding and the border-radius in the right corners.

Nice, the results turned out to be better with your suggestion, thanks! I will push them after some more tests with different themes and pictures.

Screenshot 2024-02-14 at 09 42 23 Screenshot 2024-02-14 at 09 42 36 Screenshot 2024-02-14 at 09 42 59

@Sereza7
Copy link
Contributor

Sereza7 commented Feb 9, 2024

Good job!
I pointed out a couple places where you could improve codestyle, but the result looks good 👍


About the PR template, I personally use ##Description for the facts and only put everything related to the thinking process in ##Clarifications.

For your Jira issue, from what I remember it's nice to put an Affected version as soon as you open it (I checked it out and was surprised to see that we don't have a jira best practice about that). For improvements, I usually just put the last release as the Affected version. Here it'd be 16.0.0 :)

Side note: I don't think this PR collides with #2771 , even though it's pretty close.

@tkrieck
Copy link
Contributor Author

tkrieck commented Feb 12, 2024

Good job! I pointed out a couple places where you could improve codestyle, but the result looks good 👍

About the PR template, I personally use ##Description for the facts and only put everything related to the thinking process in ##Clarifications.

For your Jira issue, from what I remember it's nice to put an Affected version as soon as you open it (I checked it out and was surprised to see that we don't have a jira best practice about that). For improvements, I usually just put the last release as the Affected version. Here it'd be 16.0.0 :)

Side note: I don't think this PR collides with #2771 , even though it's pretty close.

Thank you @Sereza7 I will update the PR and Jira.

…(avatar)

* Updated #avatar styles to keep it visually integrated with the button;
* Updated button styles using mixins and a few layout rules to keep alignment;
Comment on lines 673 to 674
width: ~"calc(100% - 0.6em)";
margin: 0 0.3em 0.3em 0.3em;
Copy link
Contributor

Choose a reason for hiding this comment

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

I was afraid that this calc would break responsiveness but apparently it's okay.

Instead of using calc and hard coded values, you can also use display: flex on the parent (.wikilink here) and flex-grow on the a.button . The button will grow to fill the whole line.

See https://css-tricks.com/snippets/css/a-guide-to-flexbox/ , flex is a really powerful tool :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated with 2b2162f

…(avatar)

* Updated avatar and buttons styles
* Updated the button container with flexbox layout instead of using calc()
p {
text-align: center;
}
img{
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add a space here to keep consistency in the codestyle:

put a space between selector and declaration start, ex. "a {}"

from https://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/XhtmlCssCodeStyle/

z-index: 1;
.attachment-picker {
.buttonwrapper {
.wikilink{
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add a space here to keep consistency in the codestyle:

put a space between selector and declaration start, ex. "a {}"

from https://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/XhtmlCssCodeStyle/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, here each rule also need to have a newline between them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, seeing the rest of this file, a lot of rules are not being followed, should I update the rest of the file as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

So, here each rule also need to have a newline between them?

Those are not next to each other but nested so it's not mandatory. As far as I know we usually don't do it for nested rulesets.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, seeing the rest of this file, a lot of rules are not being followed, should I update the rest of the file as well?

From what I remember, it's okay to update codestyle in a file you're already editing.
If you want to do it, go for it, but there's no requirement as long as it's not code you've updated :)

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 adjusted my code with df059ae . I will do it for the rest of the file, but on a separate commit.

#avatar {
p {
text-align: center;
}
Copy link
Contributor

@Sereza7 Sereza7 Feb 14, 2024

Choose a reason for hiding this comment

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

Rulesets that are next to each other should be separated with an empty line. Here, this would mean adding back a line between the p ruleset and the img one :)

Separate adjacent rulesets with an empty line.

From https://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/XhtmlCssCodeStyle/

PS: It's a pretty new rule in the codestyle, so if you notice it's not followed somewhere, you're welcome to propose a fix for the file :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted with df059ae

@tkrieck tkrieck marked this pull request as ready for review February 21, 2024 09:19
width: 18px !important;
z-index: 1;
.attachment-picker {
.buttonwrapper {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an unchanged style rule for .attachment-picker .buttonwrapper right before this one, is it intentional that they are kept separate? Also, I'm wondering a bit if these style rules aren't too general (not really changed by this PR), and won't affect other attachment pickers that could, e.g., be present in the user profile's content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an unchanged style rule for .attachment-picker .buttonwrapper right before this one, is it intentional that they are kept separate? Also, I'm wondering a bit if these style rules aren't too general (not really changed by this PR), and won't affect other attachment pickers that could, e.g., be present in the user profile's content.

It's not intentional, from what I can see there's no reason to not include it in my changed code and remove from the first one. I'll do it.

Regarding the generality of rules, maybe we can add a general prefix to all rules and make them more specific. I will do some tests on this.

Thanks for the feedback.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tkrieck Do you still plan to add these changes to this PR, or shall we merge it without them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tkrieck Do you still plan to add these changes to this PR, or shall we merge it without them?

My bad, I had totally forgotten about this. Addressed this in my last commit 10c083b.

tkrieck and others added 2 commits October 7, 2024 10:03
…(avatar)

- Added an isolation for the .attachment-picker rules to reduce the risk of conflicts
@michitux michitux self-assigned this Oct 22, 2024
@michitux michitux merged commit ca46534 into xwiki:master Oct 23, 2024
1 check passed
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.

3 participants