-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Updated TextContainer styles for better UX and responsive design #166
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
Open
Tanvichovatiya
wants to merge
2
commits into
adrianhajdin:master
Choose a base branch
from
Tanvichovatiya:Textcontainet-css
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,107 @@ | ||
| /* =========================== | ||
| TextContainer Styles | ||
| Updated for better clarity, | ||
| modern look, and accessibility | ||
| =========================== */ | ||
|
|
||
| .textContainer { | ||
| display: flex; | ||
| flex-direction: column; | ||
| margin-left: 100px; | ||
| color: white; | ||
| height: 60%; | ||
| justify-content: space-between; | ||
| justify-content: flex-start; | ||
| align-items: center; | ||
| padding: 1rem; | ||
| font-family: 'Arial', sans-serif; | ||
| color: #333; | ||
| text-align: center; | ||
| background-color: #fafafa; | ||
| border-radius: 8px; | ||
| box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05); | ||
| } | ||
|
|
||
| /* Intro Section */ | ||
| .intro h1 { | ||
| font-size: 2rem; | ||
| font-weight: 600; | ||
| margin-bottom: 0.5rem; | ||
| color: #111; | ||
| } | ||
|
|
||
| .intro h2 { | ||
| font-size: 1.1rem; | ||
| margin-bottom: 0.5rem; | ||
| color: #555; | ||
| } | ||
|
|
||
| /* Users Section */ | ||
| .usersSection { | ||
| margin-top: 2rem; | ||
| width: 100%; | ||
| max-width: 320px; | ||
| } | ||
|
|
||
| /* Active User List Container */ | ||
| .activeContainer { | ||
| display: flex; | ||
| align-items: center; | ||
| margin-bottom: 50%; | ||
| flex-direction: column; | ||
| gap: 0.6rem; | ||
| max-height: 220px; | ||
| overflow-y: auto; | ||
| padding: 0.7rem; | ||
| border: 1px solid #e2e2e2; | ||
| border-radius: 0.6rem; | ||
| background-color: #ffffff; | ||
| scrollbar-width: thin; | ||
| scrollbar-color: #ccc transparent; | ||
| } | ||
|
|
||
| /* Scrollbar Styling for WebKit browsers */ | ||
| .activeContainer::-webkit-scrollbar { | ||
| width: 6px; | ||
| } | ||
| .activeContainer::-webkit-scrollbar-thumb { | ||
| background-color: #ccc; | ||
| border-radius: 3px; | ||
| } | ||
|
|
||
| /* Individual Active Item */ | ||
| .activeItem { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 0.6rem; | ||
| padding: 0.4rem 0.6rem; | ||
| border-radius: 0.4rem; | ||
| transition: background-color 0.2s ease, transform 0.1s ease; | ||
| cursor: default; | ||
| } | ||
|
|
||
| .activeItem:hover { | ||
| background-color: #e6f7ff; | ||
| transform: scale(1.02); | ||
| } | ||
|
|
||
| .activeContainer img { | ||
| padding-left: 10px; | ||
| /* Online Icon */ | ||
| .onlineIcon { | ||
| width: 16px; | ||
| height: 16px; | ||
| } | ||
|
|
||
| .textContainer h1 { | ||
| margin-bottom: 0px; | ||
| /* Username Text */ | ||
| .username { | ||
| font-weight: 500; | ||
| color: #222; | ||
| } | ||
|
|
||
| @media (min-width: 320px) and (max-width: 1200px) { | ||
| .textContainer { | ||
| display: none; | ||
| /* Responsive Design */ | ||
| @media (max-width: 480px) { | ||
| .intro h1 { | ||
| font-size: 1.6rem; | ||
| } | ||
| } | ||
|
|
||
| .usersSection { | ||
| max-width: 90%; | ||
| } | ||
|
|
||
| .activeContainer { | ||
| max-height: 180px; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,35 @@ | ||
| import React from 'react'; | ||
|
|
||
| import onlineIcon from '../../icons/onlineIcon.png'; | ||
|
|
||
| import './TextContainer.css'; | ||
|
|
||
| const TextContainer = ({ users }) => ( | ||
| <div className="textContainer"> | ||
| <div> | ||
| <h1>Realtime Chat Application <span role="img" aria-label="emoji">💬</span></h1> | ||
| <h2>Created with React, Express, Node and Socket.IO <span role="img" aria-label="emoji">❤️</span></h2> | ||
| <h2>Try it out right now! <span role="img" aria-label="emoji">⬅️</span></h2> | ||
| <div className="intro"> | ||
| <h1> | ||
| Realtime Chat Application <span role="img" aria-label="chat">💬</span> | ||
| </h1> | ||
| <h2> | ||
| Created with React, Express, Node and Socket.IO <span role="img" aria-label="heart">❤️</span> | ||
| </h2> | ||
| <h2> | ||
| Try it out right now! <span role="img" aria-label="arrow">⬅️</span> | ||
| </h2> | ||
| </div> | ||
| { | ||
| users | ||
| ? ( | ||
| <div> | ||
| <h1>People currently chatting:</h1> | ||
| <div className="activeContainer"> | ||
| <h2> | ||
| {users.map(({name}) => ( | ||
| <div key={name} className="activeItem"> | ||
| {name} | ||
| <img alt="Online Icon" src={onlineIcon}/> | ||
| </div> | ||
| ))} | ||
| </h2> | ||
|
|
||
| {users && users.length > 0 && ( | ||
| <div className="usersSection"> | ||
| <h1>People currently chatting:</h1> | ||
| <div className="activeContainer"> | ||
| {users.map(({ name }) => ( | ||
| <div key={name} className="activeItem"> | ||
| <img alt="Online Icon" src={onlineIcon} className="onlineIcon" /> | ||
| <span className="username">{name}</span> | ||
| </div> | ||
| </div> | ||
| ) | ||
| : null | ||
| } | ||
| ))} | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
|
|
||
| export default TextContainer; | ||
| export default TextContainer; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify users type or add explicit array check.
The conditional check
users && users.length > 0assumesusersis an array, but the relevant code snippet fromChat.js(line 18) shows it's initialized as an empty string:const [users, setUsers] = useState('');. While an empty string is falsy and won't cause immediate issues, ifusersis set to a non-empty non-array value,users.map()on line 23 will throw a runtime error.Consider using a more defensive check:
Alternatively, ensure the parent component (
Chat.js) initializesusersas an empty array instead of an empty string:Run this script to verify how
usersis managed throughout the codebase:🏁 Script executed:
Length of output: 201
🏁 Script executed:
Length of output: 1314
Initialize
usersas an array and guard against non-arraysChat.js (client/src/components/Chat/Chat.js) line 19:
TextContainer.js (client/src/components/TextContainer/TextContainer.js) line 19:
📝 Committable suggestion