diff --git a/__tests__/users/App.test.js b/__tests__/users/App.test.js index 44156922..7d27f03b 100644 --- a/__tests__/users/App.test.js +++ b/__tests__/users/App.test.js @@ -86,4 +86,65 @@ describe('App Component', () => { const url = await page.url(); expect(url).toContain('?tab=verified'); }); + + it('should not display user details section initially when window width is less than 600 pixels', async () => { + await page.setViewport({ width: 599, height: 768 }); + + await page.waitForSelector('.user_details_section'); + + const userDetailsSection = await page.$('.user_details_section'); + const overlay = await page.$('#overlay'); + + const userDetailsSectionStyle = await page.evaluate((element) => { + return getComputedStyle(element).display; + }, userDetailsSection); + + const overlayStyle = await page.evaluate((element) => { + return getComputedStyle(element).display; + }, overlay); + + expect(overlayStyle).toBe('none'); + expect(userDetailsSectionStyle).toBe('none'); + }); + + it('should display user details section when clicking on user_card', async () => { + await page.setViewport({ width: 599, height: 768 }); + + await page.click('.user_card'); + + const userDetailsSection = await page.$('.user_details_section'); + const overlay = await page.$('#overlay'); + + const userDetailsSectionStyle = await page.evaluate((element) => { + return getComputedStyle(element).display; + }, userDetailsSection); + + const overlayStyle = await page.evaluate((element) => { + return getComputedStyle(element).display; + }, overlay); + + expect(overlayStyle).toBe('block'); + expect(userDetailsSectionStyle).toBe('block'); + }); + + it('should hide user details section when clicking on the overlay', async () => { + await page.setViewport({ width: 599, height: 768 }); + + const userDetailsSection = await page.$('.user_details_section'); + const overlay = await page.$('#overlay'); + + expect(overlay).toBeDefined(); + await page.click('#overlay', { offset: { x: 10, y: 10 } }); + + const userDetailsSectionStyle = await page.evaluate((element) => { + return getComputedStyle(element).display; + }, userDetailsSection); + + const overlayStyle = await page.evaluate((element) => { + return getComputedStyle(element).display; + }, overlay); + + expect(userDetailsSectionStyle).toBe('none'); + expect(overlayStyle).toBe('none'); + }); }); diff --git a/style.css b/style.css index 05fc9e90..b3f61e1c 100644 --- a/style.css +++ b/style.css @@ -12,6 +12,7 @@ --failure-color: #f44336; --lightblue-color: #0d6efd; --lightgray-color: #d7d6d6; + --link-color: #4d4dff; } body { diff --git a/users/discord/App.js b/users/discord/App.js index 87fa873d..46c049f6 100644 --- a/users/discord/App.js +++ b/users/discord/App.js @@ -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'; + } + }); + } + const selectedUserId = e.target?.getAttribute('data_key') || e.target.parentElement?.getAttribute('data_key'); @@ -46,7 +63,6 @@ const handleUserSelected = (e) => { showUser = usersData[activeTab]?.findIndex( (user) => user.id === selectedUserId, ); - rerender(App(), window['root']); } }; diff --git a/users/discord/components/TabsSection.js b/users/discord/components/TabsSection.js index 15c69408..bdaf5298 100644 --- a/users/discord/components/TabsSection.js +++ b/users/discord/components/TabsSection.js @@ -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], ); diff --git a/users/discord/components/UserDetailsSection.js b/users/discord/components/UserDetailsSection.js index 419d3ee5..82f276a9 100644 --- a/users/discord/components/UserDetailsSection.js +++ b/users/discord/components/UserDetailsSection.js @@ -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: '_blank', + href: `${USER_MANAGEMENT_URL}${username}`, + }, + [`${USER_MANAGEMENT_URL}${username}`], + ), + ]), + ]), ]); }; diff --git a/users/discord/index.html b/users/discord/index.html index 3b9f7ac7..02c49834 100644 --- a/users/discord/index.html +++ b/users/discord/index.html @@ -9,10 +9,24 @@