Skip to content

Commit

Permalink
Merge branch 'fe-dev' into feature/#764
Browse files Browse the repository at this point in the history
  • Loading branch information
Todari authored Oct 23, 2024
2 parents 7cfce63 + fc44763 commit 0ecc883
Show file tree
Hide file tree
Showing 16 changed files with 202 additions and 43 deletions.
5 changes: 0 additions & 5 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
<link rel="dns-prefetch" href="https://cdn.jsdelivr.net" />
<link href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" rel="stylesheet" />
<script
src="https://t1.kakaocdn.net/kakao_js_sdk/2.7.2/kakao.min.js"
integrity="sha384-TiCUE00h649CAMonG018J2ujOgDKW/kVWlChEuu4jK2vxfAAD0eZxzCKakxg55G4"
crossorigin="anonymous"
></script>
</head>
<body>
<div id="root"></div>
Expand Down
5 changes: 1 addition & 4 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {ReactQueryDevtools} from '@tanstack/react-query-devtools';
import QueryClientBoundary from '@components/QueryClientBoundary/QueryClientBoundary';
import ErrorCatcher from '@components/AppErrorBoundary/ErrorCatcher';
import ToastContainer from '@components/Toast/ToastContainer';
import KakaoInitializer from '@components/KakaoInitializer/KakaoInitializer';
import AmplitudeInitializer from '@components/AmplitudeInitializer/AmplitudeInitializer';

