Skip to content

Commit 601c3a1

Browse files
authored
Merge pull request #14941 from TylerAPfledderer/refactor/storybook-dir-path-alias
refactor: create import alias for `.storybook` directory
2 parents 90cbc7b + 3f31dc8 commit 601c3a1

File tree

12 files changed

+25
-14
lines changed

12 files changed

+25
-14
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
["^@/data"],
3434
// From the `constants` directory.
3535
["^@/lib/constants"],
36-
// From the `.storybook/utils` file
37-
["^@/storybook-utils"],
36+
// `.storybook` directory and utils files`
37+
["^@/storybook","^@/storybook-utils"],
3838
// Parent imports. Put `..` last.
3939
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
4040
// Other relative imports. Put same-folder imports and `.` last.

.storybook/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from "path"
2+
13
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"
24
import type { StorybookConfig } from "@storybook/nextjs"
35

@@ -51,6 +53,11 @@ const config: StorybookConfig = {
5153
extensions: config.resolve.extensions,
5254
}),
5355
]
56+
57+
config.resolve.alias = {
58+
...config.resolve.alias,
59+
"@/storybook/*": path.resolve(__dirname, "./.storybook/"),
60+
}
5461
}
5562

5663
// This modifies the existing image rule to exclude .svg files

src/components/Hero/ContentHero/ContentHero.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useTranslations } from "next-intl"
22
import { Meta, StoryObj } from "@storybook/react"
33

4-
import { langViewportModes } from "../../../../.storybook/modes"
4+
import { langViewportModes } from "@/storybook/modes"
55

66
import ContentHeroComponent, { ContentHeroProps } from "."
77

src/components/Hero/HomeHero/HomeHero.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { Meta, StoryObj } from "@storybook/react"
22

3-
import { langViewportModes } from "../../../../.storybook/modes"
3+
import { langViewportModes } from "@/storybook/modes"
44

55
import HomeHeroComponent from "."
66

7+
import homeHeroImg from "@/public/images/home/hero.png"
8+
79
const meta = {
810
title: "Organisms / Layouts / Hero",
911
component: HomeHeroComponent,
@@ -26,8 +28,6 @@ const meta = {
2628

2729
export default meta
2830

29-
import homeHeroImg from "@/public/images/home/hero.png"
30-
3131
export const HomeHero: StoryObj<typeof meta> = {
3232
args: {
3333
heroImg: homeHeroImg,

src/components/Hero/HubHero/HubHero.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Meta, StoryObj } from "@storybook/react"
44

55
import { screens } from "@/lib/utils/screen"
66

7-
import { langViewportModes } from "../../../../.storybook/modes"
7+
import { langViewportModes } from "@/storybook/modes"
88

99
import HubHeroComponent, { type HubHeroProps } from "./"
1010

src/components/Hero/MdxHero/MdxHero.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HStack } from "@/components/ui/flex"
55

66
import { screens } from "@/lib/utils/screen"
77

8-
import { langViewportModes } from "../../../../.storybook/modes"
8+
import { langViewportModes } from "@/storybook/modes"
99

1010
import MdxHeroComponent from "./"
1111

src/components/MdComponents/MdComponents.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pickBy from "lodash/pickBy"
22
import type { Meta, StoryObj } from "@storybook/react/*"
33

4-
import { viewportModes } from "../../../.storybook/modes"
4+
import { viewportModes } from "@/storybook/modes"
55

66
import MdComponentSet from "."
77

src/components/MergeInfographic/MergeInfographic.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meta, StoryObj } from "@storybook/react"
22

3-
import { langViewportModes } from "../../../.storybook/modes"
3+
import { langViewportModes } from "@/storybook/modes"
44

55
import MergeInfographicComponent from "."
66

src/components/Simulator/__stories__/Explanation.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import pickBy from "lodash/pickBy"
22
import type { Meta, StoryObj } from "@storybook/react"
33
import { fn } from "@storybook/test"
44

5-
import { viewportModes } from "../../../../.storybook/modes"
5+
import { viewportModes } from "@/storybook/modes"
6+
67
import { Explanation as ExplanationComponent } from "../Explanation"
78
import { SendReceiveIcon } from "../icons"
89

src/layouts/stories/BaseLayout.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import type { Meta, StoryObj } from "@storybook/react"
22

33
import { Center } from "@/components/ui/flex"
44

5-
import { langViewportModes } from "../../../.storybook/modes"
5+
import { langViewportModes } from "@/storybook/modes"
6+
67
import { BaseLayout as BaseLayoutComponent } from "../BaseLayout"
78

89
const meta = {

0 commit comments

Comments
 (0)