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

[UX Improvement] Add Posts filter #13

Merged
merged 1 commit into from
Jun 20, 2020
Merged
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
3 changes: 2 additions & 1 deletion src/AuthenticatedApp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Router, Redirect, useLocation } from '@reach/router'

import { Account, Home, Subreddit, Tag, Comments, NSFW } from './pages'
import { Account, Home, Subreddit, Tag, Comments, Posts, NSFW } from './pages'
import { Layout } from './components'

const NotFound = () => <Redirect from='/login' to='/' noThrow />
Expand All @@ -21,6 +21,7 @@ const AuthenticatedApp = () => {
* Snapchat's "My Eyes Only" (protect_nsfw_content: Boolean)
*/}
<NSFW path='/nsfw' />
<Posts path='/posts' />
<Comments path='/comments' />
{/**
* @reach/router does not support regular expressions matching in path,
Expand Down
5 changes: 5 additions & 0 deletions src/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const Sidebar = () => {
<Text mb={3} pl={5} color='gray.400' fontWeight='semibold'>
Filters
</Text>
<Stack isInline justify='flex-start' align='center' cursor='pointer'>
<NavLink to='/posts' icon='bs-post'>
Posts
</NavLink>
</Stack>
<Stack isInline justify='flex-start' align='center' cursor='pointer'>
<NavLink to='/comments' icon='bs-chat'>
Comments
Expand Down
2 changes: 2 additions & 0 deletions src/components/shared/NavLinkIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
BsFillCaretDownFill,
BsFillCaretRightFill,
BsFillChatSquareFill,
BsFillFolderFill,
} from 'react-icons/bs'

const NavLinkIcon = ({ name, ...rest }) => {
Expand All @@ -16,6 +17,7 @@ const NavLinkIcon = ({ name, ...rest }) => {
'bs-caret-right': BsFillCaretRightFill,
'bs-chat': BsFillChatSquareFill,
'bs-warning': BsFillExclamationOctagonFill,
'bs-post': BsFillFolderFill,
}

const icon = iconMapping[name]
Expand Down
25 changes: 25 additions & 0 deletions src/pages/Posts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useEffect } from 'react'
import { Heading } from '@chakra-ui/core'

import { useThings } from '../contexts/ThingsContext'
import { SEO } from '../components'

const Posts = () => {
const { updateCurrentFilter } = useThings()

useEffect(() => {
updateCurrentFilter({ name: 'post' })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return (
<>
<SEO title='Posts' />
<Heading as='h3' size='xl' mb={4} fontWeight='bold'>
Posts
</Heading>
</>
)
}

export default Posts
1 change: 1 addition & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export { default as Home } from './Home'
export { default as Subreddit } from './Subreddit'
export { default as Tag } from './Tag'
export { default as Comments } from './Comments'
export { default as Posts } from './Posts'
export { default as NSFW } from './NSFW'