Skip to content

Commit

Permalink
[#1726] Customize Start a New Conversation button (#1731)
Browse files Browse the repository at this point in the history
* edited and added customization for start a new conversation button

* updated button name
  • Loading branch information
AudreyKj committed May 5, 2021
1 parent 96a2ad5 commit 80e6143
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 15 deletions.
5 changes: 4 additions & 1 deletion frontend/chat-plugin/src/components/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ const Chat = (props: Props) => {
setNewConversation={setNewConversation}
/>
) : (
<NewConversation reAuthenticate={reAuthenticate} />
<NewConversation
reAuthenticate={reAuthenticate}
startNewConversationText={config.startNewConversationText || null}
/>
);

const bubble = props.bubbleProp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
.newConversation {
display: flex;
justify-content: center;
padding-left: 20px;
margin: 0;
font-family: 'Lato', sans-serif;
color: var(--color-airy-blue);
Expand All @@ -19,12 +18,32 @@
margin: 0;
}

.newConversationLink {
.startConversationContainer {
display: flex;
justify-content: center;
width: 100%;
margin-bottom: 20px;
}

.newConversationLink,
.newConversationLink:hover,
.newConversationLink:active {
text-decoration: none;
color: var(--color-airy-blue);
font-family: 'Lato', sans-serif;
font-size: 16px;
}

.newConversationButton {
font-weight: 600;
font-size: 20px;
color: #1578d4;
line-height: 16px;
height: 40px;
background-color: white;
border-radius: 8px;
border: 1px solid var(--color-airy-blue);
cursor: pointer;
padding: 8px 10px;
&:hover {
background-color: rgba(128, 128, 128, 0.173);
}
}
22 changes: 12 additions & 10 deletions frontend/chat-plugin/src/components/newConversation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ import {cyChatPluginStartNewConversation} from 'chat-plugin-handles';

type newConversationProps = {
reAuthenticate: () => void;
startNewConversationText: string;
};

const NewConversation = (props: newConversationProps) => {
return (
<div>
<div className={style.paragraphWrapper}>
<p className={style.newConversation}>Your conversation has ended. Thank you for</p>{' '}
<p className={style.newConversationLine}>chatting with us today.</p>
<p className={style.newConversation}>Your conversation has ended.</p>
</div>

<div>
<a
href=""
onClick={props.reAuthenticate}
className={style.newConversationLink}
data-cy={cyChatPluginStartNewConversation}>
Click Here To Start a New Conversation
</a>
<div className={style.startConversationContainer}>
<button className={style.newConversationButton}>
<a
href=""
onClick={props.reAuthenticate}
data-cy={cyChatPluginStartNewConversation}
className={style.newConversationLink}>
{props.startNewConversationText || 'Start a new Conversation'}
</a>
</button>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions frontend/chat-plugin/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type RenderProp = (ctrl?: RenderCtrl) => JSX.Element;
export type Config = {
welcomeMessage?: {};
headerText?: string;
startNewConversationText?: string;
headerTextColor?: string;
backgroundColor?: string;
primaryColor?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface CustomiseSectionProps {

export const CustomiseSection = ({channelId, host}: CustomiseSectionProps) => {
const [headerText, setHeaderText] = useState('');
const [startNewConversationText, setStartNewConversationText] = useState('');
const [bubbleIconUrl, setBubbleIconUrl] = useState('');
const [sendMessageIconUrl, setSendMessageIconUrl] = useState('');
const [headerTextColor, setHeaderTextColor] = useState('');
Expand Down Expand Up @@ -44,6 +45,7 @@ export const CustomiseSection = ({channelId, host}: CustomiseSectionProps) => {
const getTemplateConfig = () => {
if (
headerText === '' &&
startNewConversationText === '' &&
bubbleIconUrl === '' &&
sendMessageIconUrl === '' &&
headerTextColor === '' &&
Expand All @@ -55,6 +57,7 @@ export const CustomiseSection = ({channelId, host}: CustomiseSectionProps) => {
}
let config = '';
if (headerText !== '') config += `\n headerText: '${headerText}',`;
if (startNewConversationText !== '') config += `\n startNewConversationText: '${startNewConversationText}',`;
if (bubbleIconUrl !== '') config += `\n bubbleIcon: '${bubbleIconUrl}',`;
if (sendMessageIconUrl !== '') config += `\n sendMessageIcon: '${sendMessageIconUrl}',`;
if (headerTextColor !== '') config += `\n headerTextColor: '${headerTextColor}',`;
Expand All @@ -73,6 +76,7 @@ export const CustomiseSection = ({channelId, host}: CustomiseSectionProps) => {
config: {
showMode: true,
...(headerText && {headerText}),
...(startNewConversationText && {startNewConversationText}),
...(headerTextColor && {headerTextColor}),
...(primaryColor && {primaryColor}),
...(accentColor && {accentColor}),
Expand Down Expand Up @@ -126,6 +130,18 @@ export const CustomiseSection = ({channelId, host}: CustomiseSectionProps) => {
height={32}
fontClass="font-base"
/>
<Input
type="text"
name="startNewConversationText"
value={startNewConversationText}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setStartNewConversationText(e.target.value);
}}
label="Start new Conversation Text"
placeholder="(optionally) add a text"
height={32}
fontClass="font-base"
/>
<Input
type="url"
name="bubbleIconUrl"
Expand Down

0 comments on commit 80e6143

Please sign in to comment.