Skip to content

Commit 64ab797

Browse files
authored
Merge pull request storybookjs#35044 from ShaharAviram1/expose-backgrounds-public-subpath
Core: Expose backgrounds types from public subpath
2 parents 20869a1 + 4ef63dc commit 64ab797

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

code/core/build-config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ const config: BuildEntries = {
118118
exportEntries: ['./actions/decorator'],
119119
entryPoint: './src/actions/decorator.ts',
120120
},
121+
{
122+
exportEntries: ['./backgrounds'],
123+
entryPoint: './src/backgrounds/index.ts',
124+
},
121125
{
122126
exportEntries: ['./viewport'],
123127
entryPoint: './src/viewport/index.ts',

code/core/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
"code": "./src/actions/decorator.ts",
5757
"default": "./dist/actions/decorator.js"
5858
},
59+
"./backgrounds": {
60+
"types": "./dist/backgrounds/index.d.ts",
61+
"code": "./src/backgrounds/index.ts",
62+
"default": "./dist/backgrounds/index.js"
63+
},
5964
"./highlight": {
6065
"types": "./dist/highlight/index.d.ts",
6166
"code": "./src/highlight/index.ts",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { expectTypeOf } from 'vitest';
2+
3+
import { DEFAULT_BACKGROUNDS } from 'storybook/backgrounds';
4+
import type { Background, BackgroundMap } from 'storybook/backgrounds';
5+
6+
expectTypeOf<BackgroundMap>().toEqualTypeOf<Record<string, Background>>();
7+
8+
expectTypeOf(DEFAULT_BACKGROUNDS).toEqualTypeOf<BackgroundMap>();
9+
10+
const customBackgrounds = {
11+
light: { name: 'Light', value: '#ffffff' },
12+
dark: { name: 'Dark', value: '#1a1a1a' },
13+
} satisfies BackgroundMap;
14+
15+
expectTypeOf(customBackgrounds.light).toExtend<Background>();

code/core/src/backgrounds/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './constants.ts';
2+
export * from './types.ts';
3+
export * from './defaults.ts';

0 commit comments

Comments
 (0)