Skip to content

Commit

Permalink
Merge branch 'main' into pudo/april-topics
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed May 8, 2024
2 parents 2283a5a + c37c07b commit f4d8339
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 98 deletions.
28 changes: 14 additions & 14 deletions docs/package-lock.json

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

5 changes: 5 additions & 0 deletions docs/src/components/explorer/PropertyIndicator.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const CONTENTS = {
title: 'Hidden property',
text: 'This property should not be displayed in user interfaces.',
},
stub: {
icon: 'arrow-uturn-left',
title: 'Stub property',
text: 'When a property points to another schema, a stub property is added to the target schema for the reverse direction. Stub properties are read-only.',
},
};
const { type } = Astro.props;
Expand Down
59 changes: 46 additions & 13 deletions docs/src/components/explorer/SchemaProperties.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const isRequired = (property) =>
const isHidden = (property) => property.hidden;
const isInherited = (property) => property.schema.name !== schema.name;
const isDeprecated = (property) => property.deprecated;
const isStub = (property) => property.stub;
const properties = Array.from(schema.getProperties().values())
.sort((a, b) => a.name.localeCompare(b.name))
Expand All @@ -24,17 +25,24 @@ const properties = Array.from(schema.getProperties().values())
<style>
.SchemaProperties__header {
display: flex;
flex-wrap: wrap;
width: 100%;
align-items: center;
justify-content: space-between;
margin-bottom: var(--space-sm);
}

.SchemaProperties__toggles {
display: flex;
gap: var(--space-sm);
}

.SchemaProperties__schema {
opacity: 66%;
}

[data-show-inherited='false'] [data-is-inherited] {
[data-show-inherited='false'] [data-is-inherited]:not(:has(:target)),
[data-show-stubs='false'] [data-is-stub]:not(:has(:target)) {
display: none;
}

Expand Down Expand Up @@ -80,24 +88,48 @@ const properties = Array.from(schema.getProperties().values())
<script>
window.addEventListener('DOMContentLoaded', () => {
const container = document.querySelector('.SchemaProperties');
const toggle = document.querySelector('.SchemaProperties__toggle');
const toggles = document.querySelectorAll('.SchemaProperties__toggle');

for (const toggle of toggles) {
const setting = toggle.dataset.toggleSetting;

toggle.checked = true;
if (!setting) {
return;
}

toggle.addEventListener('change', () => {
container.dataset.showInherited = toggle.checked ? 'true' : 'false';
});
container.dataset[setting] = toggle.checked ? 'true' : 'false';

toggle.addEventListener('change', () => {
container.dataset[setting] = toggle.checked ? 'true' : 'false';
});
}
});
</script>

<section class="SchemaProperties" data-show-inherited="true" {...rest}>
<div class="SchemaProperties__header">
<h2 class="beta">Properties</h2>

<label>
<input type="checkbox" class="SchemaProperties__toggle" checked />
Show inherited
</label>
<h2 class="SchemaProperties__heading beta">Properties</h2>

<div class="SchemaProperties__toggles">
<label>
<input
type="checkbox"
class="SchemaProperties__toggle"
checked
data-toggle-setting="showInherited"
/>
Show inherited
</label>

<label>
<input
type="checkbox"
class="SchemaProperties__toggle"
data-toggle-setting="showStubs"
/>
Show stubs
</label>
</div>
</div>

<IndexTable>
Expand All @@ -109,7 +141,7 @@ const properties = Array.from(schema.getProperties().values())

{
properties.map((prop) => (
<tr data-is-inherited={isInherited(prop)}>
<tr data-is-inherited={isInherited(prop)} data-is-stub={isStub(prop)}>
<td>
<span
id={`property-${prop.name}`}
Expand All @@ -123,6 +155,7 @@ const properties = Array.from(schema.getProperties().values())
{isFeatured(prop) && <PropertyIndicator type="featured" />}
{isRequired(prop) && <PropertyIndicator type="required" />}
{isHidden(prop) && <PropertyIndicator type="hidden" />}
{isStub(prop) && <PropertyIndicator type="stub" />}
{isDeprecated(prop) && (
<DeprecatedIndicator message="This property is deprecated and will be removed in a future version of the FollowTheMoney model." />
)}
Expand Down
Loading

0 comments on commit f4d8339

Please sign in to comment.