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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ dist/
!demo/avro.json
!demo/avro2.json
!demo/grpc-test.json
!demo/grpc-test-old.json
!demo/product-order-minimal.json
!demo/product-order-minimal-compact.json
!demo/product-order-deep-allof.json
Expand Down
4,490 changes: 4,490 additions & 0 deletions demo/grpc-test-old.json

Large diffs are not rendered by default.

26,871 changes: 22,668 additions & 4,203 deletions demo/grpc-test.json

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,68 @@
.options > * {
margin-left: 8px;
}

/* Dark mode: simulates theme where union/oneOf buttons use transparent/inherit */
body.dark-mode {
background-color: #1e1e1e !important;
color: #e0e0e0;
}
body.dark-mode header {
background-color: #2d2d2d;
--iron-icon-fill-color: #e0e0e0;
--paper-input-container-focus-color: #90caf9;
--paper-input-container-label: { color: #e0e0e0; };
}
body.dark-mode [role="main"] {
background-color: #1e1e1e;
}
.dark-mode-toggle {
position: fixed;
bottom: 12px;
right: 12px;
z-index: 9999;
padding: 6px 10px;
background: #333;
color: #fff;
border-radius: 4px;
font-size: 12px;
cursor: pointer;
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.dark-mode-toggle input { margin-right: 6px; }
</style>
</head>

<body>
<div id="demo"></div>
<label class="dark-mode-toggle" title="Toggle dark mode to verify union/oneOf button visibility">
<input type="checkbox" id="darkModeCheckbox" /> Dark mode
</label>

<script type="module" src="index.js"></script>

<script>
(function() {
function initDarkMode() {
var cb = document.getElementById('darkModeCheckbox');
var stored = localStorage.getItem('api-type-document-dark-mode') === 'true';
if (stored) {
document.body.classList.add('dark-mode');
if (cb) cb.checked = true;
}
if (cb) {
cb.addEventListener('change', function() {
document.body.classList.toggle('dark-mode', cb.checked);
localStorage.setItem('api-type-document-dark-mode', cb.checked);
});
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initDarkMode);
} else {
initDarkMode();
}
})();
document.addEventListener('WebComponentsReady', function() {
if (!window.ShadyCSS) {
return;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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-type-document",
"description": "A documentation table for type (resource) properties. Works with AMF data model",
"version": "4.2.42",
"version": "4.2.43",
"license": "Apache-2.0",
"main": "index.js",
"module": "index.js",
Expand Down
8 changes: 4 additions & 4 deletions src/TypeStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export default css`

.media-toggle {
outline: none;
color: var(--api-type-document-media-button-color, #000);
color: var(--api-type-document-media-button-color, inherit);
background-color: var(
--api-type-document-media-button-background-color,
#fff
transparent
);
border-width: 1px;
border-color: var(--api-type-document-media-button-border-color, #a3b11d);
Expand All @@ -64,9 +64,9 @@ export default css`
outline: none;
background-color: var(
--api-type-document-union-button-background-color,
#fff
transparent
);
color: var(--api-type-document-union-button-color, #000);
color: var(--api-type-document-union-button-color, inherit);
border-width: 1px;
border-color: var(--api-type-document-media-button-border-color, #a3b11d);
border-style: solid;
Expand Down
11 changes: 11 additions & 0 deletions test/api-type-document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,17 @@ describe('<api-type-document>', () => {
assert.equal(buttons.length, 2);
});

it('union toggle buttons have transparent background by default (dark mode fix)', () => {
const button = element.shadowRoot.querySelector('.union-toggle');
assert.ok(button, 'union toggle button should exist');
const styles = getComputedStyle(button);
assert.notEqual(
styles.backgroundColor,
'rgb(255, 255, 255)',
'should not use hardcoded white background (invisible in dark mode)'
);
});

it('Button change selection', () => {
const buttons = element.shadowRoot.querySelectorAll('.union-toggle');
/** @type HTMLElement */ (buttons[1]).click();
Expand Down
4 changes: 2 additions & 2 deletions test/grpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('<api-type-document> - gRPC', () => {
let amf;

before(async () => {
amf = await AmfLoader.load(compact, 'grpc-test');
amf = await AmfLoader.load(compact, 'grpc-test-old');
});

describe('link-target resolution', () => {
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('<api-type-document> - gRPC', () => {
assert.isDefined(props1, 'Should have initial computed properties');

// Update amf reference (simulate amf reload)
const newAmf = await AmfLoader.load(compact, 'grpc-test');
const newAmf = await AmfLoader.load(compact, 'grpc-test-old');
element.amf = newAmf;
await nextFrame();
await aTimeout(0);
Expand Down