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

Fix : fixed the broken UI of discord users in mobile view with some UI enhancements. #551

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
--blue-color: #1d1283;
--success-color: green;
--failure-color: #f44336;
--link-color: #4d4dff;
}

body {
Expand Down
18 changes: 17 additions & 1 deletion users/discord/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ const handleTabNavigation = async (e) => {
};

const handleUserSelected = (e) => {
const userDetailsSection = document.querySelector('.user_details_section');
const overlay = document.getElementById('overlay');

if (window.innerWidth < 600) {
overlay.style.display = 'block';
userDetailsSection.style.display = 'block';
document.body.style.overflow = 'hidden';

overlay.addEventListener('click', (event) => {
if (event.target === overlay) {
overlay.style.display = 'none';
userDetailsSection.style.display = 'none';
document.body.style.overflow = 'auto';
}
});
}
Achintya-Chatterjee marked this conversation as resolved.
Show resolved Hide resolved

const selectedUserId =
e.target?.getAttribute('data_key') ||
e.target.parentElement?.getAttribute('data_key');
Expand All @@ -46,7 +63,6 @@ const handleUserSelected = (e) => {
showUser = usersData[activeTab]?.findIndex(
(user) => user.id === selectedUserId,
);
rerender(App(), window['root']);
}
};

Expand Down
2 changes: 1 addition & 1 deletion users/discord/components/TabsSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const TabsSection = ({ tabs, activeTab, handleTabNavigation }) => {
'span',
{
data_key: `${tabItem.id}`,
class: `tab ${activeTab === tabItem.id ? 'active_tab' : ''}`,
class: `tab ${activeTab === tabItem.id ? 'active_tab_link' : ''}`,
},
[tabItem.display_name],
);
Expand Down
61 changes: 36 additions & 25 deletions users/discord/components/UserDetailsSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,46 @@
const { createElement } = react;

export const UserDetailsSection = ({
user: { first_name, username, discordId, discordJoinedAt },
user: { first_name, username, discordId, discordJoinedAt, picture },
}) => {
return createElement('section', { class: 'user_details_section' }, [
createElement('div', { class: 'user_details_field' }, [
createElement('span', {}, ['Name: ']),
createElement('span', {}, [first_name]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', {}, ['Username: ']),
createElement('span', {}, [username]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', {}, ['Discord ID: ']),
createElement('span', {}, [discordId]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', {}, ['Joined RDS server on: ']),
createElement('span', {}, [new Date(discordJoinedAt).toUTCString()]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', {}, ['User Management: ']),
createElement('span', { class: 'profile_pic_container' }, [
createElement(
'a',
{
target: '_bllank',
href: `${USER_MANAGEMENT_URL}${username}`,
},
[`${USER_MANAGEMENT_URL}${username}`],
'img',
{ src: picture?.url ?? dummyPicture },
{ class: 'profile_pic' },
),
]),
createElement('div', { class: 'user_details_container' }, [
createElement('div', { class: 'user_details_field' }, [
createElement('span', { class: 'user_info' }, ['Name : ']),
createElement('span', {}, [first_name]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', { class: 'user_info' }, ['Username : ']),
createElement('span', {}, [username]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', { class: 'user_info' }, ['Discord ID : ']),
createElement('span', {}, [discordId]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', { class: 'user_info' }, [
'Joined RDS server on : ',
]),
createElement('span', {}, [new Date(discordJoinedAt).toUTCString()]),
]),
createElement('div', { class: 'user_details_field' }, [
createElement('span', { class: 'user_info' }, ['User Management : ']),
createElement(
'a',
{
target: '_bllank',
href: `${USER_MANAGEMENT_URL}${username}`,
},
[`${USER_MANAGEMENT_URL}${username}`],
),
]),
]),
Achintya-Chatterjee marked this conversation as resolved.
Show resolved Hide resolved
]);
};
14 changes: 14 additions & 0 deletions users/discord/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@
<title>Discord Users | Real Dev Squad</title>
</head>
<body>
<div class="overlay" id="overlay"></div>
<header class="header">
<h1>Discord Users</h1>
</header>
<div id="root"></div>
<footer>
<p class="info-repo">
The contents of this website are deployed from this
<a
class="info-repo-link"
href="https://github.com/Real-Dev-Squad/website-dashboard"
target="_blank"
rel="noopener noreferrer"
>
Open sourced repo
</a>
</p>
</footer>
</body>
<script src="utils/react.js"></script>
<script src="/constants.js"></script>
Expand Down
129 changes: 125 additions & 4 deletions users/discord/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
--light-gray: #d4d4d478;
}

.overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgb(0 0 0 / 66%);
z-index: 999;
}

.header {
background-color: var(--blue-color);
text-align: center;
Expand All @@ -15,7 +26,7 @@ main {
grid-template-areas:
'tab tab '
'aside details';
height: 100vh;
height: 80vh;
}

.users_section {
Expand All @@ -36,6 +47,12 @@ main {
cursor: pointer;
}

.active_tab_link {
color: var(--blue-color);
font-weight: 600;
border-bottom: 3px solid var(--blue-color);
}

.active_tab {
border: 2px solid gray;
}
Expand All @@ -45,7 +62,7 @@ main {
display: flex;
align-items: center;
gap: 1rem;
margin-block: 0.5rem;
margin-bottom: 10px;
width: 100%;
background-color: var(--light-gray);
cursor: pointer;
Expand All @@ -59,18 +76,122 @@ main {
}

.user_details_section {
grid-area: details;
padding: 1rem;
display: flex;
justify-content: space-evenly;
padding-top: 3rem;
margin: 0 1rem;
background-color: var(--light-gray);
}

.user_details_container {
width: 60%;
overflow-wrap: break-word;
}

.profile_pic_container {
height: 35%;
flex: 0 0 25%;
text-align: center;
}

.profile_pic_container img {
width: 55%;
height: auto;
border-radius: 50%;
}

.user_details_field {
padding: 0.5rem;
}

.user_details_field a {
color: var(--link-color);
}

.user_info {
color: var(--blue-color);
}

.no_user_found {
width: 100vw;
text-align: center;
font-size: larger;
padding: 2rem;
}

/* MEDIA QUERY */

@media only screen and (max-width: 600px) {
main {
display: flex;
flex-direction: column;
align-items: center;
}

.active_tab {
border: none;
}

.users_section {
width: 95%;
}

.user_details_section {
display: none;
background: white;
position: absolute;
top: 20rem;
left: 50%;
transform: translate(-50%, -50%);
margin: auto;
z-index: 1000;
padding: 2rem 0;
border-radius: 1rem;
}

.profile_pic_container {
display: block;
}

.profile_pic_container img {
width: 35%;
margin-bottom: 1rem;
}

.user_details_container {
margin: auto;
width: 80%;
}
}

@media only screen and (max-width: 400px) {
.user_details_section {
width: 90%;
}

.user_details_container {
width: 95%;
}
}

@media only screen and (min-width: 600px) and (max-width: 900px) {
.user_details_section {
flex-direction: column;
align-items: center;
padding-top: 0;
}

.profile_pic_container img {
width: 30%;
}

.user_details_container {
width: 90%;
}
}

@media only screen and (min-width: 900px) and (max-width: 1200px) {
.profile_pic_container img {
width: 80%;
}
}
Loading