-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19315 from storybookjs/shilman/web-componets-vite…
…-framework Vite: Add web-components/lit support
- Loading branch information
Showing
23 changed files
with
266 additions
and
12 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
console.log('vue3-vite preset!'); | ||
module.exports = require('./dist/preset'); |
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 @@ | ||
# Storybook for Web components |
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,86 @@ | ||
{ | ||
"name": "@storybook/web-components-vite", | ||
"version": "7.0.0-alpha.34", | ||
"description": "Storybook for web-components and Vite: Develop Web Components in isolation with Hot Reloading.", | ||
"keywords": [ | ||
"storybook" | ||
], | ||
"homepage": "https://github.com/storybookjs/storybook/tree/main/frameworks/web-components-vite", | ||
"bugs": { | ||
"url": "https://github.com/storybookjs/storybook/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/storybookjs/storybook.git", | ||
"directory": "frameworks/web-components-vite" | ||
}, | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/storybook" | ||
}, | ||
"license": "MIT", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"./preset": { | ||
"require": "./dist/preset.js", | ||
"import": "./dist/preset.mjs", | ||
"types": "./dist/preset.d.ts" | ||
}, | ||
"./package.json": { | ||
"require": "./package.json", | ||
"import": "./package.json", | ||
"types": "./package.json" | ||
} | ||
}, | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*", | ||
"types/**/*", | ||
"README.md", | ||
"*.js", | ||
"*.d.ts" | ||
], | ||
"scripts": { | ||
"check": "tsc --noEmit", | ||
"prep": "../../../scripts/prepare/bundle.ts" | ||
}, | ||
"dependencies": { | ||
"@storybook/addons": "7.0.0-alpha.34", | ||
"@storybook/builder-vite": "7.0.0-alpha.34", | ||
"@storybook/channel-postmessage": "7.0.0-alpha.34", | ||
"@storybook/channel-websocket": "7.0.0-alpha.34", | ||
"@storybook/client-api": "7.0.0-alpha.34", | ||
"@storybook/core-server": "7.0.0-alpha.34", | ||
"@storybook/node-logger": "7.0.0-alpha.34", | ||
"@storybook/preview-web": "7.0.0-alpha.34", | ||
"@storybook/web-components": "7.0.0-alpha.34", | ||
"@vitejs/plugin-vue": "^3.0.3", | ||
"magic-string": "^0.26.1", | ||
"vite": "3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.20 || ^16.0.0", | ||
"typescript": "~4.6.3", | ||
"vite": "^3.1.0" | ||
}, | ||
"engines": { | ||
"node": "^14.18 || >=16" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"bundler": { | ||
"entries": [ | ||
"./src/index.ts", | ||
"./src/preset.ts" | ||
], | ||
"platform": "node" | ||
}, | ||
"gitHead": "02c013c33186479017098d532a18ff8654b91f1f" | ||
} |
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 @@ | ||
module.exports = require('./dist/preset'); |
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,9 @@ | ||
// exports for builder-vite | ||
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage'; | ||
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket'; | ||
export { addons } from '@storybook/addons'; | ||
export { composeConfigs, PreviewWeb } from '@storybook/preview-web'; | ||
export { ClientApi } from '@storybook/client-api'; | ||
|
||
export * from '@storybook/web-components'; | ||
export type { StorybookConfig } from '@storybook/builder-vite'; |
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,7 @@ | ||
import type { StorybookConfig } from '@storybook/builder-vite'; | ||
|
||
export const addons: StorybookConfig['addons'] = ['@storybook/web-components']; | ||
|
||
export const core: StorybookConfig['core'] = { | ||
builder: '@storybook/builder-vite', | ||
}; |
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,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"types": ["node"], | ||
"resolveJsonModule": true | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"] | ||
} |
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
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
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
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
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
3 changes: 2 additions & 1 deletion
3
code/renderers/web-components/src/docs/sourceDecorator.test.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
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
22 changes: 22 additions & 0 deletions
22
code/renderers/web-components/template/components/Button.js
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,22 @@ | ||
/* eslint-disable import/extensions */ | ||
import { html } from 'lit-html'; | ||
import { styleMap } from 'lit-html/directives/style-map.js'; | ||
import './button.css'; | ||
|
||
/** | ||
* Primary UI component for user interaction | ||
*/ | ||
export const Button = ({ primary, backgroundColor = null, size, label, onClick }) => { | ||
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; | ||
|
||
return html` | ||
<button | ||
type="button" | ||
class=${['storybook-button', `storybook-button--${size || 'medium'}`, mode].join(' ')} | ||
style=${styleMap({ backgroundColor })} | ||
@click=${onClick} | ||
> | ||
${label} | ||
</button> | ||
`; | ||
}; |
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,14 @@ | ||
/* eslint-disable import/extensions */ | ||
import { html } from 'lit-html'; | ||
import { styleMap } from 'lit-html/directives/style-map.js'; | ||
|
||
/** | ||
* Helper component for rendering text or data | ||
*/ | ||
export const Pre = ({ style, object, text }) => | ||
html` | ||
<pre data-testid="pre" style=${styleMap({ style })}> | ||
${object ? JSON.stringify(object, null, 2) : text} | ||
</pre | ||
> | ||
`; |
30 changes: 30 additions & 0 deletions
30
code/renderers/web-components/template/components/button.css
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,30 @@ | ||
.storybook-button { | ||
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; | ||
font-weight: 700; | ||
border: 0; | ||
border-radius: 3em; | ||
cursor: pointer; | ||
display: inline-block; | ||
line-height: 1; | ||
} | ||
.storybook-button--primary { | ||
color: white; | ||
background-color: #1ea7fd; | ||
} | ||
.storybook-button--secondary { | ||
color: #333; | ||
background-color: transparent; | ||
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset; | ||
} | ||
.storybook-button--small { | ||
font-size: 12px; | ||
padding: 10px 16px; | ||
} | ||
.storybook-button--medium { | ||
font-size: 14px; | ||
padding: 11px 20px; | ||
} | ||
.storybook-button--large { | ||
font-size: 16px; | ||
padding: 12px 24px; | ||
} |
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,6 @@ | ||
import globalThis from 'global'; | ||
|
||
import { Button } from './Button'; | ||
import { Pre } from './Pre'; | ||
|
||
globalThis.Components = { Button, Pre }; |
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 @@ | ||
Placeholder until we write some render-specific stories |
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
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
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
Oops, something went wrong.