Skip to content

Commit

Permalink
issue ann0nip#26 : Change widget position
Browse files Browse the repository at this point in the history
From a UX point of view, it is recommended to keep chat icons on the bottom right corner of your website, as this is a familiar and usual spot where people naturally notice and navigate.

However, UX is subjective. This PR added support issue ann0nip#26 .

I would recommend the WA button to have a high contrast background `#5ad167` and the WA chat icon in `white` in light mode situations and vice versa --> issue ann0nip#27
  • Loading branch information
nd0nd0 committed Oct 28, 2023
1 parent 32fed06 commit 68115e5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/components/app/app.component.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useContext, Fragment, useEffect } from 'react';

import { ChatContext } from '../../contexts/chat.context';
import ChatBox from '../chat-box/chat-box.component';
import Header from '../header/header.component';
Expand All @@ -8,6 +7,7 @@ import WaButton from '../wa-button/wa-button.component';
import styles from './app.module.css';

const App = (props) => {
console.log("🚀 ~ file: app.component.jsx:10 ~ App ~ props:", props)
const { isChatOpen, setIsChatOpen } = useContext(ChatContext);
useEffect(() => {
if (props.open) {
Expand All @@ -20,13 +20,14 @@ const App = (props) => {
<div
className={`${styles.root} ${
isChatOpen ? styles.open : styles.close
}`}
} ${props.position === 'left' ? styles.positionLeft : styles.positionRight} ` }
>

<Header {...props} />
<ChatBox {...props} />
<SendButton {...props} />
</div>
<WaButton />
<WaButton {...props} />
</Fragment>
);
};
Expand Down
10 changes: 9 additions & 1 deletion src/components/app/app.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
transform: translate3d(0px, 0px, 0px);
touch-action: auto;
display: none;
position: fixed;
bottom: 110px;
position: fixed;

}

.positionRight{
right: 25px;
}

.positionLeft{
left: 25px;
}

.open {
display: flex;
animation: customTransition 250ms ease-in-out both;
Expand Down
10 changes: 8 additions & 2 deletions src/components/wa-button/wa-button.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ import { FaWhatsapp } from 'react-icons/fa';
import { ChatContext } from '../../contexts/chat.context';
import styles from './wa-button.module.css';

const WaButton = () => {
const defaultProps = {
position: 'right',
};

const WaButton = ({
position = defaultProps.position
}) => {
const { isChatOpen, setIsChatOpen } = useContext(ChatContext);

const handleOpen = () => {
setIsChatOpen(!isChatOpen);
};

return (
<div className={styles.root} onClick={handleOpen}>
<div className={`${styles.root} ${position === 'left' ? styles.positionLeft : styles.positionRight} ` } onClick={handleOpen}>
<FaWhatsapp />
</div>
);
Expand Down
9 changes: 8 additions & 1 deletion src/components/wa-button/wa-button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
-webkit-box-pack: center;
position: fixed;
bottom: 25px;
right: 25px;
transition: 0.2s ease;

}

.positionRight{
right: 25px;
}

.positionLeft{
left: 25px;
}

.root:hover {
background-color: #5ad167;
}
Expand Down

0 comments on commit 68115e5

Please sign in to comment.