-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #559 from gagan-suie/dev
Fix: disabled chat buttons if not logged in
- Loading branch information
Showing
4 changed files
with
59 additions
and
56 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 |
---|---|---|
@@ -1,57 +1,55 @@ | ||
<script lang="ts"> | ||
import { clickOutside } from '../../../utils.js'; | ||
export let id:string = "float-menu" | ||
export let icon:any = null | ||
export let label:string = "" | ||
import { clickOutside } from '../../../utils.js' | ||
export let id: string = 'float-menu' | ||
export let icon: any = null | ||
export let label: string = '', | ||
isChannelSocketConnected: any | ||
let btn: any | ||
let isFocused = false | ||
const handleClickOutside = (event: any) =>{ | ||
const _id = event.target.id || | ||
event.target.parentElement.id || | ||
event.target.parentElement.parentElement.id | ||
const handleClickOutside = (event: any) => { | ||
const _id = | ||
event.target.id || | ||
event.target.parentElement.id || | ||
event.target.parentElement.parentElement.id | ||
if(id !== _id) | ||
isFocused = false | ||
if (id !== _id) isFocused = false | ||
} | ||
const forceClose = () => { | ||
isFocused = false | ||
} | ||
$: btnClass = isFocused ? "btn-primary" : "btn-neutral" | ||
$: dropdownClass = isFocused ? "dropdown-open" : "" | ||
$: bottom = btn ? window.innerHeight - (btn.getBoundingClientRect().top) : 0 | ||
$: btnClass = isFocused ? 'btn-primary' : 'btn-neutral' | ||
$: dropdownClass = isFocused ? 'dropdown-open' : '' | ||
$: bottom = btn ? window.innerHeight - btn.getBoundingClientRect().top : 0 | ||
</script> | ||
|
||
<button | ||
bind:this={btn} | ||
id={id} | ||
{id} | ||
type="button" | ||
class={"btn text-white border-none tooltip font-normal normal-case " + btnClass} | ||
class={'btn text-white border-none tooltip font-normal normal-case ' + btnClass} | ||
data-tip={label} | ||
on:click={() => { | ||
isFocused = true | ||
}} | ||
> | ||
<svelte:component id={id} this={icon} /> | ||
disabled={!isChannelSocketConnected}> | ||
<svelte:component this={icon} {id} /> | ||
<span class="sr-only">Add emoji</span> | ||
</button> | ||
<div | ||
use:clickOutside={handleClickOutside} | ||
class={"dropdown dropdown-top " + dropdownClass} | ||
> | ||
<div use:clickOutside={handleClickOutside} class={'dropdown dropdown-top ' + dropdownClass}> | ||
<!-- svelte-ignore a11y-no-noninteractive-tabindex --> | ||
<div | ||
style="bottom: {bottom}px" | ||
class={'dropdown-content menu shadow !fixed right-0 z-50 floating-menu overflow-auto'} | ||
> | ||
<div | ||
style="bottom: {bottom}px" | ||
class={'dropdown-content menu shadow !fixed right-0 z-50 floating-menu overflow-auto'}> | ||
<slot {forceClose} /> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.floating-menu { | ||
max-width: 100vw; | ||
} | ||
</style> | ||
</style> |
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