beem-component 1.3.9 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- import React from "react";
2
- import { Done, DoneAll } from "@material-ui/icons";
3
- import FilePresentIcon from "@mui/icons-material/FilePresent";
4
- import DownloadIcon from "@mui/icons-material/Download";
5
- import styled from "styled-components";
6
- import BmAvatar from "../../Avatars/avatars";
7
- import { BmIcons } from "../../iconStyles";
1
+ import React from 'react';
2
+ import { Done, DoneAll } from '@material-ui/icons';
3
+ import FilePresentIcon from '@mui/icons-material/FilePresent';
4
+ import DownloadIcon from '@mui/icons-material/Download';
5
+ import styled from 'styled-components';
6
+ import BmAvatar from '../../Avatars/avatars';
7
+ import { BmIcons } from '../../iconStyles';
8
8
 
9
9
  import {
10
10
  BmPrimaryWhite,
@@ -12,13 +12,13 @@ import {
12
12
  BmPrimaryBlack,
13
13
  BmSecondaryDarkGreen,
14
14
  BmGrey200,
15
- } from "../../colors";
15
+ } from '../../colors';
16
16
 
17
17
  const BmChat = styled.div`
18
18
  display: flex;
19
19
  flex-direction: column;
20
20
  height: 100%;
21
- ${"" /* border: 0.071rem solid ${BmGrey400}; */}
21
+ ${'' /* border: 0.071rem solid ${BmGrey400}; */}
22
22
  `;
23
23
 
24
24
  BmChat.Body = styled.div`
@@ -33,13 +33,13 @@ BmChat.Body = styled.div`
33
33
  const Details = styled.div`
34
34
  display: flex;
35
35
  justify-content: ${({ state }) => {
36
- if (state === "inbound") {
37
- return "flex-start";
36
+ if (state === 'inbound') {
37
+ return 'flex-start';
38
38
  }
39
- if (state === "outbound") {
40
- return "flex-end";
39
+ if (state === 'outbound') {
40
+ return 'flex-end';
41
41
  }
42
- return "row";
42
+ return 'row';
43
43
  }};
44
44
  > *:not(:last-child) {
45
45
  margin-right: 1rem;
@@ -68,22 +68,22 @@ const Messages = styled.div`
68
68
  padding: 0.5rem;
69
69
  background: ${({ state }) => {
70
70
  if (state) {
71
- if (state === "inbound") return `${BmPrimaryWhite}`;
72
- if (state === "outbound") return `${BmPrimaryBlue}`;
71
+ if (state === 'inbound') return `${BmPrimaryWhite}`;
72
+ if (state === 'outbound') return `${BmPrimaryBlue}`;
73
73
  }
74
74
  return `${BmPrimaryWhite}`;
75
75
  }};
76
76
  color: ${({ state }) => {
77
77
  if (state) {
78
- if (state === "inbound") return `${BmPrimaryBlack}`;
79
- if (state === "outbound") return `${BmPrimaryWhite}`;
78
+ if (state === 'inbound') return `${BmPrimaryBlack}`;
79
+ if (state === 'outbound') return `${BmPrimaryWhite}`;
80
80
  }
81
81
  return `${BmPrimaryWhite}`;
82
82
  }};
83
83
  border-radius: ${({ state }) => {
84
84
  if (state) {
85
- if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
86
- if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
85
+ if (state === 'inbound') return '0.21875rem 0.21875rem 0.21875rem 0rem';
86
+ if (state === 'outbound') return '0.21875rem 0.21875rem 0rem 0.21875rem';
87
87
  }
88
88
  return `${BmPrimaryWhite}`;
89
89
  }};
@@ -103,11 +103,11 @@ const MessagesSubDetails = styled.div`
103
103
  `;
104
104
 
