Skip to content

Commit

Permalink
refactor: Storybook 에러 해결을 위한 Link 래퍼 구현
Browse files Browse the repository at this point in the history
related on: #22
  • Loading branch information
cobocho committed Jun 13, 2024
1 parent 2ecec55 commit 19beb0b
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"liveServer.settings.port": 5501
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { style } from '@vanilla-extract/css'

import { appearBottom } from '../../../../styles/animations.css'
import { appearBottom } from '@/styles/animations.css'

export const header = style({
marginBottom: 40,
Expand Down
11 changes: 5 additions & 6 deletions apps/web/src/app/(onboarding)/onboarding/funnel/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
SelectBox,
Text,
} from '@vook-client/design-system'
import Link from 'next/link'
import React from 'react'
import clsx from 'clsx'
import { OnboardingFunnel } from '@vook-client/api'

import { appearBottom } from '../../../../styles/animations.css'
import { Link } from '@/components/Link'
import { appearBottom } from '@/styles/animations.css'

import { SelectBoxGroup } from '../_components/SelectBoxGroup'
import { useOnBoarding } from '../_context/useOnboarding'
import { OnboardingHeader } from '../_components/OnboardingHeader'
Expand Down Expand Up @@ -71,8 +72,6 @@ const OnboardingFunnelPage = () => {
setFunnel(funnel)
}

const isStorybook = process.env.IS_STORYBOOK !== undefined

return (
<div>
<OnboardingHeader step={1} />
Expand Down Expand Up @@ -101,12 +100,12 @@ const OnboardingFunnelPage = () => {
</SelectBoxGroup>
</div>
<div className={buttonGroup}>
<Link prefetch={!isStorybook} href="/onboarding/job">
<Link href="/onboarding/job">
<Text type="body-2" color="label-alternative">
건너뛰기
</Text>
</Link>
<Link prefetch={!isStorybook} href="/onboarding/job">
<Link href="/onboarding/job">
<Button disabled={selectedFunnel === null} size="middle">
다음
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/(onboarding)/onboarding/job/page.css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { style } from '@vanilla-extract/css'

import { appearBottom } from '../../../../styles/animations.css'
import { appearBottom } from '@/styles/animations.css'

export const header = style({
marginBottom: 40,
Expand Down
11 changes: 5 additions & 6 deletions apps/web/src/app/(onboarding)/onboarding/job/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
SelectBox,
Text,
} from '@vook-client/design-system'
import Link from 'next/link'
import React from 'react'
import { OnboardingJob, useOnboardingMutation } from '@vook-client/api'
import { useRouter } from 'next/navigation'

import { Link } from '@/components/Link'

import { SelectBoxGroup } from '../_components/SelectBoxGroup'
import { useOnBoarding } from '../_context/useOnboarding'
import { OnboardingHeader } from '../_components/OnboardingHeader'
Expand Down Expand Up @@ -88,8 +89,6 @@ const OnboardingJobPage = () => {
setJob(job)
}

const isStorybook = process.env.IS_STORYBOOK !== undefined

return (
<div>
<OnboardingHeader step={2} />
Expand Down Expand Up @@ -118,17 +117,17 @@ const OnboardingJobPage = () => {
</SelectBoxGroup>
</div>
<div className={buttonGroup}>
<Link prefetch={!isStorybook} href="/">
<Link href="/">
<Text type="body-2" color="label-alternative">
건너뛰기
</Text>
</Link>
<Link prefetch={!isStorybook} href="/onboarding/funnel">
<Link href="/onboarding/funnel">
<Button filled={false} blueLine={false} size="middle">
뒤로가기
</Button>
</Link>
<Link prefetch={!isStorybook} href="/onboarding/job">
<Link href="/onboarding/job">
<Button
onClick={onSubmitFunnel}
size="middle"
Expand Down
8 changes: 8 additions & 0 deletions apps/web/src/components/Link/Link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React, { PropsWithChildren } from 'react'
import ActualLink, { LinkProps } from 'next/link'

export const Link = (props: LinkProps & PropsWithChildren) => {
const isStorybook = process.env.IS_STORYBOOK !== undefined

return <ActualLink {...props} prefetch={!isStorybook} />
}
1 change: 1 addition & 0 deletions apps/web/src/components/Link/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Link } from './Link'
3 changes: 2 additions & 1 deletion apps/workshop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"msw-storybook-addon": "^2.0.2",
"storybook": "^8.0.10",
"style-loader": "^4.0.0",
"vite": "^4.4.5"
"vite": "^4.4.5",
"vite-tsconfig-paths": "^4.3.2"
},
"msw": {
"workerDirectory": [
Expand Down
11 changes: 10 additions & 1 deletion apps/workshop/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"extends": "@vook-client/typescript-config/vite.json",
"include": [".storybook/*"]
"include": [".storybook/*"],
"compilerOptions": {
"paths": {
"@/providers/*": ["./src/providers/*"],
"@/components/*": ["./src/components/*"],
"@/styles/*": ["./src/styles/*"],
"@/utils/*": ["./src/utils/*"],
"@/mocks/*": ["./src/mocks/*"]
}
}
}
3 changes: 2 additions & 1 deletion apps/workshop/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [react(), tsconfigPaths()],
})
25 changes: 23 additions & 2 deletions pnpm-lock.yaml

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

0 comments on commit 19beb0b

Please sign in to comment.