Skip to content

Commit

Permalink
🛣
Browse files Browse the repository at this point in the history
  • Loading branch information
oogxdd committed Sep 30, 2020
1 parent 039ddf0 commit 43f865e
Show file tree
Hide file tree
Showing 55 changed files with 954 additions and 308 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"dependencies": {
"@stripe/react-stripe-js": "^1.1.2",
"@stripe/stripe-js": "^1.9.0",
"@urql/exchange-graphcache": "^3.1.2",
"crypto-js": "^4.0.0",
"draft-js": "^0.11.7",
"draftjs-to-html": "^0.9.1",
"getstream": "^4.5.4",
Expand All @@ -13,6 +15,7 @@
"html-to-draftjs": "^1.5.0",
"html5-file-selector": "^2.1.0",
"isomorphic-unfetch": "^3.0.0",
"jsonwebtoken": "^8.5.1",
"localforage": "^1.7.4",
"moment": "^2.27.0",
"node-sass": "^4.14.1",
Expand Down
Binary file added public/img/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/img/empty/empty01.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions public/img/logo-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions src/api/books/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@ export const getBooksQuery = gql`

export const getFollowedBooksQuery = gql`
query($userId: Int!) {
books(where: { readers: { some: { id: { equals: $userId } } } }) {
books(
where: {
OR: [
{ readers: { some: { id: { equals: $userId } } } }
{ author: { followers: { some: { id: { equals: $userId } } } } }
]
}
) {
...Book
description
chapters {
...Chapter
}
reviews {
stars
}
chapters {
...Chapter
}
author {
...User
}
Expand Down
11 changes: 11 additions & 0 deletions src/api/chapters/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const getChapterQuery = gql`
id
stars
}
readers {
id
}
}
author {
...User
Expand Down Expand Up @@ -93,11 +96,15 @@ export const getLastChaptersQuery = gql`
chapters {
id
}
author {
...User
}
genres {
...Genre
}
}
}
chaptersFeedCount
}
${UserFragment}
${BookFragment}
Expand All @@ -124,6 +131,7 @@ export const getLastChaptersByAuthorQuery = gql`
}
}
}
chaptersFeedByAuthorCount
}
${UserFragment}
${BookFragment}
Expand All @@ -146,6 +154,9 @@ export const getChapterByBookQuery = gql`
id
stars
}
readers {
id
}
chapters(orderBy: { createdAt: asc }) {
id
}
Expand Down
11 changes: 3 additions & 8 deletions src/api/users/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ export const removeBookFromFavoritesMutation = gql`

export const followUserMutation = gql`
mutation($followingId: Int!, $followerId: Int!) {
updateOneUser(
where: { id: $followerId }
data: { following: { connect: { id: $followingId } } }
) {
followUser(followingId: $followingId, followerId: $followerId) {
id
...User
following {
...User
}
Expand Down Expand Up @@ -64,10 +62,7 @@ export const updateUserMutation = gql`

export const unfollowUserMutation = gql`
mutation($followingId: Int!, $followerId: Int!) {
updateOneUser(
where: { id: $followerId }
data: { following: { disconnect: { id: $followingId } } }
) {
unfollowUser(followingId: $followingId, followerId: $followerId) {
id
following {
...User
Expand Down
13 changes: 12 additions & 1 deletion src/api/users/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export const getUserQuery = gql`
...User
}
}
followers {
...User
}
following {
...User
}
}
}
${UserFragment}
Expand All @@ -36,7 +42,6 @@ export const getMeQuery = gql`
...User
firstname
givenname
email
username
getStreamToken
stripeId
Expand All @@ -49,9 +54,15 @@ export const getMeQuery = gql`
id
}
}
books {
id
}
following {
id
}
invited {
id
}
}
}
${UserFragment}
Expand Down
10 changes: 10 additions & 0 deletions src/assets/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,13 @@
width: 100%;
display: block;
}

.invite-link {
text-align: center;
margin-top: 30px;
padding-left: 10px;
color: #7057d2;
cursor: pointer;
font-weight: 500;
font-size: 14px;
}
15 changes: 3 additions & 12 deletions src/components/Explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
removeBookFromFavoritesMutation,
} from 'api'

import BookCover from 'components/atoms/book-cover'
import Loader from 'components/Loader'
import Flex from 'components/Flex'

Expand Down Expand Up @@ -37,12 +38,7 @@ const Book = ({ book, isFirst }) => {

return (
<div className="item item01">
<div
className="item-img"
style={{
backgroundImage: `url("${book.image || '/img/placeholder.jpg'}")`,
}}
/>
<BookCover book={book} isItem hideText />
<div className="item-info" style={{ width: '100%' }}>
<div className="item-head">
<h3 className="item-title">{book.name}</h3>
Expand All @@ -63,12 +59,7 @@ const Book = ({ book, isFirst }) => {
))}
</ul>
<Flex row>
<button
className={`btn btn-follow ${
isFirst && !isFavorite ? 'active' : ''
}`}
onClick={addToLibrary}
>
<button className={`btn btn-follow`} onClick={addToLibrary}>
{isFavorite ? 'Following' : 'Follow'}{' '}
{!isFavorite && (
<span>
Expand Down
9 changes: 6 additions & 3 deletions src/components/Layout/Header/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const CreatePopup = ({ bookId }) => {
}

const AddBook = () => {
return null
return (
<Link to="/new-book" className="header-nav__link">
New book
Expand All @@ -44,9 +45,11 @@ const AddBook = () => {

const AddChapter = ({ bookId }) => {
return (
<Link to={`/books/${bookId}/new-chapter`} className="header-nav__link">
Add page
</Link>
<li className="header-nav__item">
<Link to={`/books/${bookId}/new-chapter`} className="header-nav__link">
Add page
</Link>
</li>
)
}

Expand Down
10 changes: 3 additions & 7 deletions src/components/Layout/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Notifications from 'components/Notifications'
import Logo from './Logo'
import Read from './Read'
import Create from './Create'
import LoginBtn from './LoginBtn'
// import LoginBtn from './LoginBtn'
import SignupBtn from './SignupBtn'
import User from './User'

Expand All @@ -24,11 +24,7 @@ export default ({ home }) => {
<Read />
</li>
)}
{user && (
<li className="header-nav__item">
<Create />
</li>
)}
{user && <Create />}
{user && (
<li
className="header-nav__item"
Expand All @@ -37,7 +33,7 @@ export default ({ home }) => {
<Notifications />
</li>
)}
{!user && <LoginBtn />}
{/* !user && <LoginBtn /> */}
</ul>
</nav>
{!user ? <SignupBtn /> : <User user={user} />}
Expand Down
9 changes: 4 additions & 5 deletions src/components/Layout/Header/Read.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useContext } from 'react'
import { UserContext } from 'context'
import BookCover from 'components/atoms/book-cover'
import { Link } from 'react-router-dom'

const ReadingList = ({ books, close }) => {
Expand All @@ -17,15 +18,14 @@ const ReadingList = ({ books, close }) => {
>
{books.map((book) => (
<Link to={`/books/${book.id}`} key={book.id} onClick={close}>
<div
className="catalog-img"
<BookCover
book={book}
isCatalog
style={{
backgroundImage: `url('${book.image || '/img/placeholder.jpg'}')`,
width: 48,
height: 64,
}}
/>

<div className="catalog-info">
<h3 className="catalog-title">{book.name}</h3>
<p className="catalog-author">
Expand Down Expand Up @@ -53,7 +53,6 @@ export default () => {
return user && user.favoriteBooks.length > 0 ? (
<>
<span
href="http://dev08.morozovoleg.com/home.html"
className="header-nav__link"
onClick={() => setShowDropdown(!showDropdown)}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Header/SignupBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const SignupBtn = () => (
className="btn-login"
href={`${process.env.REACT_APP_BACKEND_URL}/auth/google`}
>
Sign Up
Login
</a>
</li>
)
Expand Down
41 changes: 21 additions & 20 deletions src/components/Layout/Header/User.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useContext } from 'react'
import { UserContext } from 'context'
import { Link, useHistory } from 'react-router-dom'
import Flex from 'components/atoms/flex'

export default () => {
const [showDropdown, setShowDropdown] = useState(false)
Expand Down Expand Up @@ -30,26 +31,30 @@ export default () => {
push(`/users/${user.username ? `@${user.username}` : user.id}`)
}
>
<div
className="header-notification-user__avatar"
style={{
background: `url("${user.avatar}")`,
backgroundSize: 'cover',
}}
/>
<div className="header-notification-user__info">
<div className="header-notification-user__name">
{user.fullname}
<Flex row style={{ cursor: 'pointer' }}>
<div
className="header-notification-user__avatar"
style={{
background: `url("${user.avatar}")`,
backgroundSize: 'cover',
// backgroundSize: 'contain',
cursor: 'pointer',
}}
/>
<div className="header-notification-user__info">
<div className="header-notification-user__name">
{user.fullname}
</div>
<div className="header-notification-user__username">
{user.username ? `@${user.username}` : `@user${user.id}`}
</div>
</div>
<div className="header-notification-user__username">
{user.username ? `@${user.username}` : `@user${user.id}`}
</div>
</div>
</Flex>
</div>
<div className="header-notification-user__body">
<ul className="header-notification-user__list">
<li>
<Link to="/new-book">New story</Link>
<Link to="/new-book">New book</Link>
</li>
<li>
<Link
Expand All @@ -59,11 +64,7 @@ export default () => {
</Link>
</li>
<li>
<Link
to={`/users/${user.username ? `@${user.username}` : user.id}`}
>
Settings
</Link>
<Link to={'/explore'}>Explore</Link>
</li>
<li>
<Link to={`/help`}>Help</Link>
Expand Down
Loading

1 comment on commit 43f865e

@vercel
Copy link

@vercel vercel bot commented on 43f865e Sep 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.