Skip to content

Commit

Permalink
feat: emoji using emoji-mart
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariaspect committed Sep 18, 2023
1 parent 2263c18 commit b64f08f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
"env": "echo $NODE_ENV"
},
"dependencies": {
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"axios": "^1.4.0",
"emoji-mart": "^5.5.2",
"framer-motion": "^10.16.1",
"immer": "^10.0.2",
"react": "^18.2.0",
Expand Down
35 changes: 33 additions & 2 deletions client/src/components/molecules/ChatInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useCallback, useMemo } from "react";
import React, { useCallback, useMemo, useState } from "react";
import { css } from "@emotion/react";
import data from "@emoji-mart/data";
import Picker from "@emoji-mart/react";

import { EmoticonIcon, SendIcon } from "@/assets";
import { Divider, TextAreaAutosize } from "@/components/atoms";
Expand Down Expand Up @@ -51,6 +53,12 @@ interface Props {
}

export const ChatInput: React.FC<Props> = ({ send }) => {
const [pickerOpen, setPickerOpen] = useState(false);
const absolutePosition = css`
position: absolute;
transform: translate(0%, -100%);
`;

const { input, setValue } = useInput();

/** TODO: disable send button based on `validated` */
Expand Down Expand Up @@ -87,7 +95,30 @@ export const ChatInput: React.FC<Props> = ({ send }) => {
/>
<Divider dir="vertical" />
</div>
<EmoticonIcon />
<EmoticonIcon
onClick={e => {
e.stopPropagation();
setPickerOpen(p => !p);
}}
/>
{pickerOpen && (
<div css={absolutePosition}>
<Picker
data={data}
onEmojiSelect={(emoji: { native: string }) =>
setValue(s => s + emoji.native)
}
onClickOutside={() => setPickerOpen(false)}
// emojiButtonRadius="50%"
// emojiButtonSize={24}
// emojiSize={16}
// dynamicWidth={true}
isNative
previewPosition="none"
skinTonePosition="none"
/>
</div>
)}
<SendIcon onClick={sendCurrent} />
{/* TODO: Replace with button / add hover, actove effect */}
</form>
Expand Down
47 changes: 31 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b64f08f

Please sign in to comment.