Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ body {

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb));
/* background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb)); */
}

a {
Expand Down
44 changes: 44 additions & 0 deletions packages/core/sds/src/components/ProgressIndicator/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { HTMLAttributes, PropsWithChildren, forwardRef } from 'react';

import { progressIndicatorCss, stepCss } from './styles';

export interface ProgressIndicatorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'style'> {
mode?: 'horizontal' | 'vertical';
totalStep: number;
currentStep: number;
}

export const ProgressIndicator = forwardRef<HTMLDivElement, PropsWithChildren<ProgressIndicatorProps>>(
({ mode = 'horizontal', totalStep, currentStep, children, ...rest }, ref) => {
const flexDirection = mode === 'horizontal' ? 'row' : 'column';
const currentStepIndex = Math.min(totalStep, currentStep) - 1;
const basis = 100 / totalStep;

return (
<div ref={ref} {...rest} css={progressIndicatorCss({ flexDirection })}>
{Array.from({ length: totalStep }).map((_, index) => (
<ProgressIndicator.Step key={index} isCurrent={index === currentStepIndex} basis={basis} />
))}
{children}
</div>
);
},
) as React.ForwardRefExoticComponent<ProgressIndicatorProps> & { Step: typeof Step };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForwardRefExoticComponent 라는 타입이란걸 처음 알았네요. 최근에 ref 때문에 다형성 컴포넌트 타입 추론 오류를 겪었는데 이게 해결책이 되겠군요.

@Doeunnkimm 아래 포스팅 보시면 Txt 다형성 컴포넌트 타입 추론 문제를 해결할 수 있을 것 같습니다.

Polymorphic한 React 컴포넌트 만들기


export interface StepProps extends HTMLAttributes<HTMLSpanElement> {
basis: number;
isCurrent: boolean;
}

const Step = ({ isCurrent, basis, ...rest }: StepProps) => {
let color = '#E1E1E1';

if (isCurrent) {
color = '#FF7664';
}

return <span {...rest} css={stepCss({ basis, color })} />;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단순한 궁금증인데 span 태그로 하신 이유가 있을까요??

};

ProgressIndicator.displayName = 'ProgressIndicator';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요 친구는 무슨 용도인가요??

ProgressIndicator.Step = Step;
16 changes: 16 additions & 0 deletions packages/core/sds/src/components/ProgressIndicator/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { css } from '@emotion/react';

import { ProgressIndicatorCssArgs, StepCssArgs } from './type';

export const progressIndicatorCss = ({ flexDirection }: ProgressIndicatorCssArgs) =>
css({ width: '100%', display: 'flex', flexWrap: 'nowrap', flexDirection });

export const stepCss = ({ basis, color }: StepCssArgs) =>
css({
boxSizing: 'border-box',
flex: `${basis}% 1 1`,
height: '4px',
backgroundColor: color,
borderRadius: '8px',
margin: '2px',
});
8 changes: 8 additions & 0 deletions packages/core/sds/src/components/ProgressIndicator/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type ProgressIndicatorCssArgs = {
flexDirection: 'row' | 'column';
};

export type StepCssArgs = {
color: string;
basis: number;
};
1 change: 1 addition & 0 deletions packages/core/sds/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { Button } from './components/Button';
export { Card } from './components/Card';
export { Code } from './components/Code';
export { ProgressIndicator } from './components/ProgressIndicator';
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
'use client';

import { FirstFeatureOfFirstDomainBox } from '../components/FirstFeatureOfFirstDomainTestBox';
import { FirstFeatureOfFirstDomainTestButton } from '../components/FirstFeatureOfFirstDomainTestButton';
import { useFirstFeatureOfFirstDomainService } from '../services/useFirstFeatureOfFirstDomainTestService';
import { ProgressIndicator } from '@sambad/sds';

export const FirstFeatureOfFirstDomainTestContainer = () => {
const { displayText, handleChangeDisplayText, data } = useFirstFeatureOfFirstDomainService();

return (
<FirstFeatureOfFirstDomainBox displayText={displayText} onClick={handleChangeDisplayText}>
<FirstFeatureOfFirstDomainTestButton
onClick={() => {
alert('Button is Clicked at Container');
}}
/>
<div css={{ width: '200px', height: '200px', backgroundColor: 'red' }}>{data}</div>
</FirstFeatureOfFirstDomainBox>
<div css={{ maxWidth: '600px;', margin: '0 auto' }}>
<ProgressIndicator totalStep={10} currentStep={7} />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const FirstDomainExampleScreen = async () => {
return (
<HydrationBoundary state={dehydrate(queryClient)}>
<div>
<h1>도메인 화면을 전체 담당 하는 컴포넌트입니다.</h1>
<FirstFeatureOfFirstDomainTestContainer />
</div>
</HydrationBoundary>
Expand Down
22 changes: 12 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.