Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lit: Initial lit2 support #14600

Merged
merged 28 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f038204
feat(lit): add initial kitchen sink for lit
Apr 1, 2021
a465415
feat(lit): add lit package, setup eslint configs, initial render works
Apr 2, 2021
ca6e3ff
Merge branch 'next' into @storybook/lit
gaetanmaisse Apr 16, 2021
0a5835c
refactor(lit): activate TS strict mode and fix errors
gaetanmaisse Apr 16, 2021
f7d9e79
docs(lit): remove ref to web components and add a big warning
gaetanmaisse Apr 16, 2021
3481417
example(lit): remove addon knob as it will be deprecated in favor of …
gaetanmaisse Apr 16, 2021
3929d2e
fixup! example(lit): remove addon knob as it will be deprecated in fa…
gaetanmaisse Apr 16, 2021
c60c7d3
refactor(docs): remove babel-loader peer dep
gaetanmaisse Apr 18, 2021
a652a01
refactor(builders): require react in the SB app context as it is prov…
gaetanmaisse Apr 18, 2021
fd0fa99
example(lit): move the example out the Yarn workspaces of the monorepo
gaetanmaisse Apr 18, 2021
35916b9
Merge branch 'next' into @storybook/lit
gaetanmaisse Apr 23, 2021
3158799
example(lit): update to lit rc and fix stories
gaetanmaisse Apr 23, 2021
dcca003
Merge branch 'next' into @storybook/lit
gaetanmaisse Apr 26, 2021
009d137
Revert "refactor(builders): require react in the SB app context as it…
gaetanmaisse Apr 26, 2021
a0fe29a
example(lit): add stories for Addon Actions
gaetanmaisse Apr 26, 2021
211fda0
example(lit): add stories for Addon Background
gaetanmaisse Apr 26, 2021
58b9df6
example(lit): add stories for Addon Viewport
gaetanmaisse Apr 29, 2021
5ec74ec
example(lit): add stories for Addon Toolbars
gaetanmaisse May 4, 2021
5d1a395
feat(lit): bootstrap support of Lit in Addon Docs
gaetanmaisse May 4, 2021
68b9c1e
example(lit): add basic stories for Addon Docs
gaetanmaisse May 4, 2021
95961b2
example(lit): add stories for Addon Controls and improve "demo button"
gaetanmaisse May 4, 2021
a763df2
Merge branch 'next' into @storybook/lit
gaetanmaisse May 4, 2021
0a40da0
refactor(docs): extract prepareForInline and fix to TS errors
gaetanmaisse May 4, 2021
16062a0
example(lit): remove stories for deprecated features `info` and `note`
gaetanmaisse May 4, 2021
c1ee5ad
example(lit): filter `lit-kitchen-sink` from `yarn build-storybooks` …
gaetanmaisse May 5, 2021
e43a50c
Merge branch 'next' into pr/14600
shilman May 10, 2021
fa82eca
feat(lit): fix Deepscan warning and strengthen TypeScript compilation…
gaetanmaisse May 10, 2021
3cc3da4
example(lit): remove unused addons from dependencies
gaetanmaisse May 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ examples/angular-cli/addon-jest.testresults.json
!/.yarn/plugins
!/.yarn/sdks
!/.yarn/versions
/.pnp.*
.pnp.*
2 changes: 1 addition & 1 deletion addons/actions/src/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ addons.register(ADDON_ID, (api) => {
addons.addPanel(PANEL_ID, {
title() {
const [actionsCount, setActionsCount] = useState(0);
const onEvent = () => setActionsCount(previous => previous + 1);
const onEvent = () => setActionsCount((previous) => previous + 1);
const onChange = () => setActionsCount(0);

useEffect(() => {
Expand Down
23 changes: 12 additions & 11 deletions addons/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ For more information on `MDX`, see the [`MDX` reference](https://github.com/stor

Storybook Docs supports all view layers that Storybook supports except for React Native (currently). There are some framework-specific features as well, such as props tables and inline story rendering. This chart captures the current state of support:

| | React | Vue | Angular | Ember | Web Components | HTML | Svelte | Preact | Riot | Mithril | Marko |
| ----------------- | :---: | :-: | :-----: | :---: | :------------: | :--: | :----: | :----: | :--: | :-----: | :---: |
| MDX stories | + | + | + | + | + | + | + | + | + | + | + |
| CSF stories | + | + | + | + | + | + | + | + | + | + | + |
| StoriesOf stories | + | + | + | + | + | + | + | + | + | + | + |
| Source | + | + | + | + | + | + | + | + | + | + | + |
| Notes / Info | + | + | + | + | + | + | + | + | + | + | + |
| Props table | + | + | + | + | + | | | | | | |
| Props controls | + | + | + | | | | | | | | |
| Description | + | + | + | + | + | | | | | | |
| Inline stories | + | + | + | | + | + | | | | | |
| | React | Vue | Angular | Ember | Web Components | Marko | HTML | Svelte | Preact | Riot | Mithril | Marko |
| ----------------- | :---: | :-: | :-----: | :---: | :------------: | :---: | :--: | :----: | :----: | :--: | :-----: | :---: |
| MDX stories | + | + | + | + | + | WIP | + | + | + | + | + | + |
| CSF stories | + | + | + | + | + | WIP | + | + | + | + | + | + |
| StoriesOf stories | + | + | + | + | + | WIP | + | + | + | + | + | + |
| Source | + | + | + | + | + | WIP | + | + | + | + | + | + |
| Notes / Info | + | + | + | + | + | WIP | + | + | + | + | + | + |
| Props table | + | + | + | + | + | WIP | | | | | | |
| Props controls | + | + | + | | | WIP | | | | | | |
| Description | + | + | + | + | + | WIP | | | | | | |
| Inline stories | + | + | + | | + | WIP | + | | | | | |

**Note:** `#` = WIP support

Expand Down Expand Up @@ -139,6 +139,7 @@ Add the following to your Jest configuration:
- [Angular](https://github.com/storybookjs/storybook/tree/next/addons/docs/angular)
- [Ember](https://github.com/storybookjs/storybook/tree/next/addons/docs/ember)
- [Web Components](https://github.com/storybookjs/storybook/tree/next/addons/docs/web-components)
- [Lit](https://github.com/storybookjs/storybook/tree/next/addons/docs/lit)
- [Common setup (all other frameworks)](https://github.com/storybookjs/storybook/tree/next/addons/docs/common)

## Preset options
Expand Down
2 changes: 1 addition & 1 deletion addons/docs/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Storybook Docs transforms your Storybook stories into world-class component documentation. Docs supports [all web frameworks that Storybook supports](../README.md#framework-support).

Popular frameworks like [React](../react/README.md)/[Vue](../vue/README.md)/[Angular](../angular/README.md)/[Ember](../ember/README.md)/[Web components](../web-components/README.md) have their own framework-specific optimizations and setup guides. This README documents the "common" setup for other frameworks that don't have any docs-specific optimizations.
Popular frameworks like [React](../react/README.md)/[Vue](../vue/README.md)/[Angular](../angular/README.md)/[Ember](../ember/README.md)/[Web components](../web-components/README.md)/[Lit](../lit/README.md) have their own framework-specific optimizations and setup guides. This README documents the "common" setup for other frameworks that don't have any docs-specific optimizations.

- [Installation](#installation)
- [DocsPage](#docspage)
Expand Down
2 changes: 1 addition & 1 deletion addons/docs/docs/docspage.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ With that flag, now the docs addon will show all code blocks open by default.
## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md) / [Lit](../lit/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
2 changes: 1 addition & 1 deletion addons/docs/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ This is [Component Story Format (CSF)](https://medium.com/storybookjs/component-
## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md) / [Lit](../lit/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
2 changes: 1 addition & 1 deletion addons/docs/docs/mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ Be sure to update your Storybook config file to load `.stories.mdx` stories, as
## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md) / [Lit](../lit/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
4 changes: 2 additions & 2 deletions addons/docs/docs/multiframework.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {

This appends `vue-docgen-loader` to the existing configuration, which at this point will also include modifications made by the common preset.

For props tables and descriptions, both of which are described in more detail below, it defines a file [config.tsx](https://github.com/storybookjs/storybook/blob/next/addons/docs/src/frameworks/vue/config.tsx).
For props tables and descriptions, both of which are described in more detail below, it defines a file [config.jsx](https://github.com/storybookjs/storybook/blob/next/addons/docs/src/frameworks/vue/config.jsx).

## Arg tables

Expand Down Expand Up @@ -160,6 +160,6 @@ This configures the `jsxDecorator` to be run on every story.
## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md) / [Lit](../lit/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
5 changes: 3 additions & 2 deletions addons/docs/docs/props-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Storybook Docs automatically generates props tables for components in supported

## Usage

For framework-specific setup instructions, see the framework's README: [React](../react/README.md), [Vue](../vue/README.md), [Angular](../angular/README.md), [Web Components](../web-components/README.md), [Ember](../ember/README.md).
For framework-specific setup instructions, see the framework's README: [React](../react/README.md), [Vue](../vue/README.md), [Angular](../angular/README.md), [Web Components](../web-components/README.md), [Ember](../ember/README.md), [Lit](../lit/README.md).

### DocsPage

Expand Down Expand Up @@ -259,10 +259,11 @@ This package relies on a variety of sub-packages to extract property information
| Angular | `compodoc` | [Docs](../angular/README.md#props-tables) | [Open issues](https://github.com/storybookjs/storybook/issues?q=is%3Aopen+is%3Aissue+label%3A%22block%3A+props%22+label%3Abug+label%3A%22app%3A+angular%22) |
| Web-components | `custom-elements.json` | [Docs](../web-components/README.md#props-tables) | [Open issues](https://github.com/storybookjs/storybook/issues?q=is%3Aopen+is%3Aissue+label%3A%22block%3A+props%22+label%3Abug+label%3A%22app%3A+web-components%22) |
| Ember | `yui-doc` | [Docs](../ember/README.md#props-tables) | [Open issues](https://github.com/storybookjs/storybook/issues?q=is%3Aopen+is%3Aissue+label%3A%22block%3A+props%22+label%3Abug+label%3A%22app%3A+ember%22) |
| Lit -- ⚠️ WIP | WIP | [Docs](../lit/README.md#props-tables) | [Open issues](https://github.com/storybookjs/storybook/issues?q=is%3Aopen+is%3Aissue+label%3A%22block%3A+props%22+label%3Abug+label%3A%22app%3A+web-components%22) |

## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md) / [Lit](../lit/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
2 changes: 1 addition & 1 deletion addons/docs/docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,6 @@ Rest of your file...
## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md) / [Lit](../lit/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
2 changes: 1 addition & 1 deletion addons/docs/docs/theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ addParameters({
## More resources

- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md)
- Framework-specific docs: [React](../react/README.md) / [Vue](../vue/README.md) / [Angular](../angular/README.md) / [Web components](../web-components/README.md) / [Ember](../ember/README.md) / [Lit](../lit/README.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
46 changes: 46 additions & 0 deletions addons/docs/lit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<h1>Storybook Docs for Lit</h1>

- [Installation](#installation)
- [Props tables](#props-tables)
- [Stories not inline](#stories-not-inline)
- [More resources](#more-resources)

## Installation

- Be sure to check the [installation section of the general addon-docs page](../README.md) before proceeding.

WIP

## Props tables

WIP

## Stories not inline

By default stories are rendered inline.
For web components that is usually fine as they are style encapsulated via shadow dom.
However when you have a style tag in you template it might be best to show them in an iframe.

To always use iframes you can set

```js
addParameters({
docs: {
inlineStories: false,
},
});
```

or add it to individual stories.

```js
<Story inline={false} />
```

## More resources

Want to learn more? Here are some more articles on Storybook Docs:

- References: [DocsPage](../docs/docspage.md) / [MDX](../docs/mdx.md) / [FAQ](../docs/faq.md) / [Recipes](../docs/recipes.md) / [Theming](../docs/theming.md) / [Props](../docs/props-tables.md)
- Announcements: [Vision](https://medium.com/storybookjs/storybook-docs-sneak-peak-5be78445094a) / [DocsPage](https://medium.com/storybookjs/storybook-docspage-e185bc3622bf) / [MDX](https://medium.com/storybookjs/rich-docs-with-storybook-mdx-61bc145ae7bc) / [Framework support](https://medium.com/storybookjs/storybook-docs-for-new-frameworks-b1f6090ee0ea)
- Example: [Storybook Design System](https://github.com/storybookjs/design-system)
1 change: 1 addition & 0 deletions addons/docs/lit/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/esm/frameworks/lit/index');
10 changes: 10 additions & 0 deletions addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"react/**/*",
"vue/**/*",
"web-components/**/*",
"lit/**/*",
"README.md",
"*.js",
"*.d.ts",
Expand Down Expand Up @@ -102,6 +103,7 @@
"@emotion/core": "^10.1.1",
"@emotion/styled": "^10.0.27",
"@storybook/angular": "6.3.0-alpha.21",
"@storybook/lit": "6.3.0-alpha.21",
"@storybook/react": "6.3.0-alpha.21",
"@storybook/vue": "6.3.0-alpha.21",
"@storybook/web-components": "6.3.0-alpha.21",
Expand Down Expand Up @@ -135,9 +137,11 @@
},
"peerDependencies": {
"@storybook/angular": "6.3.0-alpha.21",
"@storybook/lit": "6.3.0-alpha.21",
"@storybook/vue": "6.3.0-alpha.21",
"@storybook/vue3": "6.3.0-alpha.21",
"@storybook/web-components": "6.3.0-alpha.21",
"lit": "^2.0.0-rc.1",
"lit-html": "^1.0.0",
"react": "^16.8.0 || ^17.0.0",
"react-dom": "^16.8.0 || ^17.0.0",
Expand All @@ -150,6 +154,9 @@
"@storybook/angular": {
"optional": true
},
"@storybook/lit": {
"optional": true
},
"@storybook/vue": {
"optional": true
},
Expand All @@ -159,6 +166,9 @@
"@storybook/web-components": {
"optional": true
},
"lit": {
"optional": true
},
"lit-html": {
"optional": true
},
Expand Down
8 changes: 8 additions & 0 deletions addons/docs/src/frameworks/lit/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { prepareForInline } from './prepareForInline';

export const parameters = {
docs: {
inlineStories: true,
prepareForInline,
},
};
22 changes: 22 additions & 0 deletions addons/docs/src/frameworks/lit/prepareForInline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { render, TemplateResult } from 'lit';

export const prepareForInline = (storyFn: () => TemplateResult) => {
const inlineStory = class Story extends React.Component {
readonly wrapperRef: React.RefObject<HTMLElement>;

constructor(props: unknown) {
super(props);
this.wrapperRef = React.createRef();
}

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

render() {
return React.createElement('div', { ref: this.wrapperRef });
}
};
return React.createElement(inlineStory);
};
6 changes: 6 additions & 0 deletions app/lit/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['../../.eslintrc.js'],
rules: {
'import/extensions': 0,
},
};