add user avatar #14 #15

This commit is contained in:
ghost 2023-09-24 00:18:16 +03:00
parent a600a08a28
commit 8740e7a63f
5 changed files with 63 additions and 2 deletions

View File

@ -19,6 +19,11 @@ class AppControllerModuleProfile
$comments = $this->_user->findUserPageCommentsDistinctTotal();
$editions = $this->_user->findUserPageEditionsDistinctTotal();
$identicon = $this->_user->getIdenticon(24);
$public = $this->_user->getPublic();
$address = $this->_user->getAddress();
include __DIR__ . '../../../view/theme/default/module/profile.phtml';
}
}

View File

@ -100,11 +100,36 @@ class AppControllerUser
exit;
}
public function getIdenticon(int $size)
{
$icon = new Jdenticon\Identicon();
$icon->setValue($this->_user->public ? $this->_user->address : $this->_user->userId);
$icon->setSize($size);
$icon->setStyle(
[
'backgroundColor' => 'rgba(255, 255, 255, 0)',
]
);
return $icon->getImageDataUri('webp');
}
public function getUser()
{
return $this->_user;
}
public function getPublic()
{
return $this->_user->public;
}
public function getAddress()
{
return $this->_user->address;
}
public function findUserPageStarsDistinctTotalByValue(bool $value) : int
{
return $this->_database->findUserPageStarsDistinctTotal(

View File

@ -1,4 +1,11 @@
<div class="position-fixed width-160-px margin-l--176 margin-y-8 padding-y-8 background-color-night border-radius-3">
<div class="margin-y-8 padding-b-8 position-fixed width-160-px margin-l--176 background-color-night border-radius-3">
<div class="padding-8 margin-b-8 border-bottom-default">
<?php if ($public) { ?>
<img class="border-radius-50 border-color-green border-width-2 margin-r-8 vertical-align-middle" src="<?php echo $identicon ?>" alt="identicon" />
<?php } else { ?>
<img class="border-radius-50 border-color-pink border-width-2 margin-r-8 vertical-align-middle" src="<?php echo $identicon ?>" alt="identicon" />
<?php } ?>
</div>
<?php if ($route == '') { ?>
<span class="padding-x-16 padding-y-8 display-block background-color-green cursor-default text-color-white">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-house-door-fill" viewBox="0 0 16 16">

View File

@ -38,6 +38,9 @@ if (!file_exists(__DIR__ . '/env.' . PHP_ENV . '.php'))
// Load environment
require_once __DIR__ . '/env.' . PHP_ENV . '.php';
// Autoload vendors
require_once __DIR__ . '/../../vendor/autoload.php';
// Route
parse_str($_SERVER['QUERY_STRING'], $request);

View File

@ -108,6 +108,10 @@ a.label-green:hover {
position: fixed;
}
.vertical-align-middle {
vertical-align: middle;
}
.top--2 {
top: -2px;
}
@ -124,14 +128,22 @@ a.label-green:hover {
border-radius: 3px;
}
.border-radius-50 {
border-radius: 50%;
}
.border-pink-light {
border: 1px #9b6895 solid;
}
.border-pink {
.border-color-pink {
border: 1px #a44399 solid;
}
.border-color-green {
border: 1px #65916d solid;
}
.border-bottom-pink {
border-bottom: 1px #a44399 solid;
}
@ -148,6 +160,10 @@ a.label-green:hover {
border-top: 1px #5d627d solid;
}
.border-width-2 {
border-width: 2px;
}
.background-color-night {
background-color: #34384f;
}
@ -314,6 +330,11 @@ a:visited.background-color-hover-night-light:hover {
margin-bottom: 8px;
}
.margin-y-16 {
margin-top: 16px;
margin-bottom: 16px;
}
.margin-t-16 {
margin-top: 16px;
}