Skip to content

Commit 0b5e263

Browse files
committed
- add chatbot components to a specific folder
- rename step component folders - add floatingStyle prop to chatbot
1 parent f3f7c37 commit 0b5e263

40 files changed

+113
-68
lines changed

dist/react-simple-chatbot.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.

lib/ChatBot.jsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ import _ from 'lodash';
22
import React, { Component } from 'react';
33
import PropTypes from 'prop-types';
44
import Random from 'random-id';
5-
import { CustomStep, OptionsStep, TextStep } from './steps';
5+
import { CustomStep, OptionsStep, TextStep } from './steps_components';
66
import schema from './schemas/schema';
77
import * as storage from './storage';
8-
import ChatBotContainer from './ChatBotContainer';
9-
import Content from './Content';
10-
import Header from './Header';
11-
import HeaderTitle from './HeaderTitle';
12-
import HeaderIcon from './HeaderIcon';
13-
import FloatButton from './FloatButton';
14-
import Footer from './Footer';
15-
import Input from './Input';
16-
import SubmitButton from './SubmitButton';
8+
import {
9+
ChatBotContainer,
10+
Content,
11+
Header,
12+
HeaderTitle,
13+
HeaderIcon,
14+
FloatButton,
15+
Footer,
16+
Input,
17+
SubmitButton,
18+
} from './components';
1719
import Recognition from './recognition';
1820
import { ChatIcon, CloseIcon, SubmitIcon, MicIcon } from './icons';
1921
import { isMobile } from './utils';
@@ -520,6 +522,7 @@ class ChatBot extends Component {
520522
className,
521523
contentStyle,
522524
floating,
525+
floatingStyle,
523526
footerStyle,
524527
headerComponent,
525528
headerTitle,
@@ -559,6 +562,7 @@ class ChatBot extends Component {
559562
{floating && (
560563
<FloatButton
561564
className="rsc-float-button"
565+
style={floatingStyle}
562566
opened={opened}
563567
onClick={() => this.toggleChatBot(true)}
564568
>
@@ -568,6 +572,7 @@ class ChatBot extends Component {
568572
<ChatBotContainer
569573
className="rsc-container"
570574
floating={floating}
575+
floatingStyle={floatingStyle}
571576
opened={opened}
572577
style={style}
573578
width={width}
@@ -635,6 +640,7 @@ ChatBot.propTypes = {
635640
customStyle: PropTypes.object,
636641
enableMobileAutoFocus: PropTypes.bool,
637642
floating: PropTypes.bool,
643+
floatingStyle: PropTypes.object,
638644
footerStyle: PropTypes.object,
639645
handleEnd: PropTypes.func,
640646
headerComponent: PropTypes.element,
@@ -673,6 +679,7 @@ ChatBot.defaultProps = {
673679
customDelay: 1000,
674680
enableMobileAutoFocus: false,
675681
floating: false,
682+
floatingStyle: {},
676683
footerStyle: {},
677684
handleEnd: undefined,
678685
headerComponent: undefined,

lib/ChatBotContainer.jsx

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import styled from 'styled-components';
2+
import defaultTheme from '../theme';
3+
4+
const ChatBotContainer = styled.div`
5+
background: ${({ theme }) => theme.background};
6+
border-radius: 10px;
7+
box-shadow: 0 12px 24px 0 rgba(0, 0, 0, 0.15);
8+
font-family: ${({ theme }) => theme.fontFamily};
9+
overflow: hidden;
10+
position: ${({ floating }) => floating ? 'fixed' : 'relative'};
11+
bottom: ${({ floating, floatingStyle }) => floating ? floatingStyle.bottom || '32px' : 'initial'};
12+
top: ${({ floating, floatingStyle }) => floating ? floatingStyle.top || 'initial' : 'initial'};
13+
right: ${({ floating, floatingStyle }) => floating ? floatingStyle.right || '32px' : 'initial'};
14+
left: ${({ floating, floatingStyle }) => floating ? floatingStyle.left || 'initial' : 'initial'};
15+
width: ${({ width }) => width};
16+
height: ${({ height }) => height};
17+
z-index: 999;
18+
transform: ${({ opened }) => opened ? 'scale(1)' : 'scale(0)'};
19+
transform-origin: ${({ floatingStyle }) => floatingStyle.transformOrigin || 'bottom right'};
20+
transition: transform .3s ease;
21+
22+
@media screen and (max-width: 568px) {
23+
border-radius: ${({ floating }) => floating ? '0' : ''};
24+
bottom: 0 !important;
25+
left: initial !important;
26+
height: 100%;
27+
right: 0 !important;
28+
top: initial !important;
29+
width: 100%;
30+
}
31+
`;
32+
33+
ChatBotContainer.defaultProps = {
34+
theme: defaultTheme,
35+
};
36+
37+
export default ChatBotContainer;

0 commit comments

Comments
 (0)