|
1 | 1 | <script lang="ts"> |
2 | | - import { base } from '$app/paths'; |
| 2 | + import DependencyRow from './DependencyRow.svelte'; |
| 3 | +
|
3 | 4 | import type { VersionDependency } from '$lib/generated'; |
4 | 5 |
|
5 | | - export let dependencies!: Pick<VersionDependency, 'mod_id' | 'condition'>[]; |
| 6 | + export let dependencies!: Pick<VersionDependency, 'mod_id' | 'optional' | 'condition'>[]; |
| 7 | +
|
| 8 | + $: requiredDependencies = dependencies.filter((d) => !d.optional); |
| 9 | + $: optionalDependencies = dependencies.filter((d) => d.optional); |
6 | 10 | </script> |
7 | 11 |
|
8 | 12 | <div class="grid grid-flow-row"> |
9 | | - <table aria-label="Mod Dependency" class="max-w-auto table table-hover !overflow-visible"> |
| 13 | + <table aria-label="Required Mod Dependencies" class="max-w-auto table table-hover !overflow-visible"> |
10 | 14 | <tbody> |
11 | 15 | <tr class="rounded border !border-surface-500"> |
12 | | - <td>Mod Dependency</td> |
| 16 | + <td |
| 17 | + class="underline decoration-dotted" |
| 18 | + title="Other mods that must be installed for this mod to function. The Mod Manager will automatically install these for you." |
| 19 | + >Required Dependencies</td> |
13 | 20 | <td><div class="text-center">Version Range</div></td> |
14 | 21 | </tr> |
15 | | - {#if dependencies?.length === 0} |
| 22 | + {#if requiredDependencies?.length === 0} |
| 23 | + <!-- A mod *not* having required dependencies is rare, so point it out when this is the case --> |
16 | 24 | <tr class="rounded border !border-surface-500"> |
17 | 25 | <td><div class="text-center">None</div></td> |
18 | 26 | <td><div class="text-center">N/A</div></td> |
19 | 27 | </tr> |
20 | 28 | {:else} |
21 | | - {#each dependencies as dependency} |
22 | | - <tr class="rounded border !border-surface-500"> |
23 | | - <td> |
24 | | - <a title="Click to view mod page" href={`${base}/mod/${dependency.mod_id}`} class="text-yellow-500"> |
25 | | - <u>{dependency.mod_id}</u> |
26 | | - </a> |
27 | | - </td> |
28 | | - <td><div class="text-center">{dependency.condition}</div></td> |
29 | | - </tr> |
| 29 | + {#each requiredDependencies as dependency} |
| 30 | + <DependencyRow {dependency} /> |
30 | 31 | {/each} |
31 | 32 | {/if} |
32 | 33 | </tbody> |
33 | 34 | </table> |
34 | 35 | </div> |
| 36 | + |
| 37 | +<!-- Optional dependencies are uncommon as of now, so don't spend UI space on them unless there are any --> |
| 38 | +{#if optionalDependencies?.length !== 0} |
| 39 | + <div class="grid grid-flow-row"> |
| 40 | + <table aria-label="Optional Mod Dependencies" class="max-w-auto table table-hover !overflow-visible"> |
| 41 | + <tbody> |
| 42 | + <tr class="rounded border !border-surface-500"> |
| 43 | + <td |
| 44 | + class="underline decoration-dotted" |
| 45 | + title="Other mods that don't need to be installed for this mod to function, but may unlock additional functionality when present. You must chose to install them in the Mod Manager if you wish to use them." |
| 46 | + >Optional Dependencies</td> |
| 47 | + <td><div class="text-center">Version Range</div></td> |
| 48 | + </tr> |
| 49 | + {#each optionalDependencies as dependency} |
| 50 | + <DependencyRow {dependency} /> |
| 51 | + {/each} |
| 52 | + </tbody> |
| 53 | + </table> |
| 54 | + </div> |
| 55 | +{/if} |
0 commit comments