Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add emojiSet to props #278

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/components/Widget/components/Conversation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface ISenderRef {
onSelectEmoji: (event: any) => void;
}

export type EmojiSet = 'apple' | 'google' | 'twitter' | 'facebook';

type Props = {
title: string;
subtitle: string;
Expand All @@ -34,6 +36,7 @@ type Props = {
showTimeStamp: boolean;
resizable?: boolean;
emojis?: boolean;
emojiSet?: EmojiSet;
};

function Conversation({
Expand All @@ -54,7 +57,8 @@ function Conversation({
sendButtonAlt,
showTimeStamp,
resizable,
emojis
emojis,
emojiSet,
}: Props) {
const [containerDiv, setContainerDiv] = useState<HTMLElement | null>();
let startX, startWidth;
Expand Down Expand Up @@ -85,11 +89,11 @@ function Conversation({
window.removeEventListener('mousemove', resize, false);
window.removeEventListener('mouseup', stopResize, false);
}

const [pickerOffset, setOffset] = useState(0)
const senderRef = useRef<ISenderRef>(null!);
const [pickerStatus, setPicket] = useState(false)
const [pickerStatus, setPicket] = useState(false)

const onSelectEmoji = (emoji) => {
senderRef.current?.onSelectEmoji(emoji)
}
Expand All @@ -104,7 +108,7 @@ function Conversation({
}

return (
<div id="rcw-conversation-container" onMouseDown={initResize}
<div id="rcw-conversation-container" onMouseDown={initResize}
className={cn('rcw-conversation-container', className)} aria-live="polite">
{resizable && <div className="rcw-conversation-resizer" />}
<Header
Expand All @@ -120,9 +124,10 @@ function Conversation({
showTimeStamp={showTimeStamp}
/>
<QuickButtons onQuickButtonClicked={onQuickButtonClicked} />
{emojis && pickerStatus && (<Picker
{emojis && pickerStatus && (<Picker
style={{ position: 'absolute', bottom: pickerOffset, left: '0', width: '100%' }}
onSelect={onSelectEmoji}
set={emojiSet ?? undefined}
/>)}
<Sender
ref={senderRef}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { isWidgetOpened } from '../../store/dispatcher';
import { AnyFunction } from '../../utils/types';

import WidgetLayout from './layout';
import {EmojiSet} from "./components/Conversation";

type Props = {
title: string;
Expand Down Expand Up @@ -34,6 +35,7 @@ type Props = {
showBadge?: boolean;
resizable?: boolean;
emojis?: boolean;
emojiSet?: EmojiSet;
}

function Widget({
Expand Down Expand Up @@ -63,7 +65,8 @@ function Widget({
handleSubmit,
showBadge,
resizable,
emojis
emojis,
emojiSet,
}: Props) {
const dispatch = useDispatch();

Expand Down Expand Up @@ -115,6 +118,7 @@ function Widget({
showBadge={showBadge}
resizable={resizable}
emojis={emojis}
emojiSet={emojiSet}
/>
);
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/Widget/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GlobalState } from 'src/store/types';
import { AnyFunction } from 'src/utils/types';
import { openFullscreenPreview } from '../../store/actions';

import Conversation from './components/Conversation';
import Conversation, {EmojiSet} from './components/Conversation';
import Launcher from './components/Launcher';
import FullScreenPreview from './components/FullScreenPreview';

Expand Down Expand Up @@ -38,7 +38,8 @@ type Props = {
zoomStep?: number;
showBadge?: boolean;
resizable?: boolean;
emojis?: boolean
emojis?: boolean;
emojiSet?: EmojiSet;
}

function WidgetLayout({
Expand Down Expand Up @@ -67,7 +68,8 @@ function WidgetLayout({
zoomStep,
showBadge,
resizable,
emojis
emojis,
emojiSet,
}: Props) {
const dispatch = useDispatch();
const { dissableInput, showChat, visible } = useSelector((state: GlobalState) => ({
Expand Down Expand Up @@ -147,6 +149,7 @@ function WidgetLayout({
showTimeStamp={showTimeStamp}
resizable={resizable}
emojis={emojis}
emojiSet={emojiSet}
/>
}
{customLauncher ?
Expand Down
8 changes: 6 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Widget from './components/Widget';
import store from './store';

import { AnyFunction } from './utils/types';
import {EmojiSet} from "./components/Widget/components/Conversation";

type Props = {
handleNewUserMessage: AnyFunction;
Expand All @@ -31,6 +32,7 @@ type Props = {
imagePreview?: boolean;
zoomStep?: number;
emojis?: boolean;
emojiSet?: EmojiSet;
handleSubmit?: AnyFunction;
showBadge?: boolean;
resizable?: boolean;
Expand Down Expand Up @@ -63,7 +65,8 @@ function ConnectedWidget({
handleSubmit,
showBadge,
resizable,
emojis
emojis,
emojiSet,
}: Props) {
return (
<Provider store={store}>
Expand All @@ -90,11 +93,12 @@ function ConnectedWidget({
sendButtonAlt={sendButtonAlt}
showTimeStamp={showTimeStamp}
imagePreview={imagePreview}
zoomStep={zoomStep}
zoomStep={zoomStep}
handleSubmit={handleSubmit}
showBadge={showBadge}
resizable={resizable}
emojis={emojis}
emojiSet={emojiSet}
/>
</Provider>
);
Expand Down