Skip to content
Closed
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
4 changes: 3 additions & 1 deletion src/assets/symbols.svg
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a variant or prop to the expand chip checkbox that uses these icons. Because your expand button should look similar to the other already existing ones.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 80 additions & 58 deletions src/shared/components/community/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ interface State {
isIsomorphic: boolean;
markPageAsReadLoading: boolean;
postListingMode: PostListingMode;
selectButtonsHidden: boolean;
}

interface CommunityProps {
Expand Down Expand Up @@ -251,6 +252,7 @@ export class Community extends Component<CommunityRouteProps, State> {
isIsomorphic: false,
markPageAsReadLoading: false,
postListingMode: defaultPostListingMode(this.isoData),
selectButtonsHidden: true,
};
private readonly mainContentRef: RefObject<HTMLDivElement>;

Expand Down Expand Up @@ -761,22 +763,82 @@ export class Community extends Component<CommunityRouteProps, State> {
const myUserInfo = this.isoData.myUserInfo;

return (
<div className="row row-cols-auto align-items-center g-3 mb-3">
<div className="d-block d-md-none col">
<ExpandChipCheckbox
option="show_sidebar"
isChecked={showSidebarMobile}
onCheck={show => handleShowSidebarMobile(this, show)}
/>
</div>
<div className="col">
<PostOrCommentTypeDropdown
currentOption={postOrCommentType}
onSelect={val => handlePostOrCommentTypeChange(this, val)}
/>
<div className="g-3 mb-3">
<div className="row row-cols-auto align-items-center">
<div className="d-block d-md-none col">
<ExpandChipCheckbox
option="show_sidebar"
isChecked={showSidebarMobile}
onCheck={show => handleShowSidebarMobile(this, show)}
/>
</div>
<div className="col">
<PostOrCommentTypeDropdown
currentOption={postOrCommentType}
onSelect={val => handlePostOrCommentTypeChange(this, val)}
/>
</div>
<div className="col">
<PostListingModeDropdown
currentOption={this.state.postListingMode}
onSelect={val =>
handlePostListingModeChange(this, val, myUserInfo)
}
showLabel
/>
</div>
{this.props.postOrCommentType === "post" ? (
<>
<div className="col">
<PostSortDropdown
currentOption={mixedToPostSortType(sort)}
onSelect={val => handleSortChange(this, val)}
showLabel
/>
</div>
<div className="col">
<TimeIntervalFilter
currentSeconds={postTimeRange}
onChange={val => handlePostTimeRangeChange(this, val)}
/>
</div>
</>
) : (
<div className="col">
<CommentSortDropdown
currentOption={mixedToCommentSortType(sort)}
onSelect={val => handleCommentSortChange(this, val)}
showLabel
/>
</div>
)}
{communityRss && (
<div className="col">
<a href={communityRss} title="RSS" rel={relTags}>
<Icon icon="rss" classes="text-muted small" />
</a>
<link
rel="alternate"
type="application/atom+xml"
href={communityRss}
/>
</div>
)}
<button
className="col btn btn-ghost"
onclick={_ => handleHideSelectButtons(this)}
>
<Icon icon="chevrons-down" />
</button>
</div>
{postOrCommentType === "post" && myUserInfo && (
<>
<div
className={
this.state.selectButtonsHidden
? "d-none"
: "row row-cols-auto mt-2"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the culprit. Don't do this, just surround the specific filters you want to hide with {!this.state.selectButtonsHidden && <div

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay fixed

Copy link
Copy Markdown
Member

@dessalines dessalines Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still had some issues, I got it: #3962

}
>
<div className="col">
<FilterChipCheckbox
option={"show_hidden_posts"}
Expand All @@ -791,50 +853,6 @@ export class Community extends Component<CommunityRouteProps, State> {
onCheck={hideRead => handleHideReadChange(this, hideRead)}
/>
</div>
</>
)}
<div className="col">
<PostListingModeDropdown
currentOption={this.state.postListingMode}
onSelect={val => handlePostListingModeChange(this, val, myUserInfo)}
showLabel
/>
</div>
{this.props.postOrCommentType === "post" ? (
<>
<div className="col">
<PostSortDropdown
currentOption={mixedToPostSortType(sort)}
onSelect={val => handleSortChange(this, val)}
showLabel
/>
</div>
<div className="col">
<TimeIntervalFilter
currentSeconds={postTimeRange}
onChange={val => handlePostTimeRangeChange(this, val)}
/>
</div>
</>
) : (
<div className="col">
<CommentSortDropdown
currentOption={mixedToCommentSortType(sort)}
onSelect={val => handleCommentSortChange(this, val)}
showLabel
/>
</div>
)}
{communityRss && (
<div className="col">
<a href={communityRss} title="RSS" rel={relTags}>
<Icon icon="rss" classes="text-muted small" />
</a>
<link
rel="alternate"
type="application/atom+xml"
href={communityRss}
/>
</div>
)}
</div>
Expand Down Expand Up @@ -1471,3 +1489,7 @@ function DeadInstanceOrCommunityWarning() {
</div>
);
}

function handleHideSelectButtons(i: Community) {
i.setState({ selectButtonsHidden: !i.state.selectButtonsHidden });
}
176 changes: 99 additions & 77 deletions src/shared/components/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ interface HomeState {
isIsomorphic: boolean;
markPageAsReadLoading: boolean;
postListingMode: PostListingMode;
selectButtonsHidden: boolean;
}

interface HomeProps {
Expand Down Expand Up @@ -289,6 +290,7 @@ export class Home extends Component<HomeRouteProps, HomeState> {
isIsomorphic: false,
markPageAsReadLoading: false,
postListingMode: defaultPostListingMode(this.isoData),
selectButtonsHidden: true,
};

loadingSettled(): boolean {
Expand Down Expand Up @@ -872,32 +874,105 @@ export class Home extends Component<HomeRouteProps, HomeState> {
const { showSubscribedMobile, showSidebarMobile } = this.state;

return (
<div className="row row-cols-auto align-items-center g-3 mb-3">
{/* Only show these two selects on mobile */}
{this.hasFollows && (
<div className="g-3 mb-3">
<div className="row row-cols-auto align-items-center">
{/* Only show these two selects on mobile */}
{this.hasFollows && (
<div className="d-block d-md-none col">
<ExpandChipCheckbox
option="show_subscribed"
isChecked={showSubscribedMobile}
onCheck={show => handleShowSubscribedMobile(this, show)}
/>
</div>
)}
<div className="d-block d-md-none col">
<ExpandChipCheckbox
option="show_subscribed"
isChecked={showSubscribedMobile}
onCheck={show => handleShowSubscribedMobile(this, show)}
option="show_sidebar"
isChecked={showSidebarMobile}
onCheck={show => handleShowSidebarMobile(this, show)}
/>
</div>
)}
<div className="d-block d-md-none col">
<ExpandChipCheckbox
option="show_sidebar"
isChecked={showSidebarMobile}
onCheck={show => handleShowSidebarMobile(this, show)}
/>
</div>
<div className="col">
<PostOrCommentTypeDropdown
currentOption={postOrCommentType}
onSelect={val => handlePostOrCommentTypeChange(this, val)}
/>
<div className="col">
<PostOrCommentTypeDropdown
currentOption={postOrCommentType}
onSelect={val => handlePostOrCommentTypeChange(this, val)}
/>
</div>
{/** TODO add show read posts also **/}
<div className="col">
<ListingTypeDropdown
currentOption={
listingType ??
this.state.siteRes.site_view.local_site
.default_post_listing_type
}
showLocal={showLocal(this.isoData)}
showSubscribed
showSuggested={
!!this.isoData.siteRes.site_view.local_site
.suggested_multi_community_id
}
showLabel
myUserInfo={this.isoData.myUserInfo}
onSelect={val => handleListingTypeChange(this, val)}
/>
</div>
<div className="col">
<PostListingModeDropdown
currentOption={this.state.postListingMode}
onSelect={val => handlePostListingModeChange(this, val)}
showLabel
/>
</div>
{this.props.postOrCommentType === "post" ? (
<>
<div className="col">
<PostSortDropdown
currentOption={mixedToPostSortType(sort)}
onSelect={val => handleSortChange(this, val)}
showLabel
/>
</div>
<div className="col">
<TimeIntervalFilter
currentSeconds={postTimeRange}
onChange={seconds => handlePostTimeRangeChange(this, seconds)}
/>
</div>
</>
) : (
<div className="col">
<CommentSortDropdown
currentOption={mixedToCommentSortType(sort)}
onSelect={val => handleCommentSortChange(this, val)}
showLabel
/>
</div>
)}
<div className="col">
{getRss(
listingType ??
this.state.siteRes.site_view.local_site
.default_post_listing_type,
sort,
)}
</div>
<button
className="col btn btn-ghost"
onclick={_ => handleHideSelectButtons(this)}
>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the ExpandChipCheckbox

<Icon icon="chevrons-down" />
</button>
</div>
{postOrCommentType === "post" && this.isoData.myUserInfo && (
<>
<div
className={
this.state.selectButtonsHidden
? "d-none"
: "row row-cols-auto mt-2"
}
>
<div className="col">
<FilterChipCheckbox
option={"show_hidden_posts"}
Expand All @@ -912,65 +987,8 @@ export class Home extends Component<HomeRouteProps, HomeState> {
onCheck={hideRead => handleHideReadChange(this, hideRead)}
/>
</div>
</>
)}
{/** TODO add show read posts also **/}
<div className="col">
<ListingTypeDropdown
currentOption={
listingType ??
this.state.siteRes.site_view.local_site.default_post_listing_type
}
showLocal={showLocal(this.isoData)}
showSubscribed
showSuggested={
!!this.isoData.siteRes.site_view.local_site
.suggested_multi_community_id
}
showLabel
myUserInfo={this.isoData.myUserInfo}
onSelect={val => handleListingTypeChange(this, val)}
/>
</div>
<div className="col">
<PostListingModeDropdown
currentOption={this.state.postListingMode}
onSelect={val => handlePostListingModeChange(this, val)}
showLabel
/>
</div>
{this.props.postOrCommentType === "post" ? (
<>
<div className="col">
<PostSortDropdown
currentOption={mixedToPostSortType(sort)}
onSelect={val => handleSortChange(this, val)}
showLabel
/>
</div>
<div className="col">
<TimeIntervalFilter
currentSeconds={postTimeRange}
onChange={seconds => handlePostTimeRangeChange(this, seconds)}
/>
</div>
</>
) : (
<div className="col">
<CommentSortDropdown
currentOption={mixedToCommentSortType(sort)}
onSelect={val => handleCommentSortChange(this, val)}
showLabel
/>
</div>
)}
<div className="col">
{getRss(
listingType ??
this.state.siteRes.site_view.local_site.default_post_listing_type,
sort,
)}
</div>
</div>
);
}
Expand Down Expand Up @@ -1494,3 +1512,7 @@ async function handleHideDonationDialog(myUserInfo?: MyUserInfo) {
}
}
}

function handleHideSelectButtons(i: Home) {
i.setState({ selectButtonsHidden: !i.state.selectButtonsHidden });
}