Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Gosrock/DuDoong-Front into r…
Browse files Browse the repository at this point in the history
…elease/ticket
  • Loading branch information
9yujin committed Jul 13, 2023
2 parents 2439fcb + 3370774 commit ecf5a2d
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 9 deletions.
8 changes: 7 additions & 1 deletion apps/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
<link
rel="stylesheet preconnect"
crossorigin
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard-dynamic-subset.css"
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.css"
/>
<link
rel="stylesheet"
type="text/css"
crossorigin="anonymous"
href="https://cdn.jsdelivr.net/gh/leetaewook/gmarket-sans-dynamic-subset/GmarketSans.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#F8F8FA" />
Expand Down
7 changes: 7 additions & 0 deletions apps/ticket/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ export default function Document() {
></link> */}
<link
rel="stylesheet preconnect"
type="text/css"
crossOrigin="anonymous"
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard-dynamic-subset.css"
/>
<link
rel="stylesheet"
type="text/css"
crossOrigin="anonymous"
href="https://cdn.jsdelivr.net/gh/leetaewook/gmarket-sans-dynamic-subset/GmarketSans.css"
/>
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=9c08b495df2ecbc09bd453fb53701551&libraries=services,clusterer"
Expand Down
9 changes: 7 additions & 2 deletions apps/ticket/src/components/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { EventApi } from '@lib/apis/events/EventApi';
import { css } from '@emotion/react';
import { useDebouncedCallback } from 'use-debounce';
import { EventResponse } from '@lib/apis/events/eventType';
import SkeletonEvent from './blocks/SkeletonEvent';

const Home = () => {
const [keyword, setKeyword] = useState<string>('');
const { infiniteListElement } = useInfiniteQueries<EventResponse>(
const { infiniteListElement, isLoading } = useInfiniteQueries<EventResponse>(
['events', keyword],
({ pageParam = 0 }) =>
EventApi.GET_EVENTS_SEARCH({ keyword, pageParam, size: 12 }),
Expand Down Expand Up @@ -44,7 +45,11 @@ const Home = () => {
placeholder={'검색어를 입력해주세요'}
rightIcon={<Search />}
/>
<EventList>{infiniteListElement}</EventList>
<EventList>
{infiniteListElement}
{isLoading &&
Array.from({ length: 6 }, (_, i) => <SkeletonEvent key={i} />)}
</EventList>
</main>
<Spacing size={170} />
</Wrapper>
Expand Down
3 changes: 2 additions & 1 deletion apps/ticket/src/components/home/blocks/EventLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const EventLink = (props: EventResponse) => {
alt={`${props.name}`}
onError={() => setImg(`/no-poster.png`)}
className="poster"
priority
/>
{props.status === '지난공연' && (
<Tag size="md" color="mono" text="지난 공연" className="tag" />
Expand Down Expand Up @@ -70,7 +71,7 @@ const Poster = styled.div<{ status: EventStatus }>`
padding-top: 141.4%;
overflow: hidden;
img {
background: ${({ theme }) => theme.palette.gray_300};
background: rgba(165, 165, 165, 0.3);
object-fit: cover;
${({ status }) =>
Expand Down
68 changes: 68 additions & 0 deletions apps/ticket/src/components/home/blocks/SkeletonEvent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import SkeletonItem from '@components/shared/SkeletonStyle';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import React from 'react';

const SkeletonEvent = () => {
return (
<Wrapper>
<Poster />
<SubText />
<MainText />
{/* <Text
typo="P_Text_14_R"
color="gray_400"
as="p"
css={css`
padding-top: 10px;
`}
>
{props.startAt}
</Text>
<Text
typo="P_Header_18_SB"
color={props.status === '지난공연' ? 'gray_400' : 'black'}
as="p"
css={css`
padding-top: 3px;
`}
>
{props.name}
</Text> */}
</Wrapper>
);
};

export default React.memo(SkeletonEvent);

const Wrapper = styled.div`
transform: translateY(0px);
transition: transform 0.15s ease-in 0s;
&:hover {
transform: translateY(-4px);
}
`;

const Poster = styled(SkeletonItem)`
position: relative;
padding-top: 141.4%;
overflow: hidden;
transition: box-shadow 0.15s ease-in 0s;
box-shadow: rgba(0, 0, 0, 0.04) 0px 4px 16px 0px;
border-radius: 12px;
&:hover {
box-shadow: rgba(0, 0, 0, 0.08) 0px 12px 20px 0px;
}
`;

const SubText = styled(SkeletonItem)`
margin-top: 10px;
height: 15.6px;
width: 80%;
`;
const MainText = styled(SkeletonItem)`
margin-top: 3px;
height: 27px;
width: 100%;
`;
34 changes: 34 additions & 0 deletions apps/ticket/src/components/shared/SkeletonStyle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import styled from '@emotion/styled';

const SkeletonItem = styled.div<{ width?: string; height?: string }>`
width: ${({ width }) => width || 'auto'};
height: ${({ width }) => width || 'auto'};
background-color: #f2f2f2;
position: relative;
overflow: hidden;
border-radius: 4px;
@keyframes skeleton-gradient {
0% {
background-color: rgba(165, 165, 165, 0.1);
}
50% {
background-color: rgba(165, 165, 165, 0.3);
}
100% {
background-color: rgba(165, 165, 165, 0.1);
}
}
&:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
animation: skeleton-gradient 1.5s infinite ease-in-out;
}
`;

export default SkeletonItem;
4 changes: 2 additions & 2 deletions shared/ui/src/theme/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const globalStyle = css`
font-display: optional;
} */
@font-face {
/* @font-face {
font-family: 'Gmarket Sans';
font-weight: 300;
font-style: normal;
Expand Down Expand Up @@ -115,7 +115,7 @@ export const globalStyle = css`
url('https://asset.dudoong.com/common/fonts/GmarketSansBold.woff')
format('woff');
font-display: swap;
}
} */
body {
font-family: 'Pretendard', Pretendard, -apple-system, BlinkMacSystemFont,
system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo',
Expand Down
11 changes: 8 additions & 3 deletions shared/utils/src/hooks/useInfiniteQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const useInfiniteQueries = <T,>(
>,
) => {
const [ref, inView] = useInView();
const { data, fetchNextPage } = useInfiniteQuery<
const { data, fetchNextPage, isLoading } = useInfiniteQuery<
InfiniteResponse<T>,
AxiosError
>(queryKey, apiFunction, {
Expand All @@ -36,6 +36,10 @@ export const useInfiniteQueries = <T,>(
if (hasNext && inView) fetchNextPage();
}, [inView]);

useEffect(() => {
console.log(isLoading);
}, [isLoading]);

const listElement = data?.pages.map(({ content }) =>
content.map((item, idx) => <ListItem {...item} key={`item-${idx}`} />),
);
Expand All @@ -49,11 +53,12 @@ export const useInfiniteQueries = <T,>(
infiniteListElement: (
<>
{listElement}
{observer}
{!isLoading && observer}
</>
),
isEmpty,
};
isLoading,
} as const;
};

export interface InfiniteResponse<T> {
Expand Down

0 comments on commit ecf5a2d

Please sign in to comment.