Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,071 changes: 954 additions & 1,117 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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.6",
"version": "4.3.7",
"license": "Apache-2.0",
"main": "index.js",
"module": "index.js",
Expand Down
5 changes: 2 additions & 3 deletions src/ApiExampleRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ export class ApiExampleRender extends LitElement {
const isJson = this._computeIsJson(this.isJson, example.value);
return html`
<div class="example-actions">
<arc-icon class="info-icon" icon="code"></arc-icon>
<div>

<anypoint-button
part="content-action-button, code-content-action-button"
class="action-button"
Expand Down Expand Up @@ -442,7 +441,7 @@ export class ApiExampleRender extends LitElement {
?compatibility="${compatibility}"
title="Toggle between JSON and example source view"
>Source view</anypoint-button>` : ''}
</div>

</div>`;
}

Expand Down
4 changes: 1 addition & 3 deletions src/ApiResourceExampleDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,6 @@ export class ApiResourceExampleDocument extends AmfHelperMixin(LitElement) {
* @returns {TemplateResult|string}
*/
_titleTemplate(example) {
const { compatibility } = this;

if (example.isScalar) {
return '';
}
Expand All @@ -594,7 +592,6 @@ export class ApiResourceExampleDocument extends AmfHelperMixin(LitElement) {
class="example-title"
@click="${this._handleCollapsePanel}"
@keyup="${this._handleCollapsePanel}"
?compatibility="${compatibility}"
>
<span>${label}</span>
<anypoint-icon-button
Expand Down Expand Up @@ -668,6 +665,7 @@ export class ApiResourceExampleDocument extends AmfHelperMixin(LitElement) {
${this._titleTemplate(item)}
${this._descriptionTemplate(item)}
<div class="renderer">
<arc-icon class="info-icon" icon="code"></arc-icon>
<api-example-render
exportParts="${parts}"
class="example"
Expand Down
9 changes: 8 additions & 1 deletion src/styles/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default css`
font-size: 1rem;
display: var(--api-example-title-display, block);
min-height: 36px;
padding: 0 10px 0 10px;
padding: 0px 12px;
background-color: var(--api-example-title-background-color, #ff9800);
color: var(--api-example-title-color, #000);
border-radius: 0 2px 0 0;
Expand Down Expand Up @@ -94,4 +94,11 @@ api-example-render {
.example-description {
padding: 10px 12px;
}

.info-icon {
margin: 0 12px;
fill: var(--api-example-accent-color, #FF9800);
width: 24px;
height: 24px;
}
`;
18 changes: 6 additions & 12 deletions src/styles/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default css`

.code-wrapper {
padding: 0px;
margin-left: 42px;
}

[hidden] {
Expand Down Expand Up @@ -55,31 +54,26 @@ export default css`
display: flex;
align-items: center;
flex-direction: row;
justify-content: space-between;
margin: 0;
margin-right: 10px;
justify-content: flex-end;
flex-wrap: wrap;
flex: 1;
}

.info-icon {
margin: 0 12px;
fill: var(--api-example-accent-color, #FF9800);
width: 24px;
height: 24px;
}

anypoint-button {
margin-bottom: 8px;
height: 28px;
color: var(--api-resource-example-document-button-color);
font-size: var(--api-resource-example-document-button-font-size);
font-weight: var(--api-resource-example-document-button-font-weight);
}

api-example-render {
background-color: inherit;
}

json-table,
api-example-render {
overflow: auto;
max-width: 100%;
margin-left: 50px;
}
`;
9 changes: 8 additions & 1 deletion test/api-resource-example-document.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable no-param-reassign */
import { fixture, assert, nextFrame, aTimeout, html } from '@open-wc/testing';
import { fixture, assert, nextFrame, aTimeout, html, waitUntil } from '@open-wc/testing';
import sinon from 'sinon';
import { AmfLoader } from './amf-loader.js';
import '../api-resource-example-document.js';
Expand Down Expand Up @@ -595,6 +595,13 @@ describe('ApiResourceExampleDocument', () => {
assert.isDefined(examplePanelCollapsed);
assert.isDefined(expandIconCollapsed);
});

it('should render code icon', async () => {
const payloads = getPayload(element, amf, '/IncludedInType', 'post');
element.examples = payloads;
await waitUntil( () => Boolean(element.shadowRoot.querySelector('.info-icon')));
assert.exists(element.shadowRoot.querySelector('.info-icon'));
});
});
});
});
Expand Down