Skip to content
Open
Show file tree
Hide file tree
Changes from all 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/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.
140 changes: 80 additions & 60 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 @@ -756,27 +758,85 @@ export class Community extends Component<CommunityRouteProps, State> {
const communityRss = res
? communityRSSUrl(res.community_view.community, sort)
: undefined;
const showSidebarMobile = this.state.showSidebarMobile;
const { showSidebarMobile, selectButtonsHidden } = this.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=" mb-3">
<div className="row row-cols-auto align-items-center g-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>
<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>
)}
{myUserInfo && (
<button
className="btn btn-sm btn-ghost text-muted"
onclick={_ => handleHideSelectButtons(this)}
>
<Icon
icon={selectButtonsHidden ? "chevrons-down" : "chevrons-up"}
/>
</button>
)}
</div>
{postOrCommentType === "post" && myUserInfo && (
<>
{postOrCommentType === "post" && myUserInfo && !selectButtonsHidden && (
<div className="row row-cols-auto mt-2">
<div className="col">
<FilterChipCheckbox
option={"show_hidden_posts"}
Expand All @@ -791,50 +851,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 +1487,7 @@ function DeadInstanceOrCommunityWarning() {
</div>
);
}

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