Skip to content

Commit

Permalink
add user avatar #14 #15
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Sep 23, 2023
1 parent a600a08 commit 8740e7a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/app/controller/module/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function render()
$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';
}
}
25 changes: 25 additions & 0 deletions src/app/controller/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,36 @@ private function _response(string $title, string $h1, string $text, int $code =
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(
Expand Down
9 changes: 8 additions & 1 deletion src/app/view/theme/default/module/profile.phtml
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
3 changes: 3 additions & 0 deletions src/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
// Load environment
require_once __DIR__ . '/env.' . PHP_ENV . '.php';

// Autoload vendors
require_once __DIR__ . '/../../vendor/autoload.php';

// Route
parse_str($_SERVER['QUERY_STRING'], $request);

Expand Down
23 changes: 22 additions & 1 deletion src/public/assets/theme/default/css/framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ a.label-green:hover {
position: fixed;
}

.vertical-align-middle {
vertical-align: middle;
}

.top--2 {
top: -2px;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8740e7a

Please sign in to comment.