api-viewer-element
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -19,2 +19,13 @@ # Change Log | ||
## [0.2.4] - 2019-11-11 | ||
### Fixed | ||
- Docs: tabs are no longer shown if there is no documented API | ||
- Demo: knobs are now hidden if there is no properties / slots | ||
### Changed | ||
- Demo: adjusted source code snippet vertical padding | ||
## [0.2.3] - 2019-11-06 | ||
@@ -21,0 +32,0 @@ |
import { __decorate } from "tslib"; | ||
import { LitElement, html, customElement, css, property } from 'lit-element'; | ||
import { getSlotTitle } from './lib/utils.js'; | ||
import { getSlotTitle, isEmptyArray } from './lib/utils.js'; | ||
import './api-viewer-demo-renderer.js'; | ||
@@ -42,4 +42,5 @@ import './api-viewer-demo-knobs.js'; | ||
render() { | ||
const noEvents = this.events.length === 0; | ||
const noCss = this.cssProps.length === 0; | ||
const noEvents = isEmptyArray(this.events); | ||
const noCss = isEmptyArray(this.cssProps); | ||
const noKnobs = isEmptyArray(this.props) && isEmptyArray(this.slots); | ||
return html ` | ||
@@ -63,3 +64,7 @@ <api-viewer-demo-renderer | ||
</api-viewer-panel> | ||
<api-viewer-tab heading="Knobs" slot="tab"></api-viewer-tab> | ||
<api-viewer-tab | ||
heading="Knobs" | ||
slot="tab" | ||
?hidden="${noKnobs}" | ||
></api-viewer-tab> | ||
<api-viewer-panel slot="panel"> | ||
@@ -72,2 +77,3 @@ <api-viewer-demo-knobs | ||
@slot-changed="${this._onSlotChanged}" | ||
?hidden="${noKnobs}" | ||
></api-viewer-demo-knobs> | ||
@@ -74,0 +80,0 @@ </api-viewer-panel> |
@@ -87,3 +87,3 @@ import { __decorate } from "tslib"; | ||
position: relative; | ||
padding: 1rem; | ||
padding: 0.75rem 1rem; | ||
} | ||
@@ -90,0 +90,0 @@ |
import { __decorate } from "tslib"; | ||
import { LitElement, html, customElement, css, property } from 'lit-element'; | ||
import { isEmptyArray } from './lib/utils.js'; | ||
import './api-viewer-item.js'; | ||
@@ -8,2 +9,3 @@ import './api-viewer-panel.js'; | ||
import './api-viewer-tabs.js'; | ||
import { ApiViewerTabs } from './api-viewer-tabs.js'; | ||
/* eslint-enable import/no-duplicates */ | ||
@@ -108,2 +110,6 @@ const processAttrs = (attrs, props) => { | ||
} | ||
.warn { | ||
padding: 1rem; | ||
} | ||
`; | ||
@@ -115,9 +121,24 @@ } | ||
const properties = processProps(props || [], attrs || []); | ||
return html ` | ||
<api-viewer-tabs> | ||
${renderProperties(properties)}${renderAttributes(attributes)} | ||
${renderSlots(slots)}${renderEvents(events)}${renderCssProps(cssProps)} | ||
${renderCssParts(cssParts)} | ||
</api-viewer-tabs> | ||
`; | ||
const emptyDocs = [ | ||
properties, | ||
attributes, | ||
slots, | ||
events, | ||
cssProps, | ||
cssParts | ||
].every(isEmptyArray); | ||
return emptyDocs | ||
? html ` | ||
<div class="warn"> | ||
The element <${this.name}> does not provide any documented | ||
API. | ||
</div> | ||
` | ||
: html ` | ||
<api-viewer-tabs> | ||
${renderProperties(properties)}${renderAttributes(attributes)} | ||
${renderSlots(slots)}${renderEvents(events)}${renderCssProps(cssProps)} | ||
${renderCssParts(cssParts)} | ||
</api-viewer-tabs> | ||
`; | ||
} | ||
@@ -128,3 +149,5 @@ updated(props) { | ||
const tabs = this.renderRoot.querySelector('api-viewer-tabs'); | ||
tabs.selectFirst(); | ||
if (tabs instanceof ApiViewerTabs) { | ||
tabs.selectFirst(); | ||
} | ||
} | ||
@@ -131,0 +154,0 @@ } |
@@ -5,2 +5,3 @@ export declare const getSlotTitle: (name: string) => string; | ||
export declare const hasTemplate: (name: string) => boolean; | ||
export declare const isEmptyArray: (array: unknown[]) => boolean; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -14,2 +14,3 @@ export const getSlotTitle = (name) => { | ||
}; | ||
export const isEmptyArray = (array) => array.length === 0; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "api-viewer-element", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Web Components API viewer element", | ||
@@ -5,0 +5,0 @@ "author": "Serhii Kulykov <iamkulykov@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
205486
2479