import {HDesignProvider} from '@HDesign/index';
Expand All @@ -26,9 +25,7 @@ const App: React.FC = () => {
<NetworkStateCatcher />
<ToastContainer />
<AmplitudeInitializer>
<KakaoInitializer>
<Outlet />
</KakaoInitializer>
<Outlet />
</AmplitudeInitializer>
</QueryClientBoundary>
</ErrorCatcher>
Expand Down
10 changes: 8 additions & 2 deletions client/src/components/Design/components/Dropdown/ButtonBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ type ButtonBaseProps = DropdownProps & {
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
dropdownRef: React.RefObject<HTMLElement>;
onBaseButtonClick?: () => void;
};

const ButtonBase = ({isOpen, setIsOpen, dropdownRef, baseButtonText, children}: ButtonBaseProps) => {
const ButtonBase = ({isOpen, setIsOpen, dropdownRef, baseButtonText, onBaseButtonClick, children}: ButtonBaseProps) => {
const {theme} = useTheme();

const onClick = () => {
if (onBaseButtonClick) onBaseButtonClick();
setIsOpen(true);
};

return (
<>
<Button variants="tertiary" size="small" onClick={() => setIsOpen(true)}>
<Button variants="tertiary" size="small" onClick={onClick}>
{baseButtonText}
</Button>
{isOpen && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MeatballBase from './MeatballBase';
import ButtonBase from './ButtonBase';
import {dropdownBaseStyle} from './Dropdown.style';

const Dropdown = ({base = 'meatballs', baseButtonText, children}: DropdownProps) => {
const Dropdown = ({base = 'meatballs', baseButtonText, onBaseButtonClick, children}: DropdownProps) => {
const {isOpen, setIsOpen, baseRef, dropdownRef} = useDropdown();
const isDropdownOpen = isOpen && !!baseRef.current;

Expand All @@ -21,6 +21,7 @@ const Dropdown = ({base = 'meatballs', baseButtonText, children}: DropdownProps)
<ButtonBase
isOpen={isDropdownOpen}
setIsOpen={setIsOpen}
onBaseButtonClick={onBaseButtonClick}
dropdownRef={dropdownRef}
children={children}
baseButtonText={baseButtonText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export type DropdownButtonProps = React.HTMLAttributes<HTMLButtonElement> & {
export type DropdownProps = {
base?: DropdownBase;
baseButtonText?: string;
onBaseButtonClick?: () => void;
children: React.ReactElement<DropdownButtonProps>[];
};
15 changes: 0 additions & 15 deletions client/src/components/KakaoInitializer/KakaoInitializer.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import toast from '@hooks/useToast/toast';

import {Dropdown, DropdownButton} from '@components/Design';

import initKakao from '@utils/initKakao';

type MobileShareEventButtonProps = {
copyShare: () => Promise<void>;
kakaoShare: () => void;
Expand All @@ -18,7 +20,7 @@ const MobileShareEventButton = ({copyShare, kakaoShare}: MobileShareEventButtonP

return (
<div style={{marginRight: '1rem'}}>
<Dropdown base="button" baseButtonText="μ •μ‚° μ΄ˆλŒ€ν•˜κΈ°">
<Dropdown base="button" baseButtonText="μ •μ‚° μ΄ˆλŒ€ν•˜κΈ°" onBaseButtonClick={initKakao}>
<DropdownButton text="링크 λ³΅μ‚¬ν•˜κΈ°" onClick={copyAndToast} />
<DropdownButton text="μΉ΄μΉ΄μ˜€ν†‘μœΌλ‘œ μ΄ˆλŒ€ν•˜κΈ°" onClick={kakaoShare} />
</Dropdown>
Expand Down
49 changes: 49 additions & 0 deletions client/src/hooks/useImageLazyLoading.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {useEffect, useState} from 'react';

type UseImageLazyLoadingProps<T extends HTMLElement> = {
targetRef: React.RefObject<T>;
src: string;
threshold?: number;
};

const useImageLazyLoading = <T extends HTMLElement>({
targetRef,
src,
threshold = 0.05,
}: UseImageLazyLoadingProps<T>) => {
const [imageSrc, setImageSrc] = useState<string | undefined>(undefined);

useEffect(() => {
if (targetRef && !imageSrc) {
const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) {
setImageSrc(src);
if (targetRef.current) {
observer.unobserve(targetRef.current);
}
}
},
{threshold},
);

if (targetRef.current) {
observer.observe(targetRef.current);
}

return () => {
if (targetRef.current) {
observer.unobserve(targetRef.current);
}
};
}

return;
}, [targetRef, src]);

return {
imageSrc,
};
};

export default useImageLazyLoading;
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import {useRef} from 'react';

import Text from '@HDesign/components/Text/Text';

import useImageLazyLoading from '@hooks/useImageLazyLoading';

import {descriptionSectionStyle, imgStyle} from './DescriptionSection.style';

const DescriptionSection = () => {
const descriptionRef = useRef<HTMLDivElement>(null);

const {imageSrc} = useImageLazyLoading({
targetRef: descriptionRef,
src: `${process.env.IMAGE_URL}/standingDog.svg`,
threshold: 0.05,
});

return (
<div css={descriptionSectionStyle}>
<img css={imgStyle} src={`${process.env.IMAGE_URL}/standingDog.svg`} alt="ν–‰λŒ•μ΄" />
<div css={descriptionSectionStyle} ref={descriptionRef}>
<img css={imgStyle} src={imageSrc} alt="ν–‰λŒ•μ΄ - ν–‰λ™λŒ€μž₯ λ§ˆμŠ€μ½”νŠΈ" />
<Text style={{textAlign: 'center'}} size="subTitle" responsive={true}>{`ν–‰λ™λŒ€μž₯듀을 μœ„ν•΄
ν–‰λ™λŒ€μž₯을 μ€€λΉ„ν–ˆμ–΄μš”
`}</Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import {useRef} from 'react';

import useImageLazyLoading from '@hooks/useImageLazyLoading';

import {Text} from '@components/Design';

import {articleStyle, imageStyle, sectionStyle, textContainerStyle} from './AutoCalculate.style';

const AutoCalculate = () => {
const sectionRef = useRef<HTMLElement>(null);

const {imageSrc} = useImageLazyLoading({
targetRef: sectionRef,
src: `${process.env.IMAGE_URL}/feature2.svg`,
threshold: 0.05,
});

return (
<section css={sectionStyle}>
<section css={sectionStyle} ref={sectionRef}>
<article css={articleStyle}>
<object type="image/svg+xml" data={`${process.env.IMAGE_URL}/feature2.svg`} css={imageStyle} />
<object type="image/svg+xml" data={imageSrc} css={imageStyle} alt="μ°¨λ“± μ •μ‚° 계산을 μ‰½κ²Œ ν•΄μ£ΌλŠ” UI 이미지"/>

Check failure on line 21 in client/src/pages/MainPage/Section/FeatureSection/AutoCalculate/AutoCalculate.tsx

View workflow job for this annotation

GitHub Actions / test

Insert `Β·`
<div css={textContainerStyle}>
<Text size="subTitle" responsive={true}>
계산은 저희가 μ•Œμ•„μ„œ ν•΄λ“œλ €μš”
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import {useRef} from 'react';

import useImageLazyLoading from '@hooks/useImageLazyLoading';

import {Text} from '@components/Design';

import {articleStyle, imageStyle, sectionStyle, textContainerStyle} from './CheckDeposit.style';

const CheckDeposit = () => {
const sectionRef = useRef<HTMLElement>(null);

const {imageSrc} = useImageLazyLoading({
targetRef: sectionRef,
src: `${process.env.IMAGE_URL}/feature3.svg`,
threshold: 0.05,
});

return (
<section css={sectionStyle}>
<section css={sectionStyle} ref={sectionRef}>
<article css={articleStyle}>
<div css={textContainerStyle}>
<Text size="subTitle" responsive={true}>
Expand All @@ -16,7 +28,7 @@ const CheckDeposit = () => {
κ°„νŽΈν•˜κ²Œ 관리할 수 μžˆμ–΄μš”.`}
</Text>
</div>
<object type="image/svg+xml" data={`${process.env.IMAGE_URL}/feature3.svg`} css={imageStyle} />
<object type="image/svg+xml" data={imageSrc} css={imageStyle} alt="μž…κΈˆ 확인 κΈ°λŠ₯ UI 이미지" />
</article>
</section>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {css} from '@emotion/react';

import useMainPageYScroll from '@hooks/useMainPageYScroll';

import {useRef} from 'react';

Check failure on line 5 in client/src/pages/MainPage/Section/FeatureSection/FeatureSection.tsx

View workflow job for this annotation

GitHub Actions / test

`react` import should occur before import of `@hooks/useMainPageYScroll`

import {SimpleShare} from './SimpleShare';
import {AutoCalculate} from './AutoCalculate';
import {CheckDeposit} from './CheckDeposit';
Expand All @@ -10,6 +12,7 @@ import {RecordMemoryWithPhoto} from './RecordMemoryWithPhoto';

const FeatureSection = () => {
const {featureSectionRef} = useMainPageYScroll();
const simpleTransferRef = useRef<HTMLElement>(null);

return (
<div
Expand All @@ -24,8 +27,8 @@ const FeatureSection = () => {
<SimpleShare />
<AutoCalculate />
<CheckDeposit />
<SimpleTransfer />
<RecordMemoryWithPhoto />
<SimpleTransfer targetRef={simpleTransferRef} />
<RecordMemoryWithPhoto targetRef={simpleTransferRef} />
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import {useRef} from 'react';

import useImageLazyLoading from '@hooks/useImageLazyLoading';

import {Text} from '@components/Design';

import {articleStyle, imageStyle, sectionStyle, textContainerStyle} from './RecordMemoryWithPhoto.style';

const RecordMemoryWithPhoto = () => {
type RecordMemoryWithPhotoProps = {
targetRef: React.RefObject<HTMLElement>;
};

const RecordMemoryWithPhoto = ({targetRef}: RecordMemoryWithPhotoProps) => {
const {imageSrc} = useImageLazyLoading({
targetRef,
src: `${process.env.IMAGE_URL}/feature5.svg`,
threshold: 0.05,
});

return (
<section css={sectionStyle}>
<article css={articleStyle}>
Expand All @@ -16,7 +30,7 @@ const RecordMemoryWithPhoto = () => {
정산은 투λͺ…ν•˜κ²Œ, 좔얡은 였래였래 간직할 수 μžˆμ–΄μš”.`}
</Text>
</div>
<object type="image/svg+xml" data={`${process.env.IMAGE_URL}/feature5.svg`} css={imageStyle} />
<object type="image/svg+xml" data={imgSrc} css={imageStyle} alt="행사 사진을 μ €μž₯ν•  수 μžˆλŠ” UI 이미지"
</article>
</section>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import {useRef} from 'react';

import useImageLazyLoading from '@hooks/useImageLazyLoading';

import {Text} from '@components/Design';

import {articleStyle, imageStyle, sectionStyle, textContainerStyle} from './SimpleShare.style';

const SimpleAccount = () => {
const sectionRef = useRef<HTMLElement>(null);

const {imageSrc} = useImageLazyLoading({
targetRef: sectionRef,
src: `${process.env.IMAGE_URL}/feature1.svg`,
threshold: 0.05,
});

return (
<section css={sectionStyle}>
<section css={sectionStyle} ref={sectionRef}>
<article css={articleStyle}>
<div css={textContainerStyle}>
<Text size="subTitle" responsive={true}>
Expand All @@ -16,7 +28,7 @@ const SimpleAccount = () => {
λ³΅μž‘ν•œ 절차 없이, λΉ λ₯΄κ²Œ 정산을 λ§ˆμΉ˜μ„Έμš”.`}
</Text>
</div>
<object type="image/svg+xml" data={`${process.env.IMAGE_URL}/feature1.svg`} css={imageStyle} />
<object type="image/svg+xml" data={imageSrc} css={imageStyle} />
</article>
</section>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import useImageLazyLoading from '@hooks/useImageLazyLoading';

import {Text} from '@components/Design';

import {articleStyle, imageStyle, sectionStyle, textContainerStyle} from './SimpleTransfer.style';

const SimpleTransfer = () => {
type SimpleTransferProps = {
targetRef: React.RefObject<HTMLElement>;
};

const SimpleTransfer = ({targetRef}: SimpleTransferProps) => {
const {imageSrc} = useImageLazyLoading({
targetRef,
src: `${process.env.IMAGE_URL}/feature4.svg`,
threshold: 0.05,
});

return (
<section css={sectionStyle}>
<section css={sectionStyle} ref={targetRef}>
<article css={articleStyle}>
<object type="image/svg+xml" data={`${process.env.IMAGE_URL}/feature4.svg`} css={imageStyle} />
<object type="image/svg+xml" data={imageSrc} css={imageStyle} />
<div css={textContainerStyle}>
<Text size="subTitle" responsive={true}>
λͺ‡ 번의 클릭으둜 μ†‘κΈˆ μ™„λ£Œ!
Expand Down
Loading

0 comments on commit 0ecc883

Please sign in to comment.