/** @jsx h */ import { Component, h } from "https://esm.sh/preact@10.17.1"; import { tw } from "https://esm.sh/twind@0.16.16"; import { InviteIcon } from "./icons/invite-icon.tsx"; import { DividerBackgroundColor, HoverButtonBackgroudColor, PrimaryTextColor } from "./style/colors.ts"; import { NoOutlineClass } from "./components/tw.ts"; import { GroupMessageController } from "../features/gm.ts"; import { ProfileGetter } from "./search.tsx"; import { PublicKey } from "../lib/nostr-ts/key.ts"; import { emitFunc } from "../event-bus.ts"; type State = { show: boolean; }; type Props = { userPublicKey: PublicKey; groupChatController: GroupMessageController; profileGetter: ProfileGetter; emit: emitFunc; }; export type InviteUsersToGroup = { type: "InviteUsersToGroup"; groupPublicKey: PublicKey; usersPublicKey: PublicKey[]; }; export class InviteButton extends Component { state = { show: false }; styles = { button: { container: tw`w-6 h-6 flex items-center justify-center relative bg-[${DividerBackgroundColor}] hover:[${HoverButtonBackgroudColor}] ${NoOutlineClass}`, icon: tw`w-4 h-4 scale-150 fill-current text-[${PrimaryTextColor}]`, }, ul: tw`absolute top-6 rounded right-0 text-[${PrimaryTextColor}] bg-[${HoverButtonBackgroudColor}] z-20 overflow-y-auto`, li: tw`p-2 text-left hover:bg-[${DividerBackgroundColor}] first:rounded-t last:rounded-b w-32 whitespace-nowrap truncate text-xs`, }; sendEvent = (e: h.JSX.TargetedMouseEvent, groupPublicKey: PublicKey) => { e.stopPropagation(); this.setState({ show: false, }); this.props.emit({ type: "InviteUsersToGroup", groupPublicKey: groupPublicKey, usersPublicKey: [this.props.userPublicKey], }); }; render() { const { groupChatController, profileGetter } = this.props; return ( ); } }