|
23 | 23 | }; |
24 | 24 |
|
25 | 25 | const onCancel = () => { |
26 | | - console.log(selected, group.children); |
27 | 26 | selected = structuredClone(group.children); |
28 | 27 | handleCancel(group.name); |
29 | 28 | }; |
30 | | -
|
31 | | - const gridClass = (items: any[]) => { |
32 | | - const ceil = Math.ceil(Math.sqrt(items.length)); |
33 | | - const max = Math.max(ceil, Math.floor(items.length / 3)); |
34 | | -
|
35 | | - const classes = [ |
36 | | - 'grid-rows-1', |
37 | | - 'grid-rows-2', |
38 | | - 'grid-rows-3', |
39 | | - 'grid-rows-4', |
40 | | - 'grid-rows-5', |
41 | | - 'grid-rows-6', |
42 | | - 'grid-rows-7', |
43 | | - 'grid-rows-8', |
44 | | - 'grid-rows-9', |
45 | | - 'grid-rows-10', |
46 | | - 'grid-rows-11', |
47 | | - 'grid-rows-12' |
48 | | - ]; |
49 | | -
|
50 | | - if (max > 12) { |
51 | | - return 'grid-rows-12'; |
52 | | - } else return classes[max - 1 || 1]; |
53 | | - }; |
54 | 29 | </script> |
55 | 30 |
|
56 | | -<div class="p-5 rounded-md max-w-6xl bg-surface-50 dark:bg-surface-800 border-primary-500 border-2"> |
57 | | - <!-- Header --> |
58 | | - <h2 class="text-xl font-semibold">{group.displayName}</h2> |
| 31 | +<div class="w-full flex justify-center max-w-[800px]"> |
| 32 | + <div class="grow max-h-[500px]"> |
| 33 | + <div |
| 34 | + class="p-5 rounded-md w-full bg-surface-50 dark:bg-surface-800 border-primary-500 border-2" |
| 35 | + > |
| 36 | + <!-- Header --> |
| 37 | + <h2 class="text-xl font-semibold">{group.displayName}</h2> |
59 | 38 |
|
60 | | - <!-- Items --> |
61 | | - <div |
62 | | - class="{gridClass( |
63 | | - Object.keys(selected) |
64 | | - )} grid grid-flow-col gap-x-10 gap-y-2 py-10 px-2 h-full overflow-x-auto" |
65 | | - > |
66 | | - {#each Object.keys(selected) as key} |
67 | | - <label class="flex gap-3 items-center w-48"> |
68 | | - <input type="checkbox" class="checkbox" bind:checked={selected[key].selected} /> |
69 | | - <span |
70 | | - title={selected[key].displayName} |
71 | | - class="whitespace-nowrap break-before-avoid break-after-avoid truncate" |
72 | | - >{selected[key].displayName}</span |
73 | | - > |
74 | | - </label> |
75 | | - {/each} |
76 | | - </div> |
| 39 | + <!-- Items --> |
| 40 | + <div class="gap-x-10 gap-y-3 py-10 px-2 max-h-[500px] columns-[192px] overflow-auto"> |
| 41 | + {#each Object.keys(selected) as key} |
| 42 | + <label class="flex gap-3 items-center w-48"> |
| 43 | + <input type="checkbox" class="checkbox" bind:checked={selected[key].selected} /> |
| 44 | + <span |
| 45 | + title={selected[key].displayName} |
| 46 | + class="whitespace-nowrap break-before-avoid break-after-avoid truncate" |
| 47 | + >{selected[key].displayName}</span |
| 48 | + > |
| 49 | + </label> |
| 50 | + {/each} |
| 51 | + </div> |
77 | 52 |
|
78 | | - <!-- Footer --> |
79 | | - <div class="flex w-full justify-between gap-5"> |
80 | | - <div class="flex gap-3"> |
81 | | - <button class="btn btn-sm variant-filled-tertiary" on:click={selectNone}>None</button> |
82 | | - <button class="btn btn-sm variant-filled-tertiary" on:click={selectAll}>All</button> |
83 | | - </div> |
84 | | - <div class="flex gap-3"> |
85 | | - <button class="btn btn-sm variant-filled-primary" on:click={onApply}>Apply</button> |
86 | | - <button class="btn btn-sm variant-filled-secondary" on:click={onCancel}>Cancel</button> |
| 53 | + <!-- Footer --> |
| 54 | + <div class="flex w-full justify-between gap-5"> |
| 55 | + <div class="flex gap-3"> |
| 56 | + <button class="btn btn-sm variant-filled-tertiary" on:click={selectNone}>None</button> |
| 57 | + <button class="btn btn-sm variant-filled-tertiary" on:click={selectAll}>All</button> |
| 58 | + </div> |
| 59 | + <div class="flex gap-3"> |
| 60 | + <button class="btn btn-sm variant-filled-primary" on:click={onApply}>Apply</button> |
| 61 | + <button class="btn btn-sm variant-filled-secondary" on:click={onCancel}>Cancel</button> |
| 62 | + </div> |
| 63 | + </div> |
87 | 64 | </div> |
88 | 65 | </div> |
89 | 66 | </div> |
0 commit comments