-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change mechanism for detecting addon docs being active
- Loading branch information
Showing
9 changed files
with
27 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
import type { StorybookConfig, LoadedPreset } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
|
||
import { join } from 'path'; | ||
|
||
export const addons: StorybookConfig['addons'] = [ | ||
require.resolve('@storybook/react-dom-shim/dist/preset'), | ||
]; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import type { LoadedPreset, StorybookConfig } from '@storybook/types'; | ||
import type { StorybookConfig } from '@storybook/types'; | ||
import { join } from 'path'; | ||
|
||
const hasDocs = (presetsList: LoadedPreset[]) => { | ||
return presetsList.some((preset: string | { name: string }) => { | ||
const presetName = typeof preset === 'string' ? preset : preset.name; | ||
return presetName.includes('@storybook/addon-docs'); | ||
}); | ||
}; | ||
|
||
export const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input, options) => { | ||
const { presetsList } = options; | ||
if (!presetsList) { | ||
return input; | ||
} | ||
const docsInList = hasDocs(presetsList); | ||
const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0; | ||
const result: string[] = []; | ||
|
||
return result | ||
.concat(input) | ||
.concat([join(__dirname, 'preview.mjs')]) | ||
.concat(docsInList ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
.concat(docsEnabled ? [join(__dirname, 'preview-docs.mjs')] : []); | ||
}; |