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/sidebar responsiveness #920

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ html {
::-webkit-resizer {
background-color: #666;
}

@media (min-width: 980px) {
#main-searchbar {
display: none;
}
}
2 changes: 1 addition & 1 deletion src/components/CaptureTheFlag/CTFElements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const SearchContainer = styled.div`
/* margin: 10px 0; */
background: #090909;
border-radius: 4px;
padding: 25px;
padding: 5px;
`;

export const SearchDifficulty = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const SearchBox = styled.div`
align-items: center;
background: #252525;
border-radius: 5px;
width: 100%;
`;

export const SearchIcon = styled.div`
Expand Down
3 changes: 2 additions & 1 deletion src/components/Common/SocialSidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Sidebar = ({
data,
selectedTags,
setSelectedTags,
hideNav = false,
}) => {
const renderFollowingFilterButtons = () => (
<>
Expand Down Expand Up @@ -87,7 +88,7 @@ const Sidebar = ({
);

return (
<SidebarContainer $sidebarType={sidebarType}>
<SidebarContainer $sidebarType={sidebarType} className={hideNav ? "hide-nav" : ""}>
{sidebarType === "blogs" && (
<div style={{ display: "flex", justifyContent: "space-between", marginBottom: "10px" }}>
{user?.role === "admin" || user?.role === "team" ? (
Expand Down
8 changes: 8 additions & 0 deletions src/components/Common/SocialSidebar/SidebarElements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export const SidebarContainer = styled.div`
color: #fff;
box-shadow: 0 4px 8px rgb(0 0 0 / 10%);
border-radius: 10px;

@media screen and (width <= 1280px) {
min-width: 80%;
}

