-
Notifications
You must be signed in to change notification settings - Fork 12
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
14 changed files
with
118 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { cloneElement, VNode } from "preact"; | ||
import { Signal, useSignal, useSignalEffect } from "@preact/signals"; | ||
|
||
export function Precense( | ||
{ present, children }: { | ||
present: Signal<boolean>; | ||
// deno-lint-ignore no-explicit-any | ||
children: VNode<any>; | ||
}, | ||
) { | ||
const mounted = useSignal(present.value); | ||
useSignalEffect(() => void (present.value && (mounted.value = true))); | ||
if (!mounted.value) return null; | ||
return cloneElement(children, { | ||
onAnimationEnd: (e: Event) => | ||
e.target == e.currentTarget && !present.value && (mounted.value = false), | ||
}); | ||
} |
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,17 @@ | ||
export function Check() { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="15" | ||
height="15" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
> | ||
<path d="M20 6 9 17l-5-5" /> | ||
</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
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 |
---|---|---|
@@ -1,48 +1,58 @@ | ||
import { StateUpdater, useEffect } from "preact/hooks"; | ||
import { useEffect } from "preact/hooks"; | ||
import { Signal } from "@preact/signals"; | ||
|
||
import { Button } from "../components/Button.tsx"; | ||
import { Precense } from "../components/Precense.tsx"; | ||
|
||
export function Alert( | ||
{ visible, setVisible }: { | ||
visible: boolean; | ||
setVisible: StateUpdater<boolean>; | ||
{ present }: { | ||
present: Signal<boolean>; | ||
}, | ||
) { | ||
useEffect(() => { | ||
const onKeyDown = (e: KeyboardEvent) => { | ||
e.key == "Escape" && setVisible(false); | ||
e.key == "Escape" && (present.value = false); | ||
}; | ||
document.addEventListener("keydown", onKeyDown); | ||
return () => document.removeEventListener("keydown", onKeyDown); | ||
}, []); | ||
if (!visible) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
class="w-full h-screen fixed top-0 left-0 bg-[#0005] dark:bg-[#fff1] p-5 flex items-center justify-center" | ||
onClick={(e) => e.target == e.currentTarget && setVisible(false)} | ||
> | ||
<div class="w-full max-w-lg p-5 bg-background rounded-xl min-h-[200px] flex flex-col gap-5 justify-between shadow-sm"> | ||
<div class="flex flex-col gap-4"> | ||
<p class="font-bold text-lg">How does this work?</p> | ||
<p> | ||
The statuses aren’t fetched from any server, rather determined from | ||
your browser by directly attempting to communicate with Telegram. | ||
</p> | ||
<p> | ||
This can be confirmed by monitoring the requests made while a | ||
connectivity test is in progress. | ||
</p> | ||
<p class="font-bold text-lg">Why does it take so long?</p> | ||
<p> | ||
Exchanging encryption keys might take a little time. After the keys | ||
are exchaged, they are stored locally in your browser, which makes | ||
future tests take much less time. | ||
</p> | ||
<Precense present={present}> | ||
<div | ||
class={`w-full h-screen fixed top-0 left-0 bg-[#0005] dark:bg-[#fff1] flex p-5 items-center justify-center duration-100 ${ | ||
present.value | ||
? "pointer-events-auto animate-in-opacity" | ||
: "pointer-events-none animate-out-opacity" | ||
}`} | ||
onClick={(e) => e.target == e.currentTarget && (present.value = false)} | ||
> | ||
<div | ||
class={`w-full max-w-lg p-5 bg-background rounded-xl min-h-[200px] flex flex-col gap-5 justify-between shadow-sm duration-100 ${ | ||
present.value ? "animate-in-scale" : "animate-out-scale" | ||
}`} | ||
> | ||
<div class="flex flex-col gap-4"> | ||
<p class="font-bold text-lg">How does this work?</p> | ||
<p> | ||
The statuses aren’t fetched from any server, rather determined | ||
from your browser by directly attempting to communicate with | ||
Telegram. | ||
</p> | ||
<p> | ||
This can be confirmed by monitoring the requests made while a | ||
connectivity test is in progress. | ||
</p> | ||
<p class="font-bold text-lg">Why does it take so long?</p> | ||
<p> | ||
Exchanging encryption keys might take a little time. After the | ||
keys are exchaged, they are stored locally in your browser, which | ||
makes future tests take much less time. | ||
</p> | ||
</div> | ||
<Button onClick={() => present.value = false}>Dismiss</Button> | ||
</div> | ||
<Button onClick={() => setVisible(false)}>Dismiss</Button> | ||
</div> | ||
</div> | ||
</Precense> | ||
); | ||
} |
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