[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
989 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import React, { FC, useState } from 'react'
  2. import { useTheme } from '../hooks'
  3. import { classNames } from '../utils'
  4. import { Post, ClassDictionary } from '../types'
  5. import PostComponent from '../components/post'
  6. interface Props {
  7. posts: Post[]
  8. collapseText?: string
  9. }
  10. const PostList: FC<Props> = ({ posts, collapseText }) => {
  11. const theme = useTheme()
  12. const [isCollapsed, setIsCollapsed] = useState(!!collapseText)
  13. const style: ClassDictionary = {
  14. 'post-list': true,
  15. 'post-list-collapsed': isCollapsed,
  16. }
  17. return (
  18. <div className={classNames(style)} style={{ backgroundColor: theme.backgroundSecondary }}>
  19. {isCollapsed &&
  20. <button className="button is-primary is-fullwidth" onClick={() => setIsCollapsed(false)}>{collapseText}</button>
  21. }
  22. {!isCollapsed && posts.map(post => <PostComponent key={post.id} post={post} />)}
  23. </div>
  24. )
  25. }
  26. export default PostList