Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
88 changes: 88 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"react": "^19.2.0",
"react-apexcharts": "^2.0.1",
"react-dom": "^19.2.0",
"react-error-boundary": "^6.1.2",
"react-hook-form": "^7.71.1",
"react-markdown": "^10.1.0",
"react-remove-scroll": "^2.7.2",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/components/common/ComingSoonPlaceholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ComingSoonPlaceholder = memo(function ComingSoonPlaceholder({
)}
>
<motion.div
className="flex w-full max-w-[420px] flex-col items-center rounded-[32px] bg-surface-100 px-8 py-12 text-center shadow-Soft transition-ui-smooth tablet:px-6"
className="flex w-full max-w-105 flex-col items-center rounded-4xl bg-surface-100 px-8 py-12 text-center shadow-Soft transition-ui-smooth tablet:px-6"
role="status"
aria-live="polite"
initial="hidden"
Expand Down
28 changes: 28 additions & 0 deletions src/components/common/error/ChartErrorFallback.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";

import ChartErrorFallback from "./ChartErrorFallback";

const meta: Meta<typeof ChartErrorFallback> = {
title: "Common/Error/ChartErrorFallback",
component: ChartErrorFallback,
args: {
error: new Error("차트 데이터를 불러오지 못했습니다."),
resetErrorBoundary: fn(),
},
parameters: { layout: "centered" },
};

export default meta;
type TStory = StoryObj<typeof ChartErrorFallback>;

export const Default: TStory = {};

export const InCard: TStory = {
render: (args) => (
<div className="w-120 rounded-3xl bg-surface-100 p-7 shadow-Soft">
<p className="mb-4 font-heading4 text-text-title">실시간 트래픽 변화</p>
<ChartErrorFallback {...args} />
</div>
),
};
34 changes: 34 additions & 0 deletions src/components/common/error/ChartErrorFallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { memo } from "react";

import Button from "@/components/common/button/Button";

import type { FallbackProps } from "./ErrorBoundary";

import WarnCircleIcon from "@/assets/icon/common/warn-circle.svg?react";

const ChartErrorFallback = memo(function ChartErrorFallback({
resetErrorBoundary,
}: FallbackProps) {
return (
<div
role="alert"
className="flex min-h-40 w-full flex-1 flex-col items-center justify-center gap-4 rounded-2xl bg-surface-200/40 px-6 py-8 text-center"
>
<WarnCircleIcon
className="h-7 w-7 shrink-0 text-info-red"
aria-hidden="true"
/>
<div className="flex flex-col gap-1">
<p className="font-body1 text-text-title">차트를 불러오지 못했어요</p>
<p className="font-body2 text-text-muted">
일시적인 오류입니다. 잠시 후 다시 시도해 주세요.
</p>
</div>
<Button variant="outline" size="small" onClick={resetErrorBoundary}>
다시 시도
</Button>
</div>
);
});

export default ChartErrorFallback;
6 changes: 6 additions & 0 deletions src/components/common/error/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type { FallbackProps } from "react-error-boundary";
export {
ErrorBoundary,
useErrorBoundary,
withErrorBoundary,
} from "react-error-boundary";
27 changes: 27 additions & 0 deletions src/components/common/error/MetricErrorFallback.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";

import MetricErrorFallback from "./MetricErrorFallback";

const meta: Meta<typeof MetricErrorFallback> = {
title: "Common/Error/MetricErrorFallback",
component: MetricErrorFallback,
args: {
error: new Error("지표 데이터를 불러오지 못했습니다."),
resetErrorBoundary: fn(),
},
parameters: { layout: "centered" },
};

export default meta;
type TStory = StoryObj<typeof MetricErrorFallback>;

export const Default: TStory = {};

export const InGrid: TStory = {
render: (args) => (
<div className="grid w-200 grid-cols-4 gap-4">
<MetricErrorFallback {...args} />
</div>
),
};
34 changes: 34 additions & 0 deletions src/components/common/error/MetricErrorFallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { memo } from "react";

import Button from "@/components/common/button/Button";

import type { FallbackProps } from "./ErrorBoundary";

import WarnCircleIcon from "@/assets/icon/common/warn-circle.svg?react";

const MetricErrorFallback = memo(function MetricErrorFallback({
resetErrorBoundary,
}: FallbackProps) {
return (
<div
role="alert"
className="col-span-4 flex min-h-28 flex-col items-center justify-center gap-4 rounded-3xl border border-surface-200 bg-surface-100/80 px-6 py-8 text-center backdrop-blur-sm"
>
<WarnCircleIcon
className="h-8 w-8 shrink-0 text-info-red"
aria-hidden="true"
/>
<div className="flex flex-col gap-1">
<p className="font-body1 text-text-title">지표를 불러오지 못했어요</p>
<p className="font-body2 text-text-muted">
일시적인 오류입니다. 잠시 후 다시 시도해 주세요.
</p>
</div>
<Button variant="outline" size="small" onClick={resetErrorBoundary}>
다시 시도
</Button>
</div>
);
});

export default MetricErrorFallback;
Loading
Loading