diff --git a/README.md b/README.md index d79475c..7c160bc 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,27 @@ npm start ```sh npm test ``` + +### Properties +| Name | Type | Required | Default | Comment | +|--------------------|-----------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| examples | object[] | yes | - | AMF model for examples. It can be Payload shape, list of Payload shapes, or any shape. | +| mediaType | string | yes | - | Examples media type | +| typeName | string | no | - | Type (model) name for which examples are generated for. This is used by RAML to XML examples processor to wrap the example in type name. If missing this wrapping is omitted. | +| payloadId | string | no | - | Rendered payload ID (if any) to associate examples with the payload. | +| _renderedExamples | Example[] | no | - | Computed in a debouncer examples to render. | +| hasExamples | boolean | no | false | Computed value, true if there are examples to render. This value is reflected to attribute so the element can be hidden via CSS until examples are set. ```api-resource-example-document { display: none; } api-resource-example-document[has-examples] { display: block; } ``` | +| table | boolean | no | - | If true it will display a table view instead of JSON code. `isJson` must be set to use this option. | +| isJson | boolean | no | false | Computed value, true if selected media type is application/json or equivalent. | +| noAuto | boolean | no | - | Configuration passed to example generator. When set the generator only returns examples that are defined in API file, without auto generating examples from object properties. | +| noActions | boolean | no | false | When set the actions row (copy, switch view type) is not rendered. | +| rawOnly | boolean | no | - | When set it only renders "raw" examples. To be used when media type context is unknown. This can happen if RAML type document is rendered outside method documentation (not in a request/response body when media type is known). | +| compatibility | boolean | no | false | Enables Anypoint compatibility styling | +| _effectiveTable | boolean | no | - | | +| _hasLocalStorage | boolean | no | - | True if current environment has localStorage support. Chrome apps do not have localStorage property. | +| _renderReadOnly | boolean | no | false | If enabled then the example generator will be called with this option to add read-only properties to the example | +| _examplesDebouncer | boolean | no | - | | + + + + diff --git a/package-lock.json b/package-lock.json index 2ecf8d0..0a0464c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@api-components/api-resource-example-document", - "version": "4.3.5", + "version": "4.3.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f75e34f..7028e1b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@api-components/api-resource-example-document", "description": "A viewer for examples in a resource based on AMF model", - "version": "4.3.5", + "version": "4.3.6", "license": "Apache-2.0", "main": "index.js", "module": "index.js", diff --git a/src/styles/Document.js b/src/styles/Document.js index 41d170b..526e2bd 100644 --- a/src/styles/Document.js +++ b/src/styles/Document.js @@ -22,10 +22,10 @@ export default css` font-size: 1rem; display: var(--api-example-title-display, block); min-height: 36px; - padding: 0 10px 0px 10px; + padding: 0 10px 0 10px; background-color: var(--api-example-title-background-color, #ff9800); color: var(--api-example-title-color, #000); - border-radius: 0px 2px 0px 0px; + border-radius: 0 2px 0 0; display: flex; justify-content: space-between; align-items: center; @@ -54,7 +54,7 @@ export default css` .renderer { padding: 8px 0; display: flex; - max-height: 500px; + max-height: var(--api-resource-example-document-max-height, 500px); -webkit-transition: all 0.4s 0.1s ease-in-out; -moz-transition: all 0.4s 0.1s ease-in-out; -o-transition: all 0.4s 0.1s ease-in-out; diff --git a/test/api-resource-example-document.test.js b/test/api-resource-example-document.test.js index 417f876..c652946 100644 --- a/test/api-resource-example-document.test.js +++ b/test/api-resource-example-document.test.js @@ -560,6 +560,27 @@ describe('ApiResourceExampleDocument', () => { assert.isDefined(expandIconCollapsed); }); + it('should have panel max-height when maxHeight property is settled with custom styles', async () => { + const payloads = getPayload(element, amf, '/IncludedInline', 'post'); + element.examples = payloads; + + await aTimeout(100); + const wrraperExample = /** @type HTMLElement */ (element.shadowRoot.querySelector('.renderer')); + + assert.equal(getComputedStyle(wrraperExample).maxHeight, '500px'); + }); + + it('should have panel max-height when maxHeight property is settled with custom styles variables', async () => { + const payloads = getPayload(element, amf, '/IncludedInline', 'post'); + element.examples = payloads; + element.style.setProperty('--api-resource-example-document-max-height', '100px'); + + await aTimeout(100); + const wrraperExample = /** @type HTMLElement */ (element.shadowRoot.querySelector('.renderer')); + + assert.equal(getComputedStyle(wrraperExample).maxHeight, '100px'); + }); + it('should expand example panel on click ', async () => { const payloads = getPayload(element, amf, '/IncludedInline', 'post'); element.examples = payloads;