forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style(web-components): refactor to TS
Split config functions into separate modules Add type and language to docs.source
- Loading branch information
1 parent
64efb26
commit fbacf4e
Showing
3 changed files
with
37 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
addons/docs/src/frameworks/web-components/prepareForInline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |