Skip to content

Commit

Permalink
Add metadata and provenance infos #37; Sort files alphabetical by def…
Browse files Browse the repository at this point in the history
…ault #38; Exchange caret icon by download #39
  • Loading branch information
geofranzi committed Jan 23, 2025
1 parent c0e127d commit f511fd7
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 13 deletions.
61 changes: 61 additions & 0 deletions src/lib/RecursiveDisplay.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script>
export let data;
import RecursiveDisplay from './RecursiveDisplay.svelte';
/** @type {Record<string, boolean>} */
let collapsed = {};
// Toggle collapse state for a given key
/**
* @param {string} key
*/
function toggleCollapse(key) {
collapsed[key] = !collapsed[key];
}
</script>

{#if typeof data === 'object' && !Array.isArray(data)}
{#each Object.entries(data) as [key, value]}
{#if key != 'NETCDF_DIM_time_VALUES'}
<div
class="ml-4 collapsible"
role="button"
tabindex="0"
on:click={() => toggleCollapse(key)}
on:keydown={(e) => e.key === 'Enter' && toggleCollapse(key)}
>
<strong>{key}:</strong>
<div class={collapsed[key] ? 'collapsed' : ''}>
<div class="content">
<RecursiveDisplay data={value} />
</div>
</div>
</div>
{/if}
{/each}
{:else if Array.isArray(data)}
<ul class="ml-4">
{#each data as item, index}
<li>
<div class="collapsible">
<div>
<div class="content">
<RecursiveDisplay data={item} />
</div>
</div>
</div>
</li>
{/each}
</ul>
{:else}
<span>{data}</span>
{/if}

<style>
.collapsible {
cursor: pointer;
user-select: none;
}
.collapsed > .content {
display: none;
}
</style>
9 changes: 9 additions & 0 deletions src/lib/icons/download.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script></script>

<svg class="fill-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="20"
><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path
d="M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 242.7-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7 288 32zM64 352c-35.3 0-64 28.7-64 64l0 32c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-32c0-35.3-28.7-64-64-64l-101.5 0-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352 64 352zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"
/></svg
>

<style></style>
Loading

0 comments on commit f511fd7

Please sign in to comment.