mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 16:51:09 +08:00
Merge pull request #9020 from aromanarguello/emberType
Migrate ember to TS
This commit is contained in:
commit
fc20697cf0
@ -15,7 +15,8 @@ export const {
|
||||
} = clientApi;
|
||||
|
||||
const framework = 'ember';
|
||||
export const storiesOf = (...args) => clientApi.storiesOf(...args).addParameters({ framework });
|
||||
export const configure = (...args) => coreConfigure(...args, framework);
|
||||
export const storiesOf = (...args: any) =>
|
||||
clientApi.storiesOf(...args).addParameters({ framework });
|
||||
export const configure = (...args: any) => coreConfigure(...args, framework);
|
||||
|
||||
export { forceReRender };
|
@ -1,6 +1,8 @@
|
||||
/* eslint-disable no-undef */
|
||||
import { window, document } from 'global';
|
||||
import dedent from 'ts-dedent';
|
||||
import { RenderMainArgs, ElementArgs, OptionsArgs } from './types';
|
||||
|
||||
declare let Ember: any;
|
||||
|
||||
const rootEl = document.getElementById('root');
|
||||
|
||||
@ -14,11 +16,11 @@ const app = window.require(`${window.STORYBOOK_NAME}/app`).default.create({
|
||||
let lastPromise = app.boot();
|
||||
let hasRendered = false;
|
||||
|
||||
function render(options, el) {
|
||||
function render(options: OptionsArgs, el: ElementArgs) {
|
||||
const { template, context = {}, element } = options;
|
||||
|
||||
if (hasRendered) {
|
||||
lastPromise = lastPromise.then(instance => instance.destroy());
|
||||
lastPromise = lastPromise.then((instance: any) => instance.destroy());
|
||||
}
|
||||
|
||||
lastPromise = lastPromise
|
||||
@ -26,7 +28,7 @@ function render(options, el) {
|
||||
const appInstancePrivate = app.buildInstance();
|
||||
return appInstancePrivate.boot().then(() => appInstancePrivate);
|
||||
})
|
||||
.then(instance => {
|
||||
.then((instance: any) => {
|
||||
instance.register(
|
||||
'component:story-mode',
|
||||
Ember.Component.extend({
|
||||
@ -56,8 +58,7 @@ export default function renderMain({
|
||||
selectedStory,
|
||||
showMain,
|
||||
showError,
|
||||
// forceRender,
|
||||
}) {
|
||||
}: RenderMainArgs) {
|
||||
const element = storyFn();
|
||||
|
||||
if (!element) {
|
24
app/ember/src/client/preview/types.ts
Normal file
24
app/ember/src/client/preview/types.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { StoryFn } from '@storybook/addons'; // eslint-disable-line
|
||||
|
||||
export interface RenderMainArgs {
|
||||
storyFn: StoryFn<any>;
|
||||
selectedKind: string;
|
||||
selectedStory: string;
|
||||
showMain: () => void;
|
||||
showError: (args: ShowErrorArgs) => void;
|
||||
}
|
||||
|
||||
export interface ShowErrorArgs {
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface ElementArgs {
|
||||
el: HTMLElement;
|
||||
}
|
||||
|
||||
export interface OptionsArgs {
|
||||
template: any;
|
||||
context: any;
|
||||
element: any;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import { precompile } from 'ember-source/dist/ember-template-compiler';
|
||||
import { Configuration } from 'webpack'; // eslint-disable-line
|
||||
|
||||
export function babel(config) {
|
||||
export function babel(config: Configuration) {
|
||||
const babelConfigPlugins = config.plugins || [];
|
||||
|
||||
const extraPlugins = [
|
@ -1,4 +1,4 @@
|
||||
import packageJson from '../../package.json';
|
||||
const packageJson = require('../../package.json');
|
||||
|
||||
export default {
|
||||
packageJson,
|
3
app/ember/src/typings.d.ts
vendored
Normal file
3
app/ember/src/typings.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
declare module '@storybook/core/*';
|
||||
declare module 'ember-source/dist/ember-template-compiler';
|
||||
declare module 'global';
|
10
app/ember/tsconfig.json
Normal file
10
app/ember/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"types": ["webpack-env"],
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src/**/*", "package.json"],
|
||||
"exclude": ["src/**/*.test.*"]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user