-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(story-decorator): add story decorator to replace knobs for theme…
… application
- Loading branch information
Showing
14 changed files
with
518 additions
and
92 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Description | ||
|
||
### Usage | ||
|
||
[![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/story-decorator?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/story-decorator) | ||
[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/story-decorator?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/story-decorator) | ||
|
||
``` | ||
yarn add @spectrum-web-components/story-decorator | ||
``` | ||
|
||
Import the side effectful registration of `<sp-story-decorator>` via: | ||
|
||
``` | ||
import '@spectrum-web-components/story-decorator/sp-story-decorator.js'; | ||
``` | ||
|
||
When looking to leverage the `StoryDecorator` base class as a type and/or for extension purposes, do so via: | ||
|
||
``` | ||
import { StoryDecorator } from '@spectrum-web-components/story-decorator'; | ||
``` | ||
|
||
## Example | ||
|
||
```html | ||
<sp-story-decorator></sp-story-decorator> | ||
``` |
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,43 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
import { html, TemplateResult, render } from 'lit-html'; | ||
import './sp-story-decorator.js'; | ||
|
||
export const themeStyles = html` | ||
<style> | ||
#root { | ||
padding: 0; | ||
} | ||
</style> | ||
`; | ||
|
||
export const swcThemeDecoratorWithConfig = ( | ||
{ bundled } = { bundled: true } | ||
) => (story: () => TemplateResult) => { | ||
if (!bundled) { | ||
requestAnimationFrame(() => { | ||
const decorator = document.querySelector( | ||
'sp-story-decorator' | ||
) as HTMLElement; | ||
render(story(), decorator); | ||
}); | ||
} | ||
return html` | ||
${themeStyles} | ||
<sp-story-decorator> | ||
${bundled ? story() : html``} | ||
</sp-story-decorator> | ||
`; | ||
}; | ||
|
||
export const swcThemeDecorator = swcThemeDecoratorWithConfig(); |
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,60 @@ | ||
{ | ||
"name": "@spectrum-web-components/story-decorator", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/adobe/spectrum-web-components.git", | ||
"directory": "packages/story-decorator" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/adobe/spectrum-web-components/issues" | ||
}, | ||
"homepage": "https://adobe.github.io/spectrum-web-components/projects/story-decorator", | ||
"keywords": [ | ||
"spectrum css", | ||
"web components", | ||
"lit-element", | ||
"lit-html" | ||
], | ||
"version": "0.0.1-beta.10", | ||
"description": "", | ||
"main": "./src/index.js", | ||
"module": "./src/index.js", | ||
"types": "./src/index.d.ts", | ||
"type": "module", | ||
"exports": { | ||
"./src/": "./src/", | ||
"./custom-elements.json": "./custom-elements.json", | ||
"./package.json": "./package.json", | ||
"./decorator": "./decorator.js", | ||
"./decorator.js": "./decorator.js", | ||
"./sp-story-decorator": "./sp-story-decorator.js", | ||
"./sp-story-decorator.js": "./sp-story-decorator.js" | ||
}, | ||
"files": [ | ||
"custom-elements.json", | ||
"*.ts", | ||
"*.js", | ||
"*.js.map", | ||
"/src/" | ||
], | ||
"sideEffects": [ | ||
"./sp-*.js", | ||
"./sp-*.ts" | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@spectrum-web-components/base": "^0.1.3", | ||
"@spectrum-web-components/theme": "^0.6.3", | ||
"@spectrum-web-components/dropdown": "^0.8.5", | ||
"@spectrum-web-components/menu": "^0.4.4", | ||
"@spectrum-web-components/switch": "^0.4.4", | ||
"tslib": "^2.0.0" | ||
} | ||
} |
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,21 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
import { StoryDecorator } from './src/StoryDecorator.js'; | ||
|
||
customElements.define('sp-story-decorator', StoryDecorator); | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'sp-story-decorator': StoryDecorator; | ||
} | ||
} |
Oops, something went wrong.