Skip to content

Commit

Permalink
add content attribute to Link
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenClontz committed Dec 12, 2023
1 parent ae5dbf3 commit cf5acc3
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/viewer/src/components/Properties/List.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{#each $properties as property (property.id)}
<tr>
<td>
<Link.Property {property}>P{property.id}</Link.Property>
<Link.Property {property} content="id" />
</td>
<td>
<Typeset body={property.name} />
Expand Down
4 changes: 2 additions & 2 deletions packages/viewer/src/components/Properties/Show.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Property } from 'src/models'
import { Aliases, References, Tabs, Title, Typeset } from '../Shared'
import { Aliases, Link, References, Tabs, Title, Typeset } from '../Shared'
import Spaces from './Spaces.svelte'
import Theorems from './Theorems.svelte'
Expand All @@ -15,7 +15,7 @@

<Title {title} />

<h3>Property P{property.id}</h3>
<h3>Property <Link.Property {property} content="idLong" /></h3>

<h1>
<Typeset body={property.name} />
Expand Down
2 changes: 1 addition & 1 deletion packages/viewer/src/components/Properties/Spaces.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</script>

<Related mode="spaces" {related}>
<Link.Space slot="id" let:space {space}>S{space.id}</Link.Space>
<Link.Space slot="id" let:space {space} content="id" />

<Link.Space slot="name" let:space {space} />
</Related>
9 changes: 8 additions & 1 deletion packages/viewer/src/components/Shared/Link/Property.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
import { Id } from '@/models'
export let property: { id: number; name: string }
export let content: 'id' | 'idLong' | 'name' = 'name'
</script>

<a href="/properties/{Id.format('P', property.id)}">
<slot>
<Typeset body={property.name} />
{#if content === 'name'}
<Typeset body={property.name} />
{:else if content === 'id'}
P{property.id}
{:else}
{Id.format('P', property.id)}
{/if}
</slot>
</a>
9 changes: 8 additions & 1 deletion packages/viewer/src/components/Shared/Link/Space.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
import { Id } from '@/models'
export let space: { id: number; name: string }
export let content: 'id' | 'idLong' | 'name' = 'name'
</script>

<a href="/spaces/{Id.format('S', space.id)}">
<slot>
<Typeset body={space.name} />
{#if content === 'name'}
<Typeset body={space.name} />
{:else if content === 'id'}
S{space.id}
{:else}
{Id.format('S', space.id)}
{/if}
</slot>
</a>
7 changes: 6 additions & 1 deletion packages/viewer/src/components/Shared/Link/Theorem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
import { Id } from '@/models'
export let theorem: { id: number }
export let content: 'id' | 'idLong' = 'id'
</script>

<a href="/theorems/{Id.format('T', theorem.id)}">
<slot>
T{theorem.id}
{#if content === 'id'}
T{theorem.id}
{:else}
{Id.format('T', theorem.id)}
{/if}
</slot>
</a>
2 changes: 1 addition & 1 deletion packages/viewer/src/components/Spaces/List.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{#each $spaces as space (space.id)}
<tr>
<td>
<Link.Space {space}>S{space.id}</Link.Space>
<Link.Space {space} content="id" />
</td>
<td>
<Typeset body={space.name} />
Expand Down
4 changes: 1 addition & 3 deletions packages/viewer/src/components/Spaces/Properties.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
</script>

<Related mode="properties" {related}>
<Link.Property slot="id" let:property {property}>
P{property.id}
</Link.Property>
<Link.Property slot="id" let:property {property} content="id" />

<Link.Property slot="name" let:property {property} />
</Related>
4 changes: 2 additions & 2 deletions packages/viewer/src/components/Spaces/Show.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Space } from 'src/models'
import { Aliases, References, Tabs, Title, Typeset } from '../Shared'
import { Aliases, Link, References, Tabs, Title, Typeset } from '../Shared'
import Counterexamples from './Counterexamples.svelte'
import Properties from './Properties.svelte'
Expand All @@ -15,7 +15,7 @@

<Title {title} />

<h3>Space S{space.id}</h3>
<h3>Space <Link.Space {space} content="idLong" /></h3>

<h1>
<Typeset body={space.name} />
Expand Down
2 changes: 1 addition & 1 deletion packages/viewer/src/components/Theorems/List.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{#each $theorems as theorem (theorem.id)}
<tr>
<td>
<Link.Theorem {theorem}>T{theorem.id}</Link.Theorem>
<Link.Theorem {theorem} content="id" />
</td>
<td>
<Formula value={theorem.when} />
Expand Down
4 changes: 2 additions & 2 deletions packages/viewer/src/components/Theorems/Show.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { Theorem } from 'src/models'
import { References, Tabs, Title, Typeset } from '../Shared'
import { Link, References, Tabs, Title, Typeset } from '../Shared'
import Name from './Name.svelte'
import Converse from './Converse.svelte'
Expand All @@ -15,7 +15,7 @@

<Title {title} />

<h3>Theorem T{theorem.id}</h3>
<h3>Theorem <Link.Theorem {theorem} content="idLong" /></h3>

<h1>
<Name {theorem} />
Expand Down
2 changes: 1 addition & 1 deletion packages/viewer/src/components/Theorems/Table.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{#each theorems as theorem (theorem.id)}
<tr>
<td>
<Link.Theorem {theorem}>T{theorem.id}</Link.Theorem>
<Link.Theorem {theorem} />
</td>
<td>
<Formula value={theorem.when} />
Expand Down

0 comments on commit cf5acc3

Please sign in to comment.