From adc545a0cb55836c92f8e7e31153584c219767aa Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 5 Apr 2024 13:46:33 -0400 Subject: [PATCH] user menu --- src/public/css/common.css | 28 +++++++++++++++++-- src/web/_views/header.php | 45 +++++++++++++++++++++++++++++- src/web/core/_controller.php | 5 ++++ src/web/helper/image.php | 15 +++++++--- src/web/lang/en_US/common_lang.php | 14 ++++++++++ 5 files changed, 100 insertions(+), 7 deletions(-) diff --git a/src/public/css/common.css b/src/public/css/common.css index 3e6b6b6..de9dedb 100644 --- a/src/public/css/common.css +++ b/src/public/css/common.css @@ -446,8 +446,8 @@ input.btn:focus { @keyframes slideIn { 0% { - animation-timing-function: ease-out; - transform: translate(0, -50%); + animation-timing-function: ease-in; + transform: translate(0, -20%); } } @@ -621,3 +621,27 @@ input[type=radio] { .grow { flex-grow: 1; } + +#user-menu { + position: fixed; + right: .5rem; + top: 4rem; + min-width: fit-content; + animation: fadeIn .1s, slideIn .1s linear; +} + +#user-menu .btn { + width: 100%; +} + +#user-menu-header { + align-items: center; +} + +#user-menu-header .pfp { + margin-right: 1rem; +} + +.hidden { + display: none; +} diff --git a/src/web/_views/header.php b/src/web/_views/header.php index f1aef01..71607d5 100644 --- a/src/web/_views/header.php +++ b/src/web/_views/header.php @@ -46,7 +46,39 @@ menu - + + + @@ -58,3 +90,14 @@ }); + diff --git a/src/web/core/_controller.php b/src/web/core/_controller.php index 4a788d3..3502ea5 100644 --- a/src/web/core/_controller.php +++ b/src/web/core/_controller.php @@ -10,6 +10,9 @@ abstract class Controller { // the database public $db; + // the format model + protected $format_model; + /** * Creates a constructor * @param Loader $load - the website loaded object @@ -26,6 +29,8 @@ abstract class Controller { if ($app) { $this->load->app_lang($lang, $app); } + + $this->format_model = $this->load->model('format'); } public function index() {} diff --git a/src/web/helper/image.php b/src/web/helper/image.php index ac2f808..8815a6c 100644 --- a/src/web/helper/image.php +++ b/src/web/helper/image.php @@ -1,6 +1,6 @@ '; + } else if ($click) { + $content .= ''; } else { $content .= ''; } @@ -26,8 +30,11 @@ function image($src, $class = NULL, $link = NULL): string { function pfp( $user, - $embedLink = TRUE, + $link = TRUE, + $click = NULL ): string { - $link = $embedLink ? '/profile?id=' . $user['id'] : NULL; - return image('/api/rpc/profile_avatar?user_id=' . $user['id'], 'pfp', link: $link); + if ($link === TRUE) { + $link = '/profile?id=' . $user['id']; + } + return image('/api/rpc/profile_avatar?user_id=' . $user['id'], 'pfp', link: $link, click: $click); } diff --git a/src/web/lang/en_US/common_lang.php b/src/web/lang/en_US/common_lang.php index eb60888..e8a88e4 100644 --- a/src/web/lang/en_US/common_lang.php +++ b/src/web/lang/en_US/common_lang.php @@ -44,6 +44,20 @@ $lang['new_post_modal_title'] = 'Author New Post'; $lang['action_new_post_text'] = 'What\'s on your mind, %s'; $lang['action_new_post_tip'] = 'Author a new post.'; +// User Menu +$lang['action_logout_text'] = 'Logout'; +$lang['action_logout_tip'] = 'Logout'; +$lang['action_logout_icon'] = 'mi mi-sm'; +$lang['action_logout_content'] = 'logout'; +$lang['action_settings_text'] = 'Settings'; +$lang['action_settings_tip'] = 'Edit account settings'; +$lang['action_settings_icon'] = 'mi mi-sm'; +$lang['action_settings_content'] = 'settings'; +$lang['action_profile_text'] = 'Profile'; +$lang['action_profile_tip'] = 'View your profile'; +$lang['action_profile_icon'] = 'mi mi-sm'; +$lang['action_profile_content'] = 'account_circle'; + // Words $lang['now'] = 'Now'; $lang['likes'] = 'Likes';