-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
174 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<script lang="ts"> | ||
import { customOscillatorTypes } from 'web-audio-oscillators'; | ||
import { type OscillatorType } from '../sound'; | ||
import { handleMenuOutsideClick } from './menu-outside-click-handler'; | ||
export let oscillatorType: OscillatorType; | ||
const getOscillatorName = (osc: OscillatorType) => { | ||
if (!osc) { | ||
return 'None'; | ||
} | ||
return (osc.charAt(0).toUpperCase() + osc.slice(1)).replace( | ||
/([0-9])/g, | ||
' $1' | ||
); | ||
}; | ||
let ref: HTMLDetailsElement; | ||
</script> | ||
|
||
<li> | ||
<details bind:this={ref}> | ||
<summary | ||
class="w-40" | ||
on:click|stopPropagation={handleMenuOutsideClick(ref, 'soundSelect')} | ||
> | ||
{#if oscillatorType} | ||
<svg | ||
class="w-[28px] h-[28px]" | ||
aria-hidden="true" | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
> | ||
<path | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
d="M15.5 8.43A4.985 4.985 0 0 1 17 12a4.984 4.984 0 0 1-1.43 3.5m2.794 2.864A8.972 8.972 0 0 0 21 12a8.972 8.972 0 0 0-2.636-6.364M12 6.135v11.73a1 1 0 0 1-1.64.768L6 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h2l4.36-3.633a1 1 0 0 1 1.64.768Z" | ||
/> | ||
</svg> | ||
{:else} | ||
<svg | ||
class="w-[28px] h-[28px]" | ||
aria-hidden="true" | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
> | ||
<path | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
d="M15.5 8.43A4.985 4.985 0 0 1 17 12c0 1.126-.5 2.5-1.5 3.5m2.864-9.864A8.972 8.972 0 0 1 21 12c0 2.023-.5 4.5-2.5 6M7.8 7.5l2.56-2.133a1 1 0 0 1 1.64.768V12m0 4.5v1.365a1 1 0 0 1-1.64.768L6 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1m1-4 14 14" | ||
/> | ||
</svg> | ||
{/if} | ||
{oscillatorType ? getOscillatorName(oscillatorType) : 'None'} | ||
</summary> | ||
<ul class="p-2 bg-base-100 rounded-t-none z-10"> | ||
<li> | ||
<button | ||
class={!oscillatorType ? 'btn-active' : ''} | ||
data-sound-select | ||
on:click={() => (oscillatorType = null)}>None</button | ||
> | ||
</li> | ||
{#each customOscillatorTypes as osc} | ||
<li> | ||
<button | ||
class={osc === oscillatorType ? 'btn-active' : ''} | ||
data-sound-select | ||
on:click={() => { | ||
oscillatorType = osc; | ||
}}>{getOscillatorName(osc)}</button | ||
> | ||
</li> | ||
{/each} | ||
</ul> | ||
</details> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<script lang="ts"> | ||
import themes from '../../../themes'; | ||
import { handleMenuOutsideClick } from './menu-outside-click-handler'; | ||
export let selectedTheme: string; | ||
let ref: HTMLDetailsElement; | ||
const selectTheme = ( | ||
e: MouseEvent & { | ||
currentTarget: EventTarget & HTMLButtonElement; | ||
} | ||
) => { | ||
selectedTheme = e.currentTarget.dataset.setTheme || 'dim'; | ||
document.documentElement.setAttribute('data-theme', selectedTheme); | ||
}; | ||
</script> | ||
|
||
<li> | ||
<details bind:this={ref}> | ||
<summary on:click|stopPropagation={handleMenuOutsideClick(ref, 'setTheme')} | ||
><svg | ||
class="w-[24px] h-[24px]" | ||
aria-hidden="true" | ||
fill="none" | ||
viewBox="0 0 21 21" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M11.15 5.6h.01m3.337 1.913h.01m-6.979 0h.01M5.541 11h.01M15 15h2.706a1.957 1.957 0 0 0 1.883-1.325A9 9 0 1 0 2.043 11.89 9.1 9.1 0 0 0 7.2 19.1a8.62 8.62 0 0 0 3.769.9A2.013 2.013 0 0 0 13 18v-.857A2.034 2.034 0 0 1 15 15Z" | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
/> | ||
</svg></summary | ||
> | ||
<ul class="p-2 bg-base-100 rounded-t-none z-10"> | ||
{#each themes as theme} | ||
<li> | ||
<button | ||
data-act-class="btn-active" | ||
data-set-theme={theme} | ||
on:click={selectTheme} | ||
>{theme.charAt(0).toUpperCase() + theme.slice(1)}</button | ||
> | ||
</li> | ||
{/each} | ||
</ul> | ||
</details> | ||
</li> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const handleMenuOutsideClick = | ||
(ref: HTMLElement, datasetElement: string) => () => { | ||
const close = (e: Event) => { | ||
if ( | ||
e !== null && | ||
e.target instanceof HTMLElement && | ||
e.target.dataset && | ||
e.target.dataset[datasetElement] === undefined | ||
) { | ||
document.body.removeEventListener('click', close); | ||
ref.removeAttribute('open'); | ||
} | ||
}; | ||
document.body.addEventListener('click', close); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters