Skip to content

Commit bf82332

Browse files
committed
Add parameter typings for addon-pseudo-state
1 parent c494cee commit bf82332

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

code/addons/pseudo-states/src/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,3 @@ export const PSEUDO_STATES = {
4141
link: 'link',
4242
target: 'target',
4343
} as const;
44-
45-
export type PseudoState = keyof typeof PSEUDO_STATES;
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { definePreviewAddon } from 'storybook/internal/csf';
22

33
import * as addonAnnotations from './preview';
4+
import type { PseudoTypes } from './types';
45

56
export { PARAM_KEY } from './constants';
67

7-
export default () => definePreviewAddon(addonAnnotations);
8+
export type { PseudoTypes } from './types';
9+
10+
export default () => definePreviewAddon<PseudoTypes>(addonAnnotations);

code/addons/pseudo-states/src/preview/withPseudoState.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,10 @@ import type { DecoratorFunction } from 'storybook/internal/types';
1212

1313
import { addons, useEffect, useMemo, useRef } from 'storybook/preview-api';
1414

15-
import type { PseudoState } from '../constants';
1615
import { PSEUDO_STATES } from '../constants';
16+
import type { PseudoParameter, PseudoState, PseudoStateConfig } from '../types';
1717
import { rewriteStyleSheet } from './rewriteStyleSheet';
1818

19-
type PseudoStateConfig = {
20-
[P in PseudoState]?: boolean | string | string[];
21-
};
22-
23-
export interface PseudoParameter extends PseudoStateConfig {
24-
rootSelector?: string;
25-
}
26-
2719
const channel = addons.getChannel();
2820
const shadowHosts = new Set<Element>();
2921

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { PSEUDO_STATES } from './constants';
2+
3+
export type PseudoState = keyof typeof PSEUDO_STATES;
4+
5+
export type PseudoStateConfig = {
6+
[P in PseudoState]?: boolean | string | string[];
7+
};
8+
9+
export interface PseudoParameter extends PseudoStateConfig {
10+
rootSelector?: string;
11+
}
12+
13+
export type PseudoParameters = {
14+
/**
15+
* Pseudo state configuration
16+
*
17+
* @see https://storybook.js.org/addons/storybook-addon-pseudo-states
18+
*/
19+
pseudo?: PseudoParameter;
20+
};
21+
22+
export interface PseudoTypes {
23+
parameters: PseudoParameters;
24+
}

0 commit comments

Comments
 (0)