-
Notifications
You must be signed in to change notification settings - Fork 370
Hide some feed select buttons by default #3944
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,7 @@ interface State { | |
| isIsomorphic: boolean; | ||
| markPageAsReadLoading: boolean; | ||
| postListingMode: PostListingMode; | ||
| selectButtonsHidden: boolean; | ||
| } | ||
|
|
||
| interface CommunityProps { | ||
|
|
@@ -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>; | ||
|
|
||
|
|
@@ -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" | ||
|
||
| } | ||
| > | ||
| <div className="col"> | ||
| <FilterChipCheckbox | ||
| option={"show_hidden_posts"} | ||
|
|
@@ -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> | ||
|
|
@@ -1471,3 +1489,7 @@ function DeadInstanceOrCommunityWarning() { | |
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function handleHideSelectButtons(i: Community) { | ||
| i.setState({ selectButtonsHidden: !i.state.selectButtonsHidden }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,6 +140,7 @@ interface HomeState { | |
| isIsomorphic: boolean; | ||
| markPageAsReadLoading: boolean; | ||
| postListingMode: PostListingMode; | ||
| selectButtonsHidden: boolean; | ||
| } | ||
|
|
||
| interface HomeProps { | ||
|
|
@@ -289,6 +290,7 @@ export class Home extends Component<HomeRouteProps, HomeState> { | |
| isIsomorphic: false, | ||
| markPageAsReadLoading: false, | ||
| postListingMode: defaultPostListingMode(this.isoData), | ||
| selectButtonsHidden: true, | ||
| }; | ||
|
|
||
| loadingSettled(): boolean { | ||
|
|
@@ -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"> | ||
Nutomic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {/* 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)} | ||
| > | ||
|
||
| <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"} | ||
|
|
@@ -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> | ||
| ); | ||
| } | ||
|
|
@@ -1494,3 +1512,7 @@ async function handleHideDonationDialog(myUserInfo?: MyUserInfo) { | |
| } | ||
| } | ||
| } | ||
|
|
||
| function handleHideSelectButtons(i: Home) { | ||
| i.setState({ selectButtonsHidden: !i.state.selectButtonsHidden }); | ||
| } | ||
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.
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.