-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement rudimentary redirect banner
Supports send and receive, uses the urlEndpoint or watchEndpoint link to open a new tab with the given url if the button is clicked This also adds support for bold text (but not deemphasized text yet) to MessageRun This does not implement contextMenuButton at all yet, only inlineActionButton.
- Loading branch information
1 parent
cff36d3
commit eb1fa02
Showing
5 changed files
with
196 additions
and
14 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,88 @@ | ||
<script lang="ts"> | ||
import { slide, fade } from 'svelte/transition'; | ||
import MessageRun from './MessageRuns.svelte'; | ||
import Tooltip from './common/Tooltip.svelte'; | ||
import Icon from 'smelte/src/components/Icon'; | ||
import { Theme } from '../ts/chat-constants'; | ||
import { createEventDispatcher } from 'svelte'; | ||
import { showProfileIcons } from '../ts/storage'; | ||
import Button from 'smelte/src/components/Button'; | ||
export let redirect: Ytc.ParsedRedirect; | ||
let dismissed = false; | ||
let shorten = false; | ||
let autoHideTimeout: NodeJS.Timeout | null = null; | ||
const classes = 'rounded inline-flex flex-col overflow-visible ' + | ||
'bg-secondary-900 p-2 w-full text-white z-10 shadow'; | ||
const onShorten = () => { | ||
shorten = !shorten; | ||
if (autoHideTimeout) { | ||
clearTimeout(autoHideTimeout); | ||
autoHideTimeout = null; | ||
} | ||
}; | ||
$: if (redirect) { | ||
dismissed = false; | ||
shorten = false; | ||
if (redirect.showtime) { | ||
autoHideTimeout = setTimeout(() => { shorten = true; }, redirect.showtime); | ||
} | ||
} | ||
const dispatch = createEventDispatcher(); | ||
$: dismissed, shorten, dispatch('resize'); | ||
</script> | ||
|
||
{#if !dismissed} | ||
<div | ||
class={classes} | ||
transition:fade={{ duration: 250 }} | ||
> | ||
<div class="flex flex-row items-center cursor-pointer" on:click={onShorten}> | ||
<div class="font-medium tracking-wide text-white flex-1"> | ||
<span class="mr-1 inline-block" style="transform: translateY(3px);"> | ||
<Icon small> | ||
{#if shorten} | ||
expand_more | ||
{:else} | ||
expand_less | ||
{/if} | ||
</Icon> | ||
</span> | ||
<span class="align-middle">Redirect Notice</span> | ||
</div> | ||
<div class="flex-none self-end" style="transform: translateY(3px);"> | ||
<Tooltip offsetY={0} small> | ||
<Icon | ||
slot="activator" | ||
class="cursor-pointer text-lg" | ||
on:click={() => { dismissed = true; }} | ||
> | ||
close | ||
</Icon> | ||
Dismiss | ||
</Tooltip> | ||
</div> | ||
</div> | ||
{#if !shorten && !dismissed} | ||
<div class="mt-1 whitespace-pre-line" transition:slide|local={{ duration: 300 }}> | ||
{#if $showProfileIcons} | ||
<img | ||
class="h-5 w-5 inline align-middle rounded-full flex-none" | ||
src={redirect.item.profileIcon.src} | ||
alt={redirect.item.profileIcon.alt} | ||
/> | ||
{/if} | ||
<MessageRun runs={redirect.item.message} forceDark forceTLColor={Theme.DARK}/> | ||
</div> | ||
<div class="mt-1 whitespace-pre-line" transition:slide|local={{ duration: 300 }}> | ||
<Button href={redirect.item.action.url} target="_blank" small> | ||
<MessageRun runs={redirect.item.action.text} forceDark forceTLColor={Theme.DARK}/> | ||
</Button> | ||
</div> | ||
{/if} | ||
</div> | ||
{/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
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