Skip to content

Commit

Permalink
icons added & PostFooter added
Browse files Browse the repository at this point in the history
  • Loading branch information
Khumoyun Akhmedov committed Oct 19, 2020
1 parent d68d808 commit 8bb0ad9
Show file tree
Hide file tree
Showing 32 changed files with 624 additions and 93 deletions.
111 changes: 103 additions & 8 deletions src/components/Post.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React, { useState } from 'react'
import { Flex, Box, Heading } from '@chakra-ui/core'
import Downvote from '../icons/down-arrow.svg'
import Upvote from '../icons/up-arrow.svg'
import Downvote from '../icons/arrow-down.svg'
import Upvote from '../icons/arrow-up.svg'

import GiveAward from '../icons/give-award.svg'
import PostSave from '../icons/post-save.svg'
import PostUnsave from '../icons/post-unsave.svg'
import Share from '../icons/arrow-share.svg'
import Comments from '../icons/comments.svg'

import styled from '@emotion/styled'
import { useRouter } from 'next/router'

Expand All @@ -16,6 +23,11 @@ export interface PostData {
points: number;
}

const FlexCore = styled.div`
display: flex;
flex-direction: row;
`

const Flexbox = styled.div`
display: flex;
flex-direction: row;
Expand All @@ -32,12 +44,41 @@ const Flexbox = styled.div`

const Rightbox = styled.div`
display: flex;
flex-direction: row;
height: 100%;
align-items: center;
flex-direction: column;
`

const PostHeader = styled(FlexCore)`
height: 100%;
`
const PostContent = styled(FlexCore)`
height: 100%;
`
const PostFooter = styled(FlexCore)`
height: 100%;
align-items: center;
`

const PostButton = styled.div`
display: inline-flex;
padding: 2px 4px;
flex-direction: row;
font-size: 10px;
border-radius: 3px;
transition: background-color 0.2s ease-in;
margin-left: 2px;
span {
display: inline-block;
margin-left: 2px;
}
&:hover {
background-color: #e1e2e4;
}
`

export const Post = ({ data }: PostProps) => {
const [vote, setVote] = useState(data.points)
const router = useRouter()
Expand All @@ -46,6 +87,10 @@ export const Post = ({ data }: PostProps) => {
console.log('handlePostClick')
router.push(`/post/${data.id}`)
}

const command = (e: React.SyntheticEvent, cmd: string) => {
console.log('command', cmd)
}

const handleVote = (e: React.SyntheticEvent, vote: string) => {
e.stopPropagation()
Expand All @@ -55,7 +100,7 @@ export const Post = ({ data }: PostProps) => {
}

return (
<Flexbox onClick={() => handlePostClick()}>
<Flexbox>
<Box
w={10}
p={1}
Expand Down Expand Up @@ -89,10 +134,60 @@ export const Post = ({ data }: PostProps) => {
borderTopRightRadius={2}
borderBottomRightRadius={2}
>
<Heading as="h4" size="sm">
{data.title}
</Heading>
<Box fontSize={14}>{data.textSnippet}</Box>
<PostHeader className="post-header">

</PostHeader>

<PostContent className="post-content" onClick={() => handlePostClick()}>
<Heading as="h4" size="sm">
{data.title}
</Heading>
<Box fontSize={14}>{data.textSnippet}</Box>
</PostContent>

<PostFooter className="post-footer">
<PostButton>
<GiveAward
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>123</span>
<span>Comments</span>
</PostButton>

<PostButton>
<Comments
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>Give Award</span>
</PostButton>

<PostButton>
<Share
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>Share</span>
</PostButton>

<PostButton>
<PostSave
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>Save</span>
</PostButton>

</PostFooter>
</Flex>
</Flexbox>
)
Expand Down
108 changes: 108 additions & 0 deletions src/components/PostFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React, { useState } from 'react'
import { Flex, Box, Heading } from '@chakra-ui/core'
import Downvote from '../icons/arrow-down.svg'
import Upvote from '../icons/arrow-up.svg'

import GiveAward from '../icons/give-award.svg'
import PostSave from '../icons/post-save.svg'
import PostUnsave from '../icons/post-unsave.svg'
import Share from '../icons/arrow-share.svg'
import Comments from '../icons/comments.svg'

import styled from '@emotion/styled'
import { useRouter } from 'next/router'

interface PostProps {
data: PostData;
}

export interface PostData {
id: string;
title: string;
textSnippet: string;
points: number;
}

const FlexCore = styled.div`
display: flex;
flex-direction: row;
`

const PostFooter = styled(FlexCore)`
height: 100%;
align-items: center;
`

const PostButton = styled.div`
display: inline-flex;
padding: 2px 4px;
flex-direction: row;
font-size: 10px;
border-radius: 3px;
transition: background-color 0.2s ease-in;
margin-left: 2px;
span {
display: inline-block;
margin-left: 2px;
}
&:hover {
background-color: #e1e2e4;
}
`

export const PostFooter = ({ data }: PostProps) => {
const [vote, setVote] = useState(data.points)
const router = useRouter()

const command = (e: React.SyntheticEvent, cmd: string) => {
console.log('command', cmd)
}

return (
<PostFooter className="post-footer">
<PostButton>
<GiveAward
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>123</span>
<span>Comments</span>
</PostButton>

<PostButton>
<Comments
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>Give Award</span>
</PostButton>

<PostButton>
<Share
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>Share</span>
</PostButton>

<PostButton>
<PostSave
onClick={(e) => command(e, 'share')}
style={{ fill: '#455A64' }}
width={16}
height={16}
/>
<span>Save</span>
</PostButton>

</PostFooter>
)
}
File renamed without changes
1 change: 1 addition & 0 deletions src/icons/arrow-share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
1 change: 1 addition & 0 deletions src/icons/awards/atom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/awards/darts.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/icons/awards/flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/icons/awards/helmet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8bb0ad9

Please sign in to comment.