105
105
  const handleState = ({ session }) => {
106
- if (session === "bot") {
107
- return <BmAvatar size="small" user="chatbot" />;
106
+ if (session === 'bot') {
107
+ return <BmAvatar size='small' user='chatbot' />;
108
108
  }
109
- if (session === "live") {
110
- return <BmAvatar size="small" user="employee" />;
109
+ if (session === 'live') {
110
+ return <BmAvatar size='small' user='employee' />;
111
111
  }
112
112
  };
113
113
 
@@ -119,22 +119,22 @@ const FileAttachmentWrapper = styled.div`
119
119
  padding: 1rem;
120
120
  background: ${({ state }) => {
121
121
  if (state) {
122
- if (state === "inbound") return `${BmPrimaryWhite}`;
123
- if (state === "outbound") return `${BmPrimaryBlue}`;
122
+ if (state === 'inbound') return `${BmPrimaryWhite}`;
123
+ if (state === 'outbound') return `${BmPrimaryBlue}`;
124
124
  }
125
125
  return `${BmPrimaryWhite}`;
126
126
  }};
127
127
  color: ${({ state }) => {
128
128
  if (state) {
129
- if (state === "inbound") return `${BmPrimaryBlack}`;
130
- if (state === "outbound") return `${BmPrimaryWhite}`;
129
+ if (state === 'inbound') return `${BmPrimaryBlack}`;
130
+ if (state === 'outbound') return `${BmPrimaryWhite}`;
131
131
  }
132
132
  return `${BmPrimaryWhite}`;
133
133
  }};
134
134
  border-radius: ${({ state }) => {
135
135
  if (state) {
136
- if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
137
- if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
136
+ if (state === 'inbound') return '0.21875rem 0.21875rem 0.21875rem 0rem';
137
+ if (state === 'outbound') return '0.21875rem 0.21875rem 0rem 0.21875rem';
138
138
  }
139
139
  return `${BmPrimaryWhite}`;
140
140
  }};
@@ -151,22 +151,29 @@ const FileAttachmentWrapper = styled.div`
151
151
  align-items: center;
152
152
  color: ${({ state }) => {
153
153
  if (state) {
154
- if (state === "inbound") return `${BmPrimaryBlue}`;
155
- if (state === "outbound") return `${BmPrimaryWhite}`;
154
+ if (state === 'inbound') return `${BmPrimaryBlue}`;
155
+ if (state === 'outbound') return `${BmPrimaryWhite}`;
156
156
  }
157
157
  return `${BmPrimaryWhite}`;
158
158
  }};
159
159
  }
160
- ${"" /* max-width: 100%; */}
161
- ${"" /* max-height: 100%; */}
160
+ ${'' /* max-width: 100%; */}
161
+ ${'' /* max-height: 100%; */}
162
162
  `;
163
163
 
164
- const BmFileAttachment = ({ state, file, src, fileName, ...rest }) => {
164
+ const BmFileAttachment = ({
165
+ state,
166
+ file,
167
+ src,
168
+ fileName,
169
+ onDownload,
170
+ ...rest
171
+ }) => {
165
172
  return (
166
173
  <FileAttachmentWrapper state={state} {...rest}>
167
174
  <BmIcons icon={<FilePresentIcon />} />
168
175
  {fileName}
169
- <BmIcons icon={<DownloadIcon />} />
176
+ <BmIcons icon={<DownloadIcon />} onClick={onDownload} />
170
177
  </FileAttachmentWrapper>
171
178
  );
172
179
  };
@@ -176,15 +183,15 @@ export const BmImageWrapper = styled.div`
176
183
  flex-direction: column;
177
184
  color: ${({ state }) => {
178
185
  if (state) {
179
- if (state === "inbound") return `${BmPrimaryBlack}`;
180
- if (state === "outbound") return `${BmPrimaryWhite}`;
186
+ if (state === 'inbound') return `${BmPrimaryBlack}`;
187
+ if (state === 'outbound') return `${BmPrimaryWhite}`;
181
188
  }
182
189
  return `${BmPrimaryWhite}`;
183
190
  }};
184
191
  border-radius: ${({ state }) => {
185
192
  if (state) {
186
- if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
187
- if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
193
+ if (state === 'inbound') return '0.21875rem 0.21875rem 0.21875rem 0rem';
194
+ if (state === 'outbound') return '0.21875rem 0.21875rem 0rem 0.21875rem';
188
195
  }
189
196
  return `${BmPrimaryWhite}`;
190
197
  }};
@@ -192,7 +199,7 @@ export const BmImageWrapper = styled.div`
192
199
  `;
193
200
 
194
201
  export const BmImage = styled.img`
195
- ${"" /* Fix width */}
202
+ ${'' /* Fix width */}
196
203
  width: 100%;
197
204
  object-fit: cover;
198
205
  flex-grow: 1;
@@ -202,7 +209,7 @@ export const BmImageChat = ({ state, src, fileName, ...rest }) => {
202
209
  return (
203
210
  <>
204
211
  <BmImageWrapper state={state} {...rest}>
205
- <BmImage src={src} alt="src" />
212
+ <BmImage src={src} alt='src' />
206
213
  {fileName && (
207
214
  <BmFileAttachment
208
215
  state={state}
@@ -239,7 +246,7 @@ BmChat.Details = ({
239
246
  <Details state={state} {...rest}>
240
247
  {/* Adding for mobile */}
241
248
  <MessageState>
242
- {state === "inbound" && session && handleState({ state, session })}
249
+ {state === 'inbound' && session && handleState({ state, session })}
243
250
  </MessageState>
244
251
  <MessageDetails>
245
252
  {/* For Images */}
@@ -259,20 +266,20 @@ BmChat.Details = ({
259
266
  )}
260
267
  <MessagesSubDetails>
261
268
  {displayTime && displayTime}
262
- {status === "sent" && (
269
+ {status === 'sent' && (
263
270
  <BmIcons
264
271
  icon={<DoneAll />}
265
272
  color={`${BmSecondaryDarkGreen}`}
266
- size="small"
273
+ size='small'
267
274
  />
268
275
  )}
269
- {status === "failed" && (
270
- <BmIcons icon={<Done />} color={`${BmPrimaryBlack}`} size="small" />
276
+ {status === 'failed' && (
277
+ <BmIcons icon={<Done />} color={`${BmPrimaryBlack}`} size='small' />
271
278
  )}
272
279
  </MessagesSubDetails>
273
280
  </MessageDetails>
274
281
  <MessageState>
275
- {state === "outbound" && session && handleState({ state, session })}
282
+ {state === 'outbound' && session && handleState({ state, session })}
276
283
  </MessageState>
277
284
  </Details>
278
285
  );
@@ -1,17 +1,17 @@
1
1
  /* eslint-disable import/no-anonymous-default-export */
2
- import React from "react";
3
- import BmChat from "./chatBody";
4
- import { BmIcons } from "../../iconStyles";
5
- import EmojiEmotionsIcon from "@mui/icons-material/EmojiEmotions";
6
- import AttachFileIcon from "@mui/icons-material/AttachFile";
7
- import QuickreplyIcon from "@mui/icons-material/Quickreply";
8
- import SendIcon from "@mui/icons-material/Send";
9
- import { BmInput } from "../../input";
10
- import image from "../../../assets/chart-img.png";
11
-
2
+ import React from 'react';
3
+ import BmChat from './chatBody';
4
+ import { BmIcons } from '../../iconStyles';
5
+ import EmojiEmotionsIcon from '@mui/icons-material/EmojiEmotions';
6
+ import AttachFileIcon from '@mui/icons-material/AttachFile';
7
+ import QuickreplyIcon from '@mui/icons-material/Quickreply';
8
+ import SendIcon from '@mui/icons-material/Send';
9
+ import { BmInput } from '../../input';
10
+ import image from '../../../assets/chart-img.png';
11
+ // TODO: ADD DESCRIPTION
12
12
  export default {
13
13
  component: BmChat,
14
- title: "components/Chat/MainChat/ChatBody",
14
+ title: 'components/Chat/MainChat/ChatBody',
15
15
  };
16
16
 
17
17
  export const ChatBody = () => {
@@ -19,61 +19,64 @@ export const ChatBody = () => {
19
19
  <BmChat>
20
20
  <BmChat.Body>
21
21
  <BmChat.Details
22
- state="inbound"
23
- session="bot"
22
+ state='inbound'
23
+ session='bot'
24
24
  displayTime={<p>12:00pm</p>}
25
- status="sent"
25
+ status='sent'
26
26
  >
27
27
  <p>Inbound Text Message</p>
28
28
  </BmChat.Details>
29
29
  <BmChat.Details
30
- state="inbound"
31
- session="live"
30
+ state='inbound'
31
+ session='live'
32
32
  displayTime={<p>12:00pm</p>}
33
- status="sent"
33
+ status='sent'
34
34
  fileName={<p>chat.png</p>}
35
35
  src={image}
36
36
  />
37
37
  <BmChat.Details
38
- state="inbound"
39
- session="live"
38
+ state='inbound'
39
+ session='live'
40
40
  displayTime={<p>10:00am</p>}
41
- status="failed"
41
+ status='failed'
42
42
  fileName={<p>file.csv</p>}
43
43
  file={image}
44
44
  />
45
45
  <BmChat.Details
46
- state="outbound"
47
- session="bot"
46
+ state='outbound'
47
+ session='bot'
48
48
  displayTime={<p>12:00pm</p>}
49
- status="sent"
49
+ status='sent'
50
50
  >
51
51
  <p>Outbound Text Message</p>
52
52
  </BmChat.Details>
53
53
  <BmChat.Details
54
- state="outbound"
55
- session="live"
54
+ state='outbound'
55
+ session='live'
56
56
  displayTime={<p>12:00pm</p>}
57
- status="sent"
57
+ status='sent'
58
58
  fileName={<p>chat.png</p>}
59
59
  src={image}
60
60
  />
61
61
  <BmChat.Details
62
- state="outbound"
63
- session="live"
62
+ state='outbound'
63
+ session='live'
64
64
  displayTime={<p>10:00am</p>}
65
- status="failed"
65
+ status='failed'
66
66
  fileName={<p>file.csv</p>}
67
67
  file={image}
68
+ onDownload={() => {
69
+ alert('hello');
70
+ }}
68
71
  />
69
72
  </BmChat.Body>
70
73
  <BmChat.Footer>
71
- <div className="chat-footer">
72
- <BmIcons icon={<EmojiEmotionsIcon />} size="xlarge" />
73
- <BmIcons icon={<AttachFileIcon />} size="xlarge" />
74
- <BmIcons icon={<QuickreplyIcon />} size="xlarge" />
75
- <BmInput placeholder="Enter Message" style={{ flex: "1" }} />
76
- <BmIcons icon={<SendIcon />} size="xlarge" />
74
+ <div className='chat-footer'>
75
+ <BmIcons icon={<EmojiEmotionsIcon />} size='xlarge' />
76
+ <BmIcons icon={<AttachFileIcon />} size='xlarge' />
77
+ <BmIcons icon={<QuickreplyIcon />} size='xlarge' />
78
+ <BmInput placeholder='Enter Message' style={{ flex: '1' }} />
79
+ <BmIcons icon={<SendIcon />} size='xlarge' />
77
80
  </div>
78
81
  </BmChat.Footer>
79
82
  </BmChat>
@@ -88,7 +88,7 @@ const Text = styled.text`
88
88
  const BmProgressRing = (props) => {
89
89
  const [offset, setOffset] = useState(0);
90
90
  const circleRef = useRef(null);
91
- const { size, progress, variant, children } = props;
91
+ const { size, progress, variant } = props;
92
92
 
93
93
  const initialMeasure = measurement(size);
94
94
 
@@ -11,9 +11,9 @@ const BmTabWrapper = styled.div`
11
11
  align-items: center;
12
12
  padding: 1rem;
13
13
  background: ${BmPrimaryWhite};
14
- box-shadow: ${({ state, disabled }) => {
14
+ box-shadow: ${({ state, disabled, stateColor }) => {
15
15
  if (state === "active" && !disabled) {
16
- return `inset 0px -3px 0px ${BmPrimaryBlue}`;
16
+ return `inset 0px -3px 0px ${stateColor ? stateColor : BmPrimaryBlue}`;
17
17
  }
18
18
  return "none";
19
19
  }};
@@ -86,6 +86,7 @@ BmTab.propTypes = {
86
86
  leadingIcon: PropTypes.node,
87
87
  state: PropTypes.string,
88
88
  color: PropTypes.string,
89
+ stateColor: PropTypes.string,
89
90
  size: PropTypes.string,
90
91
  disabled: PropTypes.bool,
91
92
  };
@@ -16,6 +16,11 @@ export default {
16
16
  control: { type: "select" },
17
17
  description: "State of the Tabs (optional)",
18
18
  },
19
+ stateColor: {
20
+ control: { type: "text" },
21
+ description: "Color of the active state",
22
+ defaultValue: { summary: "primary blue" },
23
+ },
19
24
  size: {
20
25
  options: ["small", "medium", "large"],
21
26
  control: { type: "select" },
@@ -23,8 +28,7 @@ export default {
23
28
  defaultValue: { summary: "large" },
24
29
  },
25
30
  disabled: {
26
- description:
27
- "Disabled tab",
31
+ description: "Disabled tab",
28
32
  },
29
33
  },
30
34
  };
@@ -37,7 +41,7 @@ BasicTab.args = {
37
41
  leadingIcon: <Favorite />,
38
42
  trailingIcon: <KeyboardArrowDown />,
39
43
  disabled: false,
40
- state: 'active',
44
+ state: "active",
41
45
  };
42
46
 
43
47
  export const DisabledTab = MainTab.bind({});
@@ -47,3 +51,13 @@ DisabledTab.args = {
47
51
  trailingIcon: <KeyboardArrowDown />,
48
52
  disabled: true,
49
53
  };
54
+
55
+ export const ColoredTab = MainTab.bind({});
56
+ ColoredTab.args = {
57
+ children: <h3>Tabs</h3>,
58
+ leadingIcon: <Favorite />,
59
+ trailingIcon: <KeyboardArrowDown />,
60
+ disabled: false,
61
+ state: "active",
62
+ stateColor: "red",
63
+ };