Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wokbjso committed Oct 8, 2024
2 parents 346cec5 + 3d63746 commit db8edde
Show file tree
Hide file tree
Showing 26 changed files with 384 additions and 37 deletions.
15 changes: 15 additions & 0 deletions app/analyzers/clarity.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Script from 'next/script';

export const Clarity = () => {
return (
<Script id="clarity" type="text/javascript">
{`
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "o2k3nk4cvl");
`}
</Script>
);
};
1 change: 1 addition & 0 deletions app/analyzers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './clarity';
6 changes: 3 additions & 3 deletions app/join/finish/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default function Page() {
const router = useRouter();
const authInfo = useAtomValue(AuthInfoAtom);

const handleGoToMain = () => {
router.push('/');
const handleStartClick = () => {
router.push('/on-boarding');
};

return (
Expand All @@ -41,7 +41,7 @@ export default function Page() {
buttonType="primary"
size="large"
className={buttonStyles}
onClick={handleGoToMain}
onClick={handleStartClick}
/>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import MetaTagImage from '@/public/images/meta-tag.png';
import { css } from '@/styled-system/css';
import { pretendard } from '@/styles/font';

import { Clarity } from './analyzers';
import ReactQueryProvider from './providers/ReactQueryProvider';

export const metadata: Metadata = {
Expand Down Expand Up @@ -62,6 +63,9 @@ export default function RootLayout({
}>) {
return (
<html lang="ko" className={pretendard.className}>
<head>
<Clarity />
</head>
<body className={rootStyle}>
<ReactQueryProvider>
<ReactQueryDevtools initialIsOpen={true} />
Expand Down
101 changes: 101 additions & 0 deletions app/on-boarding/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
'use client';

import '../../features/on-boarding/steps.css';

import Link from 'next/link';
import { cloneElement, ReactElement } from 'react';
import { CSSTransition, TransitionGroup } from 'react-transition-group';

import { Button } from '@/components/atoms';
import { BackButton, HeaderBar } from '@/components/molecules';
import {
ProgressIndicator,
SkipButton,
Steps,
stepsIntroduce,
useProgressIndicator,
} from '@/features/on-boarding';
import { css } from '@/styled-system/css';

export default function OnBoarding() {
const { step, handlers } = useProgressIndicator();
return (
<div className={layoutStyles.total}>
<HeaderBar
className={css({
marginBottom: '43px',
})}
innerClassName={css({ backgroundColor: 'background.gray!' })}
>
<HeaderBar.LeftContent>
<BackButton />
</HeaderBar.LeftContent>
<HeaderBar.CenterContent>
<ProgressIndicator step={step} />
</HeaderBar.CenterContent>
<HeaderBar.RightContent>
{[
{
component: (
<SkipButton label="๊ฑด๋„ˆ๋›ฐ๊ธฐ" onClick={handlers.skip} />
),
key: 'skipButton',
},
]}
</HeaderBar.RightContent>
</HeaderBar>
<TransitionGroup
component={null}
childFactory={(child: ReactElement) => {
return cloneElement(child, {
classNames: 'fade',
});
}}
>
<CSSTransition key={step} timeout={200}>
<Steps current={step} />
</CSSTransition>
</TransitionGroup>
<div className={layoutStyles.button}>
{step < stepsIntroduce.length - 1 ? (
<Button
buttonType="secondary"
variant="outlined"
size="large"
label="๋‹ค์Œ"
interaction="normal"
onClick={() => handlers.next()}
className={css({ w: 'full' })}
/>
) : (
<Link href="/">
<Button
buttonType="primary"
variant="solid"
size="large"
label="์‹œ์ž‘ํ•˜๊ธฐ"
interaction="normal"
className={css({ w: 'full' })}
/>
</Link>
)}
</div>
</div>
);
}

const layoutStyles = {
total: css({
display: 'flex',
justifyContent: 'center',
backgroundColor: 'background.gray',
height: '100dvh',
}),
button: css({
w: 'full',
maxWidth: 'maxWidth',
position: 'fixed',
bottom: 'calc(15px + env(safe-area-inset-bottom))',
padding: '0 20px',
}),
};
70 changes: 44 additions & 26 deletions components/molecules/header-bar/header-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,36 @@ import {
import { css, cx } from '@/styled-system/css';
import { flex } from '@/styled-system/patterns';

import { leftIconStyles } from './style';

interface LeftContentProps {
interface CommonProps {
children?: ReactNode;
className?: string;
}

function LeftContent({ children, className }: LeftContentProps) {
return <div className={cx(leftIconStyles, className)}>{children}</div>;
function LeftContent({ children, className }: CommonProps) {
return (
<div className={cx(layoutStyles.leftContent, className)}>{children}</div>
);
}

interface TitleProps {
children?: ReactNode;
className?: string;
function Title({ children, className }: CommonProps) {
return (
<h3 className={cx(layoutStyles.centerContent, className)}>{children}</h3>
);
}

function Title({ children, className }: TitleProps) {
return <h3 className={cx(titleStyles, className)}>{children}</h3>;
function CenterContent({ children, className }: CommonProps) {
return (
<div className={cx(layoutStyles.centerContent, className)}>{children}</div>
);
}

interface RightContentProps {
interface RightContentProps extends Pick<CommonProps, 'className'> {
children?: { component: ReactNode; key: string | number }[];
className?: string;
}

function RightContent({ children, className }: RightContentProps) {
return (
<div className={cx(layoutStyles.rightIcon, className)}>
<div className={cx(layoutStyles.rightContent, className)}>
{children?.map((object) => (
<div key={object.key}>{object.component}</div>
))}
Expand All @@ -61,14 +63,24 @@ const getChildrenArray = (
interface HeaderBarProps {
children?: ReactNode;
className?: string;
innerClassName?: string;
}

function HeaderBarLayout({ children, className }: HeaderBarProps) {
function HeaderBarLayout({
children,
className,
innerClassName,
}: HeaderBarProps) {
const leftContent = getChildrenArray(
children,
1,
(<LeftContent />).type as FunctionComponent,
);
const centerContent = getChildrenArray(
children,
1,
(<CenterContent />).type as FunctionComponent,
);
const title = getChildrenArray(
children,
1,
Expand All @@ -82,9 +94,10 @@ function HeaderBarLayout({ children, className }: HeaderBarProps) {
return (
<>
<div style={{ height: '44px' }} className={className} />
<header className={layoutStyles.header}>
<div className={layoutStyles.content}>
<header className={cx(layoutStyles.header, innerClassName)}>
<div className={layoutStyles.totalContent}>
{leftContent}
{centerContent}
{title}
{rightContent}
</div>
Expand All @@ -96,6 +109,7 @@ function HeaderBarLayout({ children, className }: HeaderBarProps) {
export const HeaderBar = Object.assign(HeaderBarLayout, {
LeftContent,
Title,
CenterContent,
RightContent,
});

Expand All @@ -111,23 +125,27 @@ const layoutStyles = {
backgroundColor: 'white',
zIndex: 200,
}),
content: css({
totalContent: css({
position: 'relative',
display: 'flex',
alignItems: 'center',
w: 'full',
}),
rightIcon: flex({
leftContent: flex({
position: 'absolute',
alignItems: 'center',
left: '12px',
}),
centerContent: flex({
justifyContent: 'center',
alignItems: 'center',
w: 'full',
textStyle: 'heading6',
fontWeight: 500,
}),
rightContent: flex({
position: 'absolute',
right: '12px',
gap: '24px',
}),
};

const titleStyles = flex({
justifyContent: 'center',
alignItems: 'center',
w: 'full',
textStyle: 'heading6',
fontWeight: 500,
});
1 change: 0 additions & 1 deletion components/molecules/header-bar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from './header-bar';
export * from './header-bar-notification-button';
export * from './header-bar-setting-button';
export * from './header-logo-button';
export * from './style';
7 changes: 0 additions & 7 deletions components/molecules/header-bar/style.ts

This file was deleted.

1 change: 1 addition & 0 deletions features/on-boarding/components/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './skip-button';
20 changes: 20 additions & 0 deletions features/on-boarding/components/atoms/skip-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { css } from '@/styled-system/css';

interface SkipButtonProps {
label: string;
onClick: () => void;
}

export function SkipButton({ label, onClick }: SkipButtonProps) {
return (
<button onClick={onClick} className={skipButtonStyles}>
{label}
</button>
);
}

const skipButtonStyles = css({
textStyle: 'label1.normal',
color: 'text.alternative',
fontWeight: 500,
});
2 changes: 2 additions & 0 deletions features/on-boarding/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './atoms';
export * from './molecules';
2 changes: 2 additions & 0 deletions features/on-boarding/components/molecules/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './progress-indicator';
export * from './steps';
40 changes: 40 additions & 0 deletions features/on-boarding/components/molecules/progress-indicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { css, cva } from '@/styled-system/css';
import { flex } from '@/styled-system/patterns';

import { stepsIntroduce } from '../../constants';

interface ProgressIndicatorProps {
step: number;
}

export function ProgressIndicator({ step }: ProgressIndicatorProps) {
return (
<div className={progressIndicatorStyles}>
{Array.from({ length: stepsIntroduce.length }, (_, i) => (
<IndicatorDot key={i} selected={step === i} />
))}
</div>
);
}

interface IndicatorDotProps {
selected: boolean;
}

function IndicatorDot({ selected }: IndicatorDotProps) {
return <div className={css(indicatorDotStyles.raw({ selected }))} />;
}

const progressIndicatorStyles = flex({
gap: '6px',
});

const indicatorDotStyles = cva({
base: { display: 'flex', width: '6px', height: '6px', borderRadius: 'full' },
variants: {
selected: {
true: { backgroundColor: 'blue.70' },
false: { backgroundColor: 'line.neutral' },
},
},
});
Loading

0 comments on commit db8edde

Please sign in to comment.