Skip to content

Commit

Permalink
style(web-components): refactor to TS
Browse files Browse the repository at this point in the history
Split config functions into separate modules

Add type and language to docs.source
  • Loading branch information
bennypowers committed Jun 24, 2021
1 parent 64efb26 commit fbacf4e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
31 changes: 0 additions & 31 deletions addons/docs/src/frameworks/web-components/config.js

This file was deleted.

19 changes: 19 additions & 0 deletions addons/docs/src/frameworks/web-components/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { extractArgTypes, extractComponentDescription } from './custom-elements';
import { sourceDecorator } from './sourceDecorator';
import { prepareForInline } from './prepareForInline';
import { SourceType } from '../../shared';

export const decorators = [sourceDecorator];

export const parameters = {
docs: {
extractArgTypes,
extractComponentDescription,
inlineStories: true,
prepareForInline,
source: {
type: SourceType.DYNAMIC,
language: 'html',
},
},
};
18 changes: 18 additions & 0 deletions addons/docs/src/frameworks/web-components/prepareForInline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { StoryFn } from '@storybook/addons';
import React from 'react';
import { render } from 'lit-html';

export const prepareForInline = (storyFn: StoryFn) => {
class Story extends React.Component {
wrapperRef = React.createRef<HTMLElement>();

componentDidMount(): void {
render(storyFn(), this.wrapperRef.current);
}

render(): React.ReactElement {
return React.createElement('div', { ref: this.wrapperRef });
}
}
return React.createElement(Story);
};

0 comments on commit fbacf4e

Please sign in to comment.