jaehyuk-jang

Add popover

...@@ -14,6 +14,7 @@ export default function CategoryPage() { ...@@ -14,6 +14,7 @@ export default function CategoryPage() {
14 variables: { 14 variables: {
15 input: { category: name }, 15 input: { category: name },
16 }, 16 },
17 + fetchPolicy: 'network-only'
17 }); 18 });
18 19
19 if (error) console.log(JSON.stringify(error, null, 2)); 20 if (error) console.log(JSON.stringify(error, null, 2));
......
1 import { useQuery } from '@apollo/client'; 1 import { useQuery } from '@apollo/client';
2 2
3 import { GET_ALL_POSTS } from '@src/gql/get-all-posts'; 3 import { GET_ALL_POSTS } from '@src/gql/get-all-posts';
4 +import { useWindowSize } from '@src/hooks';
4 5
5 import Main from '@views/Main'; 6 import Main from '@views/Main';
6 7
7 export default function IndexPage() { 8 export default function IndexPage() {
8 - const { error, data } = useQuery(GET_ALL_POSTS); 9 + const [width] = useWindowSize()
10 + const { error, data } = useQuery(GET_ALL_POSTS, {variables: {skipContent: width < 1000}});
9 if (error) console.log(JSON.stringify(error, null, 2)); 11 if (error) console.log(JSON.stringify(error, null, 2));
10 12
11 let categories = []; 13 let categories = [];
......
1 -import gql from 'graphql-tag'; 1 +import gql from "graphql-tag";
2 2
3 export const GET_ALL_POSTS = gql` 3 export const GET_ALL_POSTS = gql`
4 - query GetAllPosts { 4 + query GetAllPosts($skipContent: Boolean! = true) {
5 getAllPosts { 5 getAllPosts {
6 id 6 id
7 title 7 title
8 category 8 category
9 + content @skip(if: $skipContent)
9 } 10 }
10 } 11 }
11 `; 12 `;
......
...@@ -13,8 +13,8 @@ export default function Card({ category, posts, ...rest }) { ...@@ -13,8 +13,8 @@ export default function Card({ category, posts, ...rest }) {
13 13
14 return ( 14 return (
15 <CardItem title={category} extra={MoreButton(category)} {...rest}> 15 <CardItem title={category} extra={MoreButton(category)} {...rest}>
16 - {sliced.map(({ title, id }) => ( 16 + {sliced.map(({ title, id, content }) => (
17 - <Row key={title} category={category} title={title} id={id} /> 17 + <Row key={title} category={category} title={title} id={id} content={content} />
18 ))} 18 ))}
19 {emptyRows.map((_, idx) => ( 19 {emptyRows.map((_, idx) => (
20 <div className={'card-row'} key={idx} /> 20 <div className={'card-row'} key={idx} />
......
1 import { useRouter } from 'next/router'; 1 import { useRouter } from 'next/router';
2 import { makeArticleURLWithNumber } from '@src/shared/functions'; 2 import { makeArticleURLWithNumber } from '@src/shared/functions';
3 +import { Popover } from 'antd';
3 4
4 -export const Row = ({ category, title, id }) => { 5 +
6 +export const Row = ({ category, title, id, content}) => {
5 const router = useRouter(); 7 const router = useRouter();
6 const sliced = title.length > 20 ? title.substr(0, 20) + '...' : title; 8 const sliced = title.length > 20 ? title.substr(0, 20) + '...' : title;
7 9
...@@ -11,9 +13,11 @@ export const Row = ({ category, title, id }) => { ...@@ -11,9 +13,11 @@ export const Row = ({ category, title, id }) => {
11 }; 13 };
12 14
13 return ( 15 return (
14 - <div className={'card-row has-content'} onClick={handleClickArticle}> 16 + <Popover title={title} content={content} >
17 + <div className={'card-row has-content'} onClick={handleClickArticle} >
15 <h2 className={'card-row-title'}>{sliced}</h2> 18 <h2 className={'card-row-title'}>{sliced}</h2>
16 <span className={'card-row-recomment'}>{'?'}</span> 19 <span className={'card-row-recomment'}>{'?'}</span>
17 </div> 20 </div>
21 + </Popover>
18 ); 22 );
19 }; 23 };
......