Skip to content

Commit c8ec4c3

Browse files
Fix missing code icon (#33)
* chore(deps): run npm up * chore(deps): regenerate package-lock.json * fix: change code icon to previous place * fix: revert more styling * 4.3.7 * test: add test for code icon existence * fix: styles for example title * test: change test to account for delays
1 parent c7b8eea commit c8ec4c3

File tree

7 files changed

+980
-1138
lines changed

7 files changed

+980
-1138
lines changed

package-lock.json

Lines changed: 954 additions & 1117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/api-resource-example-document",
33
"description": "A viewer for examples in a resource based on AMF model",
4-
"version": "4.3.6",
4+
"version": "4.3.7",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/ApiExampleRender.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,7 @@ export class ApiExampleRender extends LitElement {
410410
const isJson = this._computeIsJson(this.isJson, example.value);
411411
return html`
412412
<div class="example-actions">
413-
<arc-icon class="info-icon" icon="code"></arc-icon>
414-
<div>
413+
415414
<anypoint-button
416415
part="content-action-button, code-content-action-button"
417416
class="action-button"
@@ -442,7 +441,7 @@ export class ApiExampleRender extends LitElement {
442441
?compatibility="${compatibility}"
443442
title="Toggle between JSON and example source view"
444443
>Source view</anypoint-button>` : ''}
445-
</div>
444+
446445
</div>`;
447446
}
448447

src/ApiResourceExampleDocument.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,6 @@ export class ApiResourceExampleDocument extends AmfHelperMixin(LitElement) {
584584
* @returns {TemplateResult|string}
585585
*/
586586
_titleTemplate(example) {
587-
const { compatibility } = this;
588-
589587
if (example.isScalar) {
590588
return '';
591589
}
@@ -594,7 +592,6 @@ export class ApiResourceExampleDocument extends AmfHelperMixin(LitElement) {
594592
class="example-title"
595593
@click="${this._handleCollapsePanel}"
596594
@keyup="${this._handleCollapsePanel}"
597-
?compatibility="${compatibility}"
598595
>
599596
<span>${label}</span>
600597
<anypoint-icon-button
@@ -668,6 +665,7 @@ export class ApiResourceExampleDocument extends AmfHelperMixin(LitElement) {
668665
${this._titleTemplate(item)}
669666
${this._descriptionTemplate(item)}
670667
<div class="renderer">
668+
<arc-icon class="info-icon" icon="code"></arc-icon>
671669
<api-example-render
672670
exportParts="${parts}"
673671
class="example"

src/styles/Document.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default css`
2222
font-size: 1rem;
2323
display: var(--api-example-title-display, block);
2424
min-height: 36px;
25-
padding: 0 10px 0 10px;
25+
padding: 0px 12px;
2626
background-color: var(--api-example-title-background-color, #ff9800);
2727
color: var(--api-example-title-color, #000);
2828
border-radius: 0 2px 0 0;
@@ -94,4 +94,11 @@ api-example-render {
9494
.example-description {
9595
padding: 10px 12px;
9696
}
97+
98+
.info-icon {
99+
margin: 0 12px;
100+
fill: var(--api-example-accent-color, #FF9800);
101+
width: 24px;
102+
height: 24px;
103+
}
97104
`;

src/styles/Render.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default css`
88
99
.code-wrapper {
1010
padding: 0px;
11-
margin-left: 42px;
1211
}
1312
1413
[hidden] {
@@ -55,31 +54,26 @@ export default css`
5554
display: flex;
5655
align-items: center;
5756
flex-direction: row;
58-
justify-content: space-between;
59-
margin: 0;
60-
margin-right: 10px;
57+
justify-content: flex-end;
6158
flex-wrap: wrap;
6259
flex: 1;
6360
}
6461
65-
.info-icon {
66-
margin: 0 12px;
67-
fill: var(--api-example-accent-color, #FF9800);
68-
width: 24px;
69-
height: 24px;
70-
}
71-
7262
anypoint-button {
63+
margin-bottom: 8px;
7364
height: 28px;
7465
color: var(--api-resource-example-document-button-color);
7566
font-size: var(--api-resource-example-document-button-font-size);
7667
font-weight: var(--api-resource-example-document-button-font-weight);
7768
}
7869
70+
api-example-render {
71+
background-color: inherit;
72+
}
73+
7974
json-table,
8075
api-example-render {
8176
overflow: auto;
8277
max-width: 100%;
83-
margin-left: 50px;
8478
}
8579
`;

test/api-resource-example-document.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable prefer-destructuring */
22
/* eslint-disable no-param-reassign */
3-
import { fixture, assert, nextFrame, aTimeout, html } from '@open-wc/testing';
3+
import { fixture, assert, nextFrame, aTimeout, html, waitUntil } from '@open-wc/testing';
44
import sinon from 'sinon';
55
import { AmfLoader } from './amf-loader.js';
66
import '../api-resource-example-document.js';
@@ -595,6 +595,13 @@ describe('ApiResourceExampleDocument', () => {
595595
assert.isDefined(examplePanelCollapsed);
596596
assert.isDefined(expandIconCollapsed);
597597
});
598+
599+
it('should render code icon', async () => {
600+
const payloads = getPayload(element, amf, '/IncludedInType', 'post');
601+
element.examples = payloads;
602+
await waitUntil( () => Boolean(element.shadowRoot.querySelector('.info-icon')));
603+
assert.exists(element.shadowRoot.querySelector('.info-icon'));
604+
});
598605
});
599606
});
600607
});

0 commit comments

Comments
 (0)