|
8 | 8 |
|
9 | 9 | export let pos: Length = '90%'; |
10 | 10 |
|
11 | | - $: previous_pos = Math.min(+pos.replace(UNIT_REGEX, '$1'), 70); |
| 11 | + $: previous_pos = Math.min(normalize(pos), 70); |
12 | 12 |
|
13 | | - export let max: Length = '90%'; |
| 13 | + export let max: Length = '-4.2rem'; |
14 | 14 |
|
15 | 15 | // we can't bind to the spring itself, but we |
16 | 16 | // can still use the spring to drive `pos` |
17 | | - const driver = spring(+pos.replace(UNIT_REGEX, '$1'), { |
| 17 | + const driver = spring(normalize(pos), { |
18 | 18 | stiffness: 0.2, |
19 | 19 | damping: 0.5 |
20 | 20 | }); |
|
23 | 23 | $: pos = $driver + '%'; |
24 | 24 |
|
25 | 25 | const toggle = () => { |
26 | | - const numeric_pos = +pos.replace(UNIT_REGEX, '$1'); |
| 26 | + let numeric_pos = normalize(pos); |
27 | 27 |
|
28 | 28 | driver.set(numeric_pos, { hard: true }); |
29 | 29 |
|
|
34 | 34 | driver.set(100); |
35 | 35 | } |
36 | 36 | }; |
| 37 | +
|
| 38 | + function normalize(pos: string) { |
| 39 | + let normalized = +pos.replace(UNIT_REGEX, '$1'); |
| 40 | +
|
| 41 | + if (normalized < 0) { |
| 42 | + normalized += 100; |
| 43 | + } |
| 44 | +
|
| 45 | + return normalized; |
| 46 | + } |
37 | 47 | </script> |
38 | 48 |
|
39 | 49 | <SplitPane {max} min="10%" type="vertical" bind:pos> |
|
46 | 56 | {#snippet b()} |
47 | 57 | <section> |
48 | 58 | <div class="panel-header"> |
49 | | - <button class="panel-heading" on:click={toggle}>{panel}</button> |
50 | | - <slot name="panel-header" /> |
| 59 | + <button class="panel-heading raised" on:click={toggle}> |
| 60 | + <svg |
| 61 | + width="1.8rem" |
| 62 | + height="1.8rem" |
| 63 | + viewBox="0 0 24 24" |
| 64 | + fill="none" |
| 65 | + stroke="currentColor" |
| 66 | + stroke-width="2" |
| 67 | + stroke-linecap="round" |
| 68 | + stroke-linejoin="round" |
| 69 | + > |
| 70 | + <path d="m7 15 5 5 5-5" /> |
| 71 | + <path d="m7 9 5-5 5 5" /> |
| 72 | + </svg> |
| 73 | + |
| 74 | + {panel} |
| 75 | + </button> |
51 | 76 | </div> |
52 | 77 |
|
53 | 78 | <div class="panel-body"> |
|
74 | 99 | .panel-heading { |
75 | 100 | font: var(--sk-font-ui-small); |
76 | 101 | text-transform: uppercase; |
77 | | - flex: 1; |
| 102 | + height: 3.2rem; |
| 103 | + padding: 0 0.8rem; |
| 104 | + /* flex: 1; */ |
78 | 105 | text-align: left; |
| 106 | + display: flex; |
| 107 | + align-items: center; |
| 108 | + gap: 0.4rem; |
79 | 109 | } |
80 | 110 |
|
81 | 111 | section { |
|
0 commit comments