Refactor emoji picker (#169)
This commit is contained in:
parent
e39bcd6bda
commit
8794782a4e
|
@ -76,7 +76,7 @@ function DragDiv() {
|
||||||
<ReactChat
|
<ReactChat
|
||||||
theme={theme ? lightTheme : darkTheme}
|
theme={theme ? lightTheme : darkTheme}
|
||||||
communityKey={
|
communityKey={
|
||||||
"0x0202a564bed987342413b47bc8013d63bbb3fbb15dcd42dd03687b2cec8bd0f3f7"
|
"0x03e28ca2c56526d3ebd673e779bea6aff740cf16227dc0f284fc73e5b26c0942ef"
|
||||||
}
|
}
|
||||||
fetchMetadata={fetchMetadata}
|
fetchMetadata={fetchMetadata}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { Picker } from "emoji-mart";
|
|
||||||
import React, {
|
import React, {
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
@ -6,13 +5,11 @@ import React, {
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import styled, { useTheme } from "styled-components";
|
import styled from "styled-components";
|
||||||
|
|
||||||
import { useMessengerContext } from "../../contexts/messengerProvider";
|
import { useMessengerContext } from "../../contexts/messengerProvider";
|
||||||
import { useModal } from "../../contexts/modalProvider";
|
import { useModal } from "../../contexts/modalProvider";
|
||||||
import { useLow } from "../../contexts/narrowProvider";
|
|
||||||
import { Reply } from "../../hooks/useReply";
|
import { Reply } from "../../hooks/useReply";
|
||||||
import { lightTheme, Theme } from "../../styles/themes";
|
|
||||||
import { uintToImgUrl } from "../../utils/uintToImgUrl";
|
import { uintToImgUrl } from "../../utils/uintToImgUrl";
|
||||||
import { ClearSvg } from "../Icons/ClearIcon";
|
import { ClearSvg } from "../Icons/ClearIcon";
|
||||||
import { EmojiIcon } from "../Icons/EmojiIcon";
|
import { EmojiIcon } from "../Icons/EmojiIcon";
|
||||||
|
@ -25,6 +22,8 @@ import { SizeLimitModal, SizeLimitModalName } from "../Modals/SizeLimitModal";
|
||||||
import { SearchBlock } from "../SearchBlock";
|
import { SearchBlock } from "../SearchBlock";
|
||||||
import { textMediumStyles, textSmallStyles } from "../Text";
|
import { textMediumStyles, textSmallStyles } from "../Text";
|
||||||
|
|
||||||
|
import { EmojiPicker } from "./EmojiPicker";
|
||||||
|
|
||||||
interface ChatInputProps {
|
interface ChatInputProps {
|
||||||
reply: Reply | undefined;
|
reply: Reply | undefined;
|
||||||
setReply: (val: Reply | undefined) => void;
|
setReply: (val: Reply | undefined) => void;
|
||||||
|
@ -33,15 +32,12 @@ interface ChatInputProps {
|
||||||
|
|
||||||
export function ChatInput({ reply, setReply, disabled }: ChatInputProps) {
|
export function ChatInput({ reply, setReply, disabled }: ChatInputProps) {
|
||||||
const { sendMessage, contacts } = useMessengerContext();
|
const { sendMessage, contacts } = useMessengerContext();
|
||||||
const theme = useTheme() as Theme;
|
|
||||||
const [content, setContent] = useState("");
|
const [content, setContent] = useState("");
|
||||||
const [clearComponent, setClearComponent] = useState("");
|
const [clearComponent, setClearComponent] = useState("");
|
||||||
const [showEmoji, setShowEmoji] = useState(false);
|
const [showEmoji, setShowEmoji] = useState(false);
|
||||||
const [inputHeight, setInputHeight] = useState(40);
|
const [inputHeight, setInputHeight] = useState(40);
|
||||||
const [imageUint, setImageUint] = useState<undefined | Uint8Array>(undefined);
|
const [imageUint, setImageUint] = useState<undefined | Uint8Array>(undefined);
|
||||||
|
|
||||||
const low = useLow();
|
|
||||||
|
|
||||||
const { setModal } = useModal(SizeLimitModalName);
|
const { setModal } = useModal(SizeLimitModalName);
|
||||||
|
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
|
@ -203,29 +199,7 @@ export function ChatInput({ reply, setReply, disabled }: ChatInputProps) {
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<SizeLimitModal />
|
<SizeLimitModal />
|
||||||
{showEmoji && (
|
<EmojiPicker addEmoji={addEmoji} showEmoji={showEmoji} />
|
||||||
<div>
|
|
||||||
<Picker
|
|
||||||
onSelect={addEmoji}
|
|
||||||
theme={theme === lightTheme ? "light" : "dark"}
|
|
||||||
set="twitter"
|
|
||||||
color={theme.tertiary}
|
|
||||||
emojiSize={26}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
bottom: "100%",
|
|
||||||
right: "0",
|
|
||||||
color: theme.secondary,
|
|
||||||
height: low ? "200px" : "355px",
|
|
||||||
overflow: "auto",
|
|
||||||
}}
|
|
||||||
showPreview={false}
|
|
||||||
showSkinTones={false}
|
|
||||||
title={""}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<AddPictureInputWrapper>
|
<AddPictureInputWrapper>
|
||||||
<PictureIcon />
|
<PictureIcon />
|
||||||
<AddPictureInput
|
<AddPictureInput
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { Picker } from "emoji-mart";
|
||||||
|
import React from "react";
|
||||||
|
import { useTheme } from "styled-components";
|
||||||
|
|
||||||
|
import { useLow } from "../../contexts/narrowProvider";
|
||||||
|
import { lightTheme, Theme } from "../../styles/themes";
|
||||||
|
|
||||||
|
type EmojiPickerProps = {
|
||||||
|
showEmoji: boolean;
|
||||||
|
addEmoji: (e: any) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function EmojiPicker({ showEmoji, addEmoji }: EmojiPickerProps) {
|
||||||
|
const theme = useTheme() as Theme;
|
||||||
|
const low = useLow();
|
||||||
|
|
||||||
|
if (showEmoji) {
|
||||||
|
return (
|
||||||
|
<Picker
|
||||||
|
onSelect={addEmoji}
|
||||||
|
theme={theme === lightTheme ? "light" : "dark"}
|
||||||
|
set="twitter"
|
||||||
|
color={theme.tertiary}
|
||||||
|
emojiSize={26}
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom: "100%",
|
||||||
|
right: "0",
|
||||||
|
color: theme.secondary,
|
||||||
|
height: low ? "200px" : "355px",
|
||||||
|
overflow: "auto",
|
||||||
|
}}
|
||||||
|
showPreview={false}
|
||||||
|
showSkinTones={false}
|
||||||
|
title={""}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
Loading…
Reference in New Issue