Input alignment (#193)
* Fix buttons alignment * Add message reaction key * Add click outside picker
This commit is contained in:
parent
7b91db2d93
commit
4eac832295
|
@ -11,6 +11,7 @@ import { useIdentity } from "../../contexts/identityProvider";
|
||||||
import { useMessengerContext } from "../../contexts/messengerProvider";
|
import { useMessengerContext } from "../../contexts/messengerProvider";
|
||||||
import { useModal } from "../../contexts/modalProvider";
|
import { useModal } from "../../contexts/modalProvider";
|
||||||
import { useNarrow } from "../../contexts/narrowProvider";
|
import { useNarrow } from "../../contexts/narrowProvider";
|
||||||
|
import { useClickOutside } from "../../hooks/useClickOutside";
|
||||||
import { Reply } from "../../hooks/useReply";
|
import { Reply } from "../../hooks/useReply";
|
||||||
import { uintToImgUrl } from "../../utils/uintToImgUrl";
|
import { uintToImgUrl } from "../../utils/uintToImgUrl";
|
||||||
import { ClearBtn } from "../Form/inputStyles";
|
import { ClearBtn } from "../Form/inputStyles";
|
||||||
|
@ -54,14 +55,8 @@ export function ChatInput({ reply, setReply }: ChatInputProps) {
|
||||||
|
|
||||||
const inputRef = useRef<HTMLDivElement>(null);
|
const inputRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
const ref = useRef(null);
|
||||||
if (showEmoji) {
|
useClickOutside(ref, () => setShowEmoji(false));
|
||||||
window.addEventListener("click", () => setShowEmoji(false));
|
|
||||||
}
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener("click", () => setShowEmoji(false));
|
|
||||||
};
|
|
||||||
}, [showEmoji]);
|
|
||||||
|
|
||||||
const image = useMemo(
|
const image = useMemo(
|
||||||
() => (imageUint ? uintToImgUrl(imageUint) : ""),
|
() => (imageUint ? uintToImgUrl(imageUint) : ""),
|
||||||
|
@ -211,7 +206,10 @@ export function ChatInput({ reply, setReply }: ChatInputProps) {
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<SizeLimitModal />
|
<SizeLimitModal />
|
||||||
|
<EmojiWrapper ref={ref}>
|
||||||
<EmojiPicker addEmoji={addEmoji} showEmoji={showEmoji} />
|
<EmojiPicker addEmoji={addEmoji} showEmoji={showEmoji} />
|
||||||
|
</EmojiWrapper>
|
||||||
|
|
||||||
<AddPictureInputWrapper>
|
<AddPictureInputWrapper>
|
||||||
<PictureIcon />
|
<PictureIcon />
|
||||||
<AddPictureInput
|
<AddPictureInput
|
||||||
|
@ -295,11 +293,8 @@ export function ChatInput({ reply, setReply }: ChatInputProps) {
|
||||||
</InputWrapper>
|
</InputWrapper>
|
||||||
<InputButtons>
|
<InputButtons>
|
||||||
<ChatButton
|
<ChatButton
|
||||||
onClick={(e) => {
|
onClick={() => {
|
||||||
e.stopPropagation();
|
if (!disabled) setShowEmoji(!showEmoji);
|
||||||
if (!disabled) {
|
|
||||||
setShowEmoji(!showEmoji);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
|
@ -325,9 +320,15 @@ const InputWrapper = styled.div`
|
||||||
position: relative;
|
position: relative;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const EmojiWrapper = styled.div`
|
||||||
|
position: absolute;
|
||||||
|
bottom: calc(100% - 6px);
|
||||||
|
right: 8px;
|
||||||
|
`;
|
||||||
|
|
||||||
const View = styled.div`
|
const View = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: flex-end;
|
||||||
padding: 6px 8px 6px 10px;
|
padding: 6px 8px 6px 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
`;
|
`;
|
||||||
|
@ -356,7 +357,7 @@ const Row = styled.div`
|
||||||
|
|
||||||
const InputButtons = styled.div`
|
const InputButtons = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-self: flex-end;
|
||||||
|
|
||||||
button + button {
|
button + button {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
|
|
|
@ -23,9 +23,6 @@ export function EmojiPicker({ showEmoji, addEmoji }: EmojiPickerProps) {
|
||||||
color={theme.tertiary}
|
color={theme.tertiary}
|
||||||
emojiSize={26}
|
emojiSize={26}
|
||||||
style={{
|
style={{
|
||||||
position: "absolute",
|
|
||||||
bottom: "100%",
|
|
||||||
right: "0",
|
|
||||||
color: theme.secondary,
|
color: theme.secondary,
|
||||||
height: low ? "200px" : "355px",
|
height: low ? "200px" : "355px",
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
|
|
|
@ -21,6 +21,7 @@ export function MessageReactions({
|
||||||
{messageReactions.map((reaction) => (
|
{messageReactions.map((reaction) => (
|
||||||
<EmojiReaction
|
<EmojiReaction
|
||||||
className={`${isMyReactionIncluded(reaction) && "chosen"}`}
|
className={`${isMyReactionIncluded(reaction) && "chosen"}`}
|
||||||
|
key={reaction.id}
|
||||||
>
|
>
|
||||||
<Emoji emoji={reaction} set={"twitter"} size={16} />
|
<Emoji emoji={reaction} set={"twitter"} size={16} />
|
||||||
<p>1</p>
|
<p>1</p>
|
||||||
|
|
Loading…
Reference in New Issue