-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Toast on redirect; revamped UI
- Loading branch information
1 parent
12297ef
commit 723cce2
Showing
6 changed files
with
168 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Component, createEffect, createSignal, onCleanup } from "solid-js"; | ||
import { Toast } from "solid-toast"; | ||
|
||
type IProps = { | ||
t: Toast; | ||
duration: number; | ||
redirect_url: string; | ||
url_name?: string; | ||
}; | ||
|
||
export const RedirectToast: Component<IProps> = (props) => { | ||
const [life, setLife] = createSignal(100); | ||
const startTime = Date.now(); | ||
|
||
createEffect(() => { | ||
if (props.t.paused) return; | ||
const interval = setInterval(() => { | ||
const diff = Date.now() - startTime - props.t.pauseDuration; | ||
setLife((diff / props.duration) * 100); | ||
}); | ||
|
||
onCleanup(() => { | ||
window.location.href = props.redirect_url; | ||
clearInterval(interval); | ||
}); | ||
}); | ||
|
||
return ( | ||
<div class="toast-notification toast-visible"> | ||
<div class="toast-content"> | ||
<div class="toast-text-content"> | ||
<div class="toast-title"> | ||
Redirecting to{" "} | ||
<a href={props.redirect_url}> | ||
{props.url_name | ||
? props.url_name | ||
: props.redirect_url} | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="toast-progress-bar"> | ||
<div class="toast-progress-background"></div> | ||
<div | ||
class="toast-progress-foreground" | ||
style={{ width: `${life()}%` }} | ||
></div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,2 +1,3 @@ | ||
@import './base.scss'; | ||
@import './register.scss'; | ||
@import './register.scss'; | ||
@import './toast.scss'; |
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,79 @@ | ||
.toast-notification { | ||
&.toast-visible { | ||
animation: toast-enter 0.3s ease-out; | ||
} | ||
|
||
&.toast-hidden { | ||
animation: toast-leave 0.3s ease-in; | ||
} | ||
|
||
background-color: #212121; | ||
// background-image: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05)); | ||
padding: 0.75rem; | ||
border-radius: 0.375rem; | ||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); | ||
min-width: 350px; | ||
overflow: hidden; | ||
|
||
.toast-content { | ||
display: flex; | ||
gap: 0.5rem; | ||
|
||
.toast-text-content { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
font-weight: 600; | ||
color: #ecfeff; | ||
text-wrap: wrap; | ||
|
||
a { | ||
color: #65b5a3; | ||
} | ||
} | ||
} | ||
|
||
.toast-progress-bar { | ||
padding-top: 1rem; | ||
position: relative; | ||
|
||
.toast-progress-background { | ||
width: 100%; | ||
height: 0.25rem; | ||
border-radius: 9999px; | ||
// background-color: #164e63; | ||
background-color: white; | ||
} | ||
|
||
.toast-progress-foreground { | ||
height: 0.25rem; | ||
max-width: 100%; | ||
position: absolute; | ||
top: 1rem; | ||
border-radius: 9999px; | ||
background-color: #65b5a3; | ||
} | ||
} | ||
} | ||
|
||
@keyframes toast-enter { | ||
0% { | ||
transform: translateY(100%); | ||
opacity: 0; | ||
} | ||
100% { | ||
transform: translateY(0); | ||
opacity: 1; | ||
} | ||
} | ||
|
||
@keyframes toast-leave { | ||
0% { | ||
transform: translateY(0); | ||
opacity: 1; | ||
} | ||
100% { | ||
transform: translateY(100%); | ||
opacity: 0; | ||
} | ||
} |