From d5e6a69ae1cb79a500e954c82625ff9ce5718309 Mon Sep 17 00:00:00 2001 From: James Dabbs Date: Sun, 10 Dec 2023 11:16:15 -0800 Subject: [PATCH] fix trait#show page reactivity per report [here](https://github.com/orgs/pi-base/discussions/464#discussioncomment-7560692) --- .../viewer/src/components/Traits/Show.svelte | 60 ------------------- .../viewer/src/components/Traits/index.ts | 2 +- .../[id]/properties/[propertyId]/+page.svelte | 35 ++++++++++- .../[id]/properties/[propertyId]/+page.ts | 22 +++++++ 4 files changed, 55 insertions(+), 64 deletions(-) delete mode 100644 packages/viewer/src/components/Traits/Show.svelte create mode 100644 packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.ts diff --git a/packages/viewer/src/components/Traits/Show.svelte b/packages/viewer/src/components/Traits/Show.svelte deleted file mode 100644 index ad82d57a..00000000 --- a/packages/viewer/src/components/Traits/Show.svelte +++ /dev/null @@ -1,60 +0,0 @@ - - -{#await loading} - -{:then { property, space, trait, proof, meta }} - - - <h1> - {#if proof} - <Robot /> - {/if} - <Link.Space {space} /> - is - {trait.value ? '' : 'not'} - <Link.Property {property} /> - </h1> - - {#if proof} - <Proof {space} {...proof} /> - {:else if meta} - <section class="description"> - <Typeset body={meta.description} /> - </section> - <h3>References</h3> - <References references={meta.refs} /> - {/if} -{:catch} - <NotFound>Could not find space {spaceId} / property {propertyId}</NotFound> -{/await} diff --git a/packages/viewer/src/components/Traits/index.ts b/packages/viewer/src/components/Traits/index.ts index 309d0b75..698b91ac 100644 --- a/packages/viewer/src/components/Traits/index.ts +++ b/packages/viewer/src/components/Traits/index.ts @@ -1,4 +1,4 @@ +export { default as Proof } from './Proof.svelte' export { default as Related } from './Related.svelte' -export { default as Show } from './Show.svelte' export { default as Table } from './Table.svelte' export { default as Value } from './Value.svelte' diff --git a/packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.svelte b/packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.svelte index 5a6f6cea..42f5dc35 100644 --- a/packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.svelte +++ b/packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.svelte @@ -1,6 +1,35 @@ <script lang="ts"> - import { page } from '$app/stores' - import { Show } from '@/components/Traits' + import { + Icons, + Link, + References, + Title, + Typeset + } from '@/components/Shared' + import { Proof } from '@/components/Traits' + + import type { PageData } from './$types' + export let data: PageData </script> -<Show spaceId={$page.params.id} propertyId={$page.params.propertyId} /> +<Title title={`${data.space.name}: ${data.property.name}`} /> + +<h1> + {#if data.proof} + <Icons.Robot /> + {/if} + <Link.Space space={data.space} /> + is + {data.trait.value ? '' : 'not'} + <Link.Property property={data.property} /> +</h1> + +{#if data.proof} + <Proof space={data.space} {...data.proof} /> +{:else if data.meta} + <section class="description"> + <Typeset body={data.meta.description} /> + </section> + <h3>References</h3> + <References references={data.meta.refs} /> +{/if} \ No newline at end of file diff --git a/packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.ts b/packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.ts new file mode 100644 index 00000000..c66919f5 --- /dev/null +++ b/packages/viewer/src/routes/(app)/spaces/[id]/properties/[propertyId]/+page.ts @@ -0,0 +1,22 @@ +import { get } from 'svelte/store' +import { error } from '@sveltejs/kit' + +import type { PageLoad } from './$types' + +export const load: PageLoad = async function ({ params: { id: spaceId, propertyId }, parent }) { + const { load, spaces, properties, theorems, traits, checked } = await parent() + + return load( + traits, + ts => ts.lookup({ + spaceId, + propertyId, + spaces: get(spaces), + properties: get(properties), + theorems: get(theorems), + }), + checked(spaceId) + ).catch(() => { + throw(error(404, `Trait not found ${spaceId} / ${propertyId}`)) + }) +}