Skip to content

Commit 7341a0f

Browse files
authored
Merge pull request #76 from K97i/v2-cpu1
Add More Info functionality to modals
2 parents 49f3c5f + 5f2950a commit 7341a0f

File tree

2 files changed

+637
-2790
lines changed

2 files changed

+637
-2790
lines changed

new/apps/web/src/lib/common/ModalWidget.svelte

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@
99
widgetContents,
1010
/** what's displayed when the widget is in modal mode*/
1111
modalContents,
12+
/** "more info" contents*/
13+
extraModalContents,
1214
} = $props();
1315
1416
// TODO: support for "more info" is not currently
1517
// implemented. When it is, it should not make use
1618
// of IDs
17-
let expanded = $state(false);
19+
let modalExpanded = $state(false);
20+
let moreInfoExpanded = $state(false);
1821
</script>
1922

2023
<button
2124
onclick={() => {
22-
expanded = true;
25+
modalExpanded = true;
2326
}}
2427
class="_widget">
2528
<h1>{title}</h1>
@@ -28,38 +31,39 @@
2831
</div>
2932
</button>
3033

31-
{#if expanded}
32-
<span class="backdrop" onclick={() => {expanded = false}} role="none">
34+
{#if modalExpanded}
35+
<span class="backdrop" onclick={() => {modalExpanded = false}} role="none">
3336
</span>
3437
<div class="_modal">
3538
<!-- modal header -->
3639
<div>
3740
<h5>{title}</h5>
38-
<button onclick={() => {expanded = false;}} type="button" aria-label="Close"
41+
<button onclick={() => {modalExpanded = false;}} type="button" aria-label="Close"
3942
></button>
4043
</div>
4144

4245
<div class="modal-body">
4346
{@render modalContents()}
4447
</div>
4548

46-
<!-- more info -->
47-
<!-- <div class="modal-body">
48-
{@render extraModalContents()}
49-
</div> -->
49+
<!-- more info -->
50+
{#if extraModalContents && moreInfoExpanded == true}
51+
<div class="modal-body">
52+
{@render extraModalContents()}
53+
</div>
54+
{/if}
5055

5156
<!-- footer -->
5257
<div>
53-
<!-- {#if extraModalContents}
58+
{#if extraModalContents && moreInfoExpanded == false}
5459
<button
5560
type="button"
5661
class="btn btn-secondary"
57-
id={modalId + '-more-info-button'}
58-
onclick={() => infoClick(modalId)}>More Info</button
62+
onclick={() => {moreInfoExpanded = true}}>More Info</button
5963
>
60-
{/if} -->
64+
{/if}
6165
<button
62-
onclick={() => {expanded = false;}}
66+
onclick={() => {modalExpanded = false;}}
6367
type="button">Close</button
6468
>
6569
</div>

0 commit comments

Comments
 (0)