Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2015104215
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
jaehyuk-jang
2021-06-13 13:51:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9358845d73e2954ea6bde265251dae6b85c787a8
9358845d
1 parent
0af53dad
Add popover
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
7 deletions
project/packages/web/pages/category/index.tsx
project/packages/web/pages/index.tsx
project/packages/web/src/gql/get-all-posts.ts
project/packages/web/src/views/Main/Card.tsx
project/packages/web/src/views/Main/Row.tsx
project/packages/web/pages/category/index.tsx
View file @
9358845
...
...
@@ -14,6 +14,7 @@ export default function CategoryPage() {
variables: {
input: { category: name },
},
fetchPolicy: 'network-only'
});
if (error) console.log(JSON.stringify(error, null, 2));
...
...
project/packages/web/pages/index.tsx
View file @
9358845
import { useQuery } from '@apollo/client';
import { GET_ALL_POSTS } from '@src/gql/get-all-posts';
import { useWindowSize } from '@src/hooks';
import Main from '@views/Main';
export default function IndexPage() {
const { error, data } = useQuery(GET_ALL_POSTS);
const [width] = useWindowSize()
const { error, data } = useQuery(GET_ALL_POSTS, {variables: {skipContent: width < 1000}});
if (error) console.log(JSON.stringify(error, null, 2));
let categories = [];
...
...
project/packages/web/src/gql/get-all-posts.ts
View file @
9358845
import
gql
from
'graphql-tag'
;
import
gql
from
"graphql-tag"
;
export
const
GET_ALL_POSTS
=
gql
`
query GetAllPosts {
query GetAllPosts
($skipContent: Boolean! = true)
{
getAllPosts {
id
title
category
content @skip(if: $skipContent)
}
}
`
;
...
...
project/packages/web/src/views/Main/Card.tsx
View file @
9358845
...
...
@@ -13,8 +13,8 @@ export default function Card({ category, posts, ...rest }) {
return (
<CardItem title={category} extra={MoreButton(category)} {...rest}>
{sliced.map(({ title, id }) => (
<Row key={title} category={category} title={title} id={id} />
{sliced.map(({ title, id
, content
}) => (
<Row key={title} category={category} title={title} id={id}
content={content}
/>
))}
{emptyRows.map((_, idx) => (
<div className={'card-row'} key={idx} />
...
...
project/packages/web/src/views/Main/Row.tsx
View file @
9358845
import { useRouter } from 'next/router';
import { makeArticleURLWithNumber } from '@src/shared/functions';
import { Popover } from 'antd';
export const Row = ({ category, title, id }) => {
export const Row = ({ category, title, id, content}) => {
const router = useRouter();
const sliced = title.length > 20 ? title.substr(0, 20) + '...' : title;
...
...
@@ -11,9 +13,11 @@ export const Row = ({ category, title, id }) => {
};
return (
<div className={'card-row has-content'} onClick={handleClickArticle}>
<Popover title={title} content={content} >
<div className={'card-row has-content'} onClick={handleClickArticle} >
<h2 className={'card-row-title'}>{sliced}</h2>
<span className={'card-row-recomment'}>{'?'}</span>
</div>
</Popover>
);
};
...
...
Please
register
or
login
to post a comment