@media screen and (width <= 1080px) {
width: 96%;
}
`;

export const FilterButton = styled.button`
Expand Down
1 change: 1 addition & 0 deletions src/components/Feeds/Feeds.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const Feeds = () => {
data={feeds}
selectedTags={selectedTags}
setSelectedTags={setSelectedTags}
hideNav={true}
/>
</LeftContainer>
</FeedsContainer>
Expand Down
5 changes: 5 additions & 0 deletions src/components/Feeds/FeedsElements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export const FeedsContainer = styled.div`
display: flex;
flex-direction: row;
justify-content: space-around;

@media screen and (width <= 1160px) {
gap: 1%;
}

`;

export const MiddleSection = styled.div`
Expand Down
143 changes: 86 additions & 57 deletions src/components/Feeds/PostForm/ModifyFeed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { cdnContentImagesUrl } from "src/features/apiUrl";
import { CircleSpinner } from "react-spinners-kit";
import { toast } from "react-toastify";
import { ImageInput, ImagePreview, useUploadImages } from "src/components/Common/ImageUpload";
import { SearchContainer } from "src/components/CaptureTheFlag/CTFElements";
import SearchInputBox from "src/components/Common/SearchInputBox";
import { RouterNavCreateButtonLink } from "src/components/Header/Navbar/NavbarElements";

const MAX_IMAGE_SIZE_BYTES = 1048576;
const ModifyPost = ({ showPostTags, userDetails, onModifyFeed, editFeed = "" }) => {
Expand Down Expand Up @@ -37,10 +40,14 @@ const ModifyPost = ({ showPostTags, userDetails, onModifyFeed, editFeed = "" })
const [content, setContent] = useState(editFeed?.content || "");
const [tags, setTags] = useState(editFeed?.tags || []);
const [showAuthPopup, setShowAuthPopup] = useState(false);
const [searchTerm, setSearchTerm] = useState("");

const MAX_CHARACTER_COUNT = 1500;

const [remainingCharacters, setRemainingCharacters] = useState(MAX_CHARACTER_COUNT);
const handleSearchTermChange = (event) => {
setSearchTerm(event.target.value);
};

useEffect(() => {
setRemainingCharacters(MAX_CHARACTER_COUNT - content.length);
Expand Down Expand Up @@ -98,65 +105,87 @@ const ModifyPost = ({ showPostTags, userDetails, onModifyFeed, editFeed = "" })
const userDetail = userDetails?.find((userDetail) => userDetail?.user === user?._id);
const avatar = cdnContentImagesUrl("/user/" + (userDetail?.avatar || editFeed?.avatar || "avatar.png"));
return (
<AddFeedCommentContainer onDrop={(e) => onImageDrop(e, true, 4)} onDragOver={onImageDragOver}>
{!editFeed && (
<LeftSection>
<PostHeaderImg src={avatar} alt="Profile picture" />
</LeftSection>
)}
<RightSection>
<div>
<FeedCommentInput
ref={textareaRef}
placeholder="What's on your mind?"
value={content}
onChange={handleChange}
onPaste={(e) => onImagePaste(e, true, 4)}
<>
<div id="main-searchbar" className="my-4">
<SearchContainer>
{/* <input placeholder="search" /> */}
<SearchInputBox
placeholder="Search by name"
value={searchTerm}
onChange={handleSearchTermChange}
setValue={setSearchTerm}
hideNav={true}
/>
<p
style={{
color:
remainingCharacters <= 99 ? "#ff2525" : remainingCharacters <= 500 ? "#ff6b08" : "grey",
width: "100%",
textAlign: "right",
fontSize: "12px",
fontWeight: "bold",
// border: '1px solid #ff6b08',
marginTop: "-15px",
marginBottom: "-10px",
}}
>
{remainingCharacters < 0 ? "-" : ""} {Math.abs(remainingCharacters)}
</p>
</SearchContainer>
<div className="flex justify-between p-2">
<RouterNavCreateButtonLink to={"/feeds/my-feeds"}>View My Feeds</RouterNavCreateButtonLink>
<RouterNavCreateButtonLink to={"/dashboard/saved"}>Saved</RouterNavCreateButtonLink>
</div>

<ImagePreview files={images} filesName={imagesName} onRemove={onImageRemove} />

{showPostTags && <AddPostTags tags={tags} setTags={setTags} />}

<FooterSection>
<ImageInput
inputName={editFeed ? `${editFeed._id}feedImage` : "feedImage"}
onChange={(e) => onImageChange(e, true, 4)}
labelStyles={{ background: "transparent", border: "transparent", padding: "0" }}
filesName={imagesName}
multiple
key={editFeed ? `${editFeed._id}feedImage` : "feedImage"}
/>

{isFeedLoading ? (
<PostFormButton>
<CircleSpinner size={17} />
</PostFormButton>
) : (
<PostFormButton onClick={handleSubmit}>{editFeed ? "Update" : "Create"}</PostFormButton>
)}
</FooterSection>
</RightSection>

{/* Render the AuthPopup component */}
{showAuthPopup && <AuthPopup onClose={() => setShowAuthPopup(false)} />}
</AddFeedCommentContainer>
</div>
<AddFeedCommentContainer onDrop={(e) => onImageDrop(e, true, 4)} onDragOver={onImageDragOver}>
{!editFeed && (
<LeftSection>
<PostHeaderImg src={avatar} alt="Profile picture" />
</LeftSection>
)}
<RightSection>
<div>
<FeedCommentInput
ref={textareaRef}
placeholder="What's on your mind?"
value={content}
onChange={handleChange}
onPaste={(e) => onImagePaste(e, true, 4)}
/>
<p
style={{
color:
remainingCharacters <= 99
? "#ff2525"
: remainingCharacters <= 500
? "#ff6b08"
: "grey",
width: "100%",
textAlign: "right",
fontSize: "12px",
fontWeight: "bold",
// border: '1px solid #ff6b08',
marginTop: "-15px",
marginBottom: "-10px",
}}
>
{remainingCharacters < 0 ? "-" : ""} {Math.abs(remainingCharacters)}
</p>
</div>

<ImagePreview files={images} filesName={imagesName} onRemove={onImageRemove} />

{showPostTags && <AddPostTags tags={tags} setTags={setTags} />}

<FooterSection>
<ImageInput
inputName={editFeed ? `${editFeed._id}feedImage` : "feedImage"}
onChange={(e) => onImageChange(e, true, 4)}
labelStyles={{ background: "transparent", border: "transparent", padding: "0" }}
filesName={imagesName}
multiple
key={editFeed ? `${editFeed._id}feedImage` : "feedImage"}
/>

{isFeedLoading ? (
<PostFormButton>
<CircleSpinner size={17} />
</PostFormButton>
) : (
<PostFormButton onClick={handleSubmit}>{editFeed ? "Update" : "Create"}</PostFormButton>
)}
</FooterSection>
</RightSection>

{/* Render the AuthPopup component */}
{showAuthPopup && <AuthPopup onClose={() => setShowAuthPopup(false)} />}
</AddFeedCommentContainer>
</>
);
};

Expand Down
5 changes: 5 additions & 0 deletions src/components/Header/Navbar/NavbarElements.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ export const RouterNavCreateButtonLink = styled(Link)`
font-size: 12px;
}

@media screen and (width <= 1280px) {
min-width: 10px;
font-size: 14px;
}

/* @media screen and (max-width: 1150px) {
display: none;
}
Expand Down
6 changes: 6 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ code {
background-color: #ff6b08;
color: #000000;
}

@media (width <= 980px) {
.hide-nav {
display: none !important;
}
}