Skip to content

Commit

Permalink
feat(core): ✨ display real name in user menu when exists
Browse files Browse the repository at this point in the history
Closes: #652
Co-authored-by: SimonTaurus <simon.stier@gmx.de>
  • Loading branch information
alistair3149 and simontaurus committed Jun 10, 2023
1 parent 82539eb commit 717d16a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
17 changes: 16 additions & 1 deletion includes/Partials/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,22 @@ public function getUserInfoData( $userPageData ): array {
*/
private function getUserPageHTML( $isRegistered, $userPageData ): ?string {
if ( $isRegistered ) {
$html = $userPageData['html-items'];
$realname = $this->user->getRealName();
if ( !empty( $realname ) ) {
$username = $this->user->getName();
$innerHtml = <<<HTML
<div id="pt-userpage-realname">$realname</div>
<div id="pt-userpage-username">$username</div>
HTML;
// Dirty but it works
$html = str_replace(
">" . $username . "<",
">" . $innerHtml . "<",
$userPageData['html-items']
);
} else {
$html = $userPageData['html-items'];
}
} else {
// There must be a cleaner way to do this
$msg = $this->skin->msg( 'notloggedin' )->text();
Expand Down
10 changes: 10 additions & 0 deletions resources/skins.citizen.styles/components/Usermenu.less
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@
}
}

&page {
&-username {
margin-top: var( --space-xxs );
margin-bottom: var( --space-sm );
color: var( --color-base--subtle );
font-size: 0.8125rem;
font-weight: var( --font-weight-normal );
}
}

&contris {
font-weight: var( --font-weight-medium );
}
Expand Down

0 comments on commit 717d16a

Please sign in to comment.