-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
253 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import SoundDown from './SoundDown.svelte'; | ||
import SoundUp from './SoundUp.svelte'; | ||
import { fly } from 'svelte/transition'; | ||
import * as Tooltip from '$lib/components/ui/tooltip'; | ||
// import * as Select from '$lib/components/ui/select'; | ||
let Speaker: SpeechSynthesisUtterance; | ||
export let isSpeaking: boolean = false; | ||
export let text: string; | ||
// let SpeakerVoices: SpeechSynthesisVoice[] = []; | ||
// let SelectedSpeakerLang = { label: '', value: '' }; | ||
// let SpeakerLangOptions: { label: string; value: string }[] = []; | ||
function handlePlay() { | ||
text && Speech(text); | ||
} | ||
function Speech(text: string) { | ||
if (isSpeaking) { | ||
window.speechSynthesis.cancel(); | ||
isSpeaking = false; | ||
return; | ||
} | ||
Speaker.lang = 'en-US'; | ||
Speaker.text = text; | ||
window.speechSynthesis.speak(Speaker); | ||
isSpeaking = true; | ||
Speaker.addEventListener('end', () => { | ||
isSpeaking = false; | ||
}); | ||
} | ||
onMount(() => { | ||
Speaker = new SpeechSynthesisUtterance(); | ||
// SpeakerVoices = window.speechSynthesis.getVoices(); | ||
// if (Speaker.voice) | ||
// SelectedSpeakerLang = { label: Speaker.voice?.name, value: Speaker.voice?.lang }; | ||
// else SelectedSpeakerLang = { label: SpeakerVoices[0].name, value: SpeakerVoices[0].lang }; | ||
// SpeakerLangOptions = | ||
// SpeakerVoices?.map((voice) => ({ label: voice.name, value: voice.lang })) || []; | ||
}); | ||
</script> | ||
|
||
<!-- svelte-ignore a11y-no-static-element-interactions --> | ||
<!-- svelte-ignore a11y-click-events-have-key-events --> | ||
{#if 'speechSynthesis' in window} | ||
<div | ||
on:click={handlePlay} | ||
class=" | ||
mt-[4px] | ||
flex | ||
h-[32px] | ||
w-[32px] | ||
cursor-pointer | ||
items-center | ||
justify-center | ||
rounded-full | ||
transition-transform | ||
{isSpeaking | ||
? '-translate-x-[3px] -translate-y-[6px] scale-[1.15]' | ||
: ' hover:-translate-x-[3px] hover:scale-[1.15] hover:border'} | ||
" | ||
> | ||
{#if isSpeaking} | ||
<span in:fly={{ duration: 100, opacity: 0.2 }}> | ||
<SoundUp {isSpeaking} style="transform:translateX(2.15px);" /> | ||
</span> | ||
{:else} | ||
<Tooltip.Root openDelay={0}> | ||
<Tooltip.Trigger> | ||
<span in:fly={{ duration: 100, opacity: 0.2 }}> | ||
<SoundDown /> | ||
</span> | ||
</Tooltip.Trigger> | ||
<Tooltip.Content transitionConfig={{ y: 0 }} side="top"> | ||
<p class="text-sm font-bold">Listen to the word</p> | ||
</Tooltip.Content> | ||
</Tooltip.Root> | ||
{/if} | ||
</div> | ||
<!-- | ||
<Select.Root bind:selected={SelectedSpeakerLang}> | ||
<Select.Trigger class="w-[180px]"> | ||
<Select.Value /> | ||
</Select.Trigger> | ||
<Select.Content class="max-h-[20rem] overflow-y-auto "> | ||
<Select.Group> | ||
{#each SpeakerLangOptions as lang} | ||
<Select.Item value={lang.value} label={lang.label}> | ||
{lang.label} | ||
</Select.Item> | ||
{/each} | ||
</Select.Group> | ||
</Select.Content> | ||
<Select.Input name="favoriteFruit" /> | ||
</Select.Root> --> | ||
{/if} |
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,26 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import SoundMute from './SoundMute.svelte'; | ||
import SoundDown from './SoundDown.svelte'; | ||
import SoundUp from './SoundUp.svelte'; | ||
let index: number = 0; | ||
onMount(() => { | ||
setInterval(() => { | ||
if (index < 1) { | ||
index++; | ||
} else { | ||
index = 0; | ||
} | ||
}, 300); | ||
}); | ||
</script> | ||
|
||
{#if index === 0} | ||
<SoundMute /> | ||
{:else if index === 1} | ||
<SoundDown /> | ||
{:else} | ||
<SoundUp /> | ||
{/if} |
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,16 @@ | ||
<script lang="ts"> | ||
export let style: string = ''; | ||
</script> | ||
|
||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="100%" | ||
height="100%" | ||
viewBox="0 -960 960 960" | ||
class="fill-[#020817] dark:fill-[#F8FAFC]" | ||
{style} | ||
> | ||
<path | ||
d="M368.462-380.001H251.283q-13.564 0-22.423-8.859-8.859-8.859-8.859-22.423v-137.434q0-13.564 8.859-22.423 8.859-8.859 22.423-8.859h117.179L496.41-707.946q12.077-12.077 27.833-5.628 15.756 6.448 15.756 23.268v420.355q0 17.077-15.756 23.525-15.756 6.449-27.833-5.628L368.462-380.001ZM719.999-480q0 42.256-18.923 77.948-18.923 35.692-53.154 57.461-7.384 4.795-14.833.462-7.448-4.333-7.448-12.897v-247.537q0-8.564 7.448-12.769 7.449-4.205 14.833.333 34.231 21.974 53.154 58.564 18.923 36.589 18.923 78.435Z" | ||
/> | ||
</svg> |
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,10 @@ | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="28px" | ||
height="28px" | ||
viewBox="0 -960 960 960" | ||
class="fill-[#313131] dark:fill-blue-400" | ||
><path | ||
d="M448.462-380.001H331.283q-13.468 0-22.375-8.907t-8.907-22.375v-137.434q0-13.468 8.907-22.375t22.375-8.907h117.179L576.41-707.946q12.077-12.077 27.833-5.544 15.756 6.532 15.756 23.184v420.355q0 16.909-15.756 23.441-15.756 6.533-27.833-5.544L448.462-380.001Z" | ||
/></svg | ||
> |
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,11 @@ | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="28px" | ||
height="28px" | ||
viewBox="0 -960 960 960" | ||
class="fill-[#313131] dark:fill-blue-400" | ||
> | ||
<path | ||
d="M752.563-456.36H665.64q-10.872 0-18-7.128t-7.128-17.999q0-10.872 7.128-18t18-7.128h86.923q10.872 0 18 7.128t7.128 18q0 10.871-7.128 17.999-7.128 7.128-18 7.128ZM582.384-283.205q5.949-8.385 16.141-10.333 10.192-1.949 18.576 4.666l71.513 53.667q8.385 6.205 9.795 16.064 1.41 9.858-4.795 18.243-6.205 8.64-16.268 10.461-10.064 1.82-18.705-4.795l-71.257-53.667q-8.384-6.205-9.794-16.063-1.41-9.859 4.794-18.243Zm104.692-443.129-71.923 53.667q-8.641 6.615-18.5 4.667-9.859-1.949-15.807-10.333-6.205-8.385-4.795-18.243 1.41-9.859 9.795-16.064l71.923-53.667q8.384-6.615 18.243-4.794 9.859 1.82 16.064 10.461 6.205 8.384 4.794 18.243-1.41 9.858-9.794 16.063ZM290.77-380.001H173.591q-13.564 0-22.423-8.859-8.859-8.859-8.859-22.423v-137.434q0-13.564 8.859-22.423 8.859-8.859 22.423-8.859H290.77l127.948-127.947q12.076-12.077 27.832-5.628 15.756 6.448 15.756 23.268v420.355q0 17.077-15.756 23.525-15.756 6.449-27.832-5.628L290.77-380.001Z" | ||
/> | ||
</svg> |
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,19 @@ | ||
<script lang="ts"> | ||
export let style: string = ''; | ||
export let isSpeaking: boolean = false; | ||
</script> | ||
|
||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="100%" | ||
height="100%" | ||
viewBox="0 -960 960 960" | ||
class="{isSpeaking ? 'fill-blue-400' : 'fill-[#020817]'} {isSpeaking | ||
? 'dark:fill-blue-500' | ||
: 'dark:fill-[#F8FAFC]'} " | ||
{style} | ||
> | ||
<path | ||
d="M763.589-481q0-87.897-48.32-159.192-48.321-71.295-127.987-104.91-10.308-4.641-14.692-13.667-4.385-9.025-.154-18.281 4.179-10.256 15.051-13.795 10.871-3.538 21.922 1.103 92.359 40.256 148.397 123.41Q813.844-583.179 813.844-481q0 102.179-56.038 185.332-56.038 83.154-148.397 123.41-11.051 4.641-21.922 1.103-10.872-3.539-15.051-13.795-4.231-9.256.154-18.281 4.384-9.026 14.692-13.667 79.666-33.615 127.987-104.91 48.32-71.295 48.32-159.192ZM294.616-380.001H177.438q-13.564 0-22.423-8.859-8.859-8.859-8.859-22.423v-137.434q0-13.564 8.859-22.423 8.859-8.859 22.423-8.859h117.178l127.948-127.947q12.077-12.077 27.833-5.628 15.756 6.448 15.756 23.268v420.355q0 17.077-15.756 23.525-15.756 6.449-27.833-5.628L294.616-380.001ZM646.153-480q0 42.256-18.923 77.948-18.923 35.692-53.153 57.461-7.385 4.795-14.833.462-7.449-4.333-7.449-12.897v-247.537q0-8.564 7.449-12.769 7.448-4.205 14.833.333 34.23 21.974 53.153 58.564 18.923 36.589 18.923 78.435Z" | ||
/> | ||
</svg> |
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,15 @@ | ||
import { Tooltip as TooltipPrimitive } from "bits-ui"; | ||
import Content from "./tooltip-content.svelte"; | ||
|
||
const Root = TooltipPrimitive.Root; | ||
const Trigger = TooltipPrimitive.Trigger; | ||
|
||
export { | ||
Root, | ||
Trigger, | ||
Content, | ||
// | ||
Root as Tooltip, | ||
Content as TooltipContent, | ||
Trigger as TooltipTrigger, | ||
}; |
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,28 @@ | ||
<script lang="ts"> | ||
import { Tooltip as TooltipPrimitive } from "bits-ui"; | ||
import { cn, flyAndScale } from "$lib/utils.js.js"; | ||
type $$Props = TooltipPrimitive.ContentProps; | ||
let className: $$Props["class"] = undefined; | ||
export let sideOffset: $$Props["sideOffset"] = 4; | ||
export let transition: $$Props["transition"] = flyAndScale; | ||
export let transitionConfig: $$Props["transitionConfig"] = { | ||
y: 8, | ||
duration: 150, | ||
}; | ||
export { className as class }; | ||
</script> | ||
|
||
<TooltipPrimitive.Content | ||
{transition} | ||
{transitionConfig} | ||
{sideOffset} | ||
class={cn( | ||
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground", | ||
className | ||
)} | ||
{...$$restProps} | ||
> | ||
<slot /> | ||
</TooltipPrimitive.Content> |
Oops, something went wrong.