Skip to content

Commit

Permalink
App-html: apply types within storybook/html
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio-martinez committed Jul 8, 2019
1 parent fee293e commit 5e38f19
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
16 changes: 14 additions & 2 deletions app/html/src/client/preview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { start } from '@storybook/core/client';
import './globals';
import render from './render';

export type StoriesOfArgs = [string, typeof module];

export type LoadFnArgs = [RequireContext, typeof module, string];

export interface RequireContext {
keys(): string[];
(id: string): any;
<T>(id: string): T;
resolve(id: string): string;
}

const { load: coreLoad, clientApi, configApi, forceReRender } = start(render);

export const {
Expand All @@ -15,8 +26,9 @@ export const {
} = clientApi;

const framework = 'html';
export const storiesOf = (...args) => clientApi.storiesOf(...args).addParameters({ framework });
export const load = (...args) => coreLoad(...args, framework);
export const storiesOf = (...args: StoriesOfArgs) =>
clientApi.storiesOf(...args).addParameters({ framework });
export const load = (...args: LoadFnArgs) => coreLoad(...args, framework);

export const { configure } = configApi;
export { forceReRender };
17 changes: 15 additions & 2 deletions app/html/src/client/preview/render.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import { document, Node } from 'global';
import { stripIndents } from 'common-tags';

export interface ShowErrorArgs {
title: string;
description: string;
}

export interface RenderMainArgs {
storyFn: () => string | Node | undefined;
selectedKind: string;
selectedStory: string;
showMain: () => void;
showError: (args: ShowErrorArgs) => void;
forceRender: boolean;
}

const rootElement = document.getElementById('root');

export default function renderMain({
parameters = {},
storyFn,
selectedKind,
selectedStory,
showMain,
showError,
forceRender,
}) {
}: RenderMainArgs) {
const element = storyFn();

showMain();
Expand Down
5 changes: 4 additions & 1 deletion app/html/src/server/framework-preset-html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export function webpack(config) {
// eslint-disable-next-line import/no-extraneous-dependencies
import { Configuration } from 'webpack';

export function webpack(config: Configuration) {
return {
...config,
module: {
Expand Down

0 comments on commit 5e38f19

Please sign in to comment.