@botonic/react 0.36.5 → 0.37.0-alpha.0
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.
- package/lib/cjs/components/button/index.js +1 -1
- package/lib/cjs/components/button/index.js.map +1 -1
- package/lib/cjs/components/custom-message.d.ts +1 -1
- package/lib/cjs/components/custom-message.js +4 -1
- package/lib/cjs/components/custom-message.js.map +1 -1
- package/lib/cjs/webchat/context/messages-reducer.js +6 -0
- package/lib/cjs/webchat/context/messages-reducer.js.map +1 -1
- package/lib/cjs/webchat/custom-messages/index.d.ts +1 -0
- package/lib/cjs/webchat/custom-messages/index.js +9 -0
- package/lib/cjs/webchat/custom-messages/index.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-angry.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-angry.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-angry.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-frown.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-frown.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-frown.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-grin-beam.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-grin-beam.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-grin-beam.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-meh.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-meh.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-meh.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-smile.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-smile.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/face-smile.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/index.d.ts +6 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/index.js +10 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/index.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/star.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/star.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/icons/star.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/index.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/index.js +51 -0
- package/lib/cjs/webchat/custom-messages/rating/index.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/rating-selector.d.ts +11 -0
- package/lib/cjs/webchat/custom-messages/rating/rating-selector.js +23 -0
- package/lib/cjs/webchat/custom-messages/rating/rating-selector.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/smileys.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/smileys.js +19 -0
- package/lib/cjs/webchat/custom-messages/rating/smileys.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/stars.d.ts +2 -0
- package/lib/cjs/webchat/custom-messages/rating/stars.js +11 -0
- package/lib/cjs/webchat/custom-messages/rating/stars.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/styles.d.ts +6 -0
- package/lib/cjs/webchat/custom-messages/rating/styles.js +25 -0
- package/lib/cjs/webchat/custom-messages/rating/styles.js.map +1 -0
- package/lib/cjs/webchat/custom-messages/rating/types.d.ts +13 -0
- package/lib/cjs/webchat/custom-messages/rating/types.js +9 -0
- package/lib/cjs/webchat/custom-messages/rating/types.js.map +1 -0
- package/lib/cjs/webchat/index.d.ts +1 -0
- package/lib/cjs/webchat/index.js +1 -0
- package/lib/cjs/webchat/index.js.map +1 -1
- package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
- package/lib/esm/components/button/index.js +1 -1
- package/lib/esm/components/button/index.js.map +1 -1
- package/lib/esm/components/custom-message.d.ts +1 -1
- package/lib/esm/components/custom-message.js +4 -1
- package/lib/esm/components/custom-message.js.map +1 -1
- package/lib/esm/webchat/context/messages-reducer.js +6 -0
- package/lib/esm/webchat/context/messages-reducer.js.map +1 -1
- package/lib/esm/webchat/custom-messages/index.d.ts +1 -0
- package/lib/esm/webchat/custom-messages/index.js +2 -0
- package/lib/esm/webchat/custom-messages/index.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-angry.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-angry.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-angry.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-frown.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-frown.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-frown.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-grin-beam.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-grin-beam.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-grin-beam.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-meh.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-meh.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-meh.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-smile.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-smile.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/face-smile.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/index.d.ts +6 -0
- package/lib/esm/webchat/custom-messages/rating/icons/index.js +7 -0
- package/lib/esm/webchat/custom-messages/rating/icons/index.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/icons/star.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/icons/star.js +5 -0
- package/lib/esm/webchat/custom-messages/rating/icons/star.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/index.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/index.js +49 -0
- package/lib/esm/webchat/custom-messages/rating/index.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/rating-selector.d.ts +11 -0
- package/lib/esm/webchat/custom-messages/rating/rating-selector.js +19 -0
- package/lib/esm/webchat/custom-messages/rating/rating-selector.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/smileys.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/smileys.js +15 -0
- package/lib/esm/webchat/custom-messages/rating/smileys.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/stars.d.ts +2 -0
- package/lib/esm/webchat/custom-messages/rating/stars.js +7 -0
- package/lib/esm/webchat/custom-messages/rating/stars.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/styles.d.ts +6 -0
- package/lib/esm/webchat/custom-messages/rating/styles.js +21 -0
- package/lib/esm/webchat/custom-messages/rating/styles.js.map +1 -0
- package/lib/esm/webchat/custom-messages/rating/types.d.ts +13 -0
- package/lib/esm/webchat/custom-messages/rating/types.js +6 -0
- package/lib/esm/webchat/custom-messages/rating/types.js.map +1 -0
- package/lib/esm/webchat/index.d.ts +1 -0
- package/lib/esm/webchat/index.js +1 -0
- package/lib/esm/webchat/index.js.map +1 -1
- package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
- package/package.json +1 -1
- package/src/components/button/index.tsx +2 -1
- package/src/components/custom-message.tsx +14 -11
- package/src/webchat/context/messages-reducer.ts +8 -0
- package/src/webchat/custom-messages/index.ts +1 -0
- package/src/webchat/custom-messages/rating/icons/face-angry.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-frown.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-grin-beam.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-meh.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/face-smile.tsx +21 -0
- package/src/webchat/custom-messages/rating/icons/index.ts +6 -0
- package/src/webchat/custom-messages/rating/icons/star.tsx +21 -0
- package/src/webchat/custom-messages/rating/index.tsx +91 -0
- package/src/webchat/custom-messages/rating/rating-selector.tsx +59 -0
- package/src/webchat/custom-messages/rating/smileys.tsx +27 -0
- package/src/webchat/custom-messages/rating/stars.tsx +9 -0
- package/src/webchat/custom-messages/rating/styles.ts +26 -0
- package/src/webchat/custom-messages/rating/types.ts +15 -0
- package/src/webchat/index.ts +1 -0
- package/src/webchat/input-panel/send-button.tsx +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FaceMehSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM176.4 176a32 32 0 1 1 0 64 32 32 0 1 1 0-64zm128 32a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zM160 336l192 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-192 0c-8.8 0-16-7.2-16-16s7.2-16 16-16z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M464 256A208 208 0 1 1 48 256a208 208 0 1 1 416 0zM256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM176.4 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm192-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM184 328c-13.3 0-24 10.7-24 24s10.7 24 24 24l144 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-144 0z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const FaceSmileSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM164.1 325.5C182 346.2 212.6 368 256 368s74-21.8 91.9-42.5c5.8-6.7 15.9-7.4 22.6-1.6s7.4 15.9 1.6 22.6C349.8 372.1 311.1 400 256 400s-93.8-27.9-116.1-53.5c-5.8-6.7-5.1-16.8 1.6-22.6s16.8-5.1 22.6 1.6zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm177.6 62.1C192.8 334.5 218.8 352 256 352s63.2-17.5 78.4-33.9c9-9.7 24.2-10.4 33.9-1.4s10.4 24.2 1.4 33.9c-22 23.8-60 49.4-113.6 49.4s-91.7-25.5-113.6-49.4c-9-9.7-8.4-24.9 1.4-33.9s24.9-8.4 33.9 1.4zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { RatingIconProps } from '../types'
|
|
4
|
+
|
|
5
|
+
export const StarSvg = ({ color, selected }: RatingIconProps) => {
|
|
6
|
+
return selected ? (
|
|
7
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512' color={color}>
|
|
8
|
+
<path
|
|
9
|
+
d='M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z'
|
|
10
|
+
fill='currentColor'
|
|
11
|
+
/>
|
|
12
|
+
</svg>
|
|
13
|
+
) : (
|
|
14
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512' color={color}>
|
|
15
|
+
<path
|
|
16
|
+
d='M287.9 0c9.2 0 17.6 5.2 21.6 13.5l68.6 141.3 153.2 22.6c9 1.3 16.5 7.6 19.3 16.3s.5 18.1-5.9 24.5L433.6 328.4l26.2 155.6c1.5 9-2.2 18.1-9.7 23.5s-17.3 6-25.3 1.7l-137-73.2L151 509.1c-8.1 4.3-17.9 3.7-25.3-1.7s-11.2-14.5-9.7-23.5l26.2-155.6L31.1 218.2c-6.5-6.4-8.7-15.9-5.9-24.5s10.3-14.9 19.3-16.3l153.2-22.6L266.3 13.5C270.4 5.2 278.7 0 287.9 0zm0 79L235.4 187.2c-3.5 7.1-10.2 12.1-18.1 13.3L99 217.9 184.9 303c5.5 5.5 8.1 13.3 6.8 21L171.4 443.7l105.2-56.2c7.1-3.8 15.6-3.8 22.6 0l105.2 56.2L384.2 324.1c-1.3-7.7 1.2-15.5 6.8-21l85.9-85.1L358.6 200.5c-7.8-1.2-14.6-6.1-18.1-13.3L287.9 79z'
|
|
17
|
+
fill='currentColor'
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { INPUT, InputType } from '@botonic/core'
|
|
2
|
+
import React, { useContext, useState } from 'react'
|
|
3
|
+
import { ThemeContext } from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import { Button, customMessage } from '../../../components'
|
|
6
|
+
import { WebchatContext } from '../../context'
|
|
7
|
+
import { RatingSelector } from './rating-selector'
|
|
8
|
+
import { MessageBubble } from './styles'
|
|
9
|
+
import { RatingType } from './types'
|
|
10
|
+
|
|
11
|
+
interface CustomRatingMessageProps {
|
|
12
|
+
payloads: string[]
|
|
13
|
+
messageText: string
|
|
14
|
+
buttonText: string
|
|
15
|
+
ratingType: RatingType
|
|
16
|
+
json: { messageId?: string; valueSent?: number }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CustomRatingMessage: React.FC<CustomRatingMessageProps> = props => {
|
|
20
|
+
const { payloads, messageText, buttonText, ratingType } = props
|
|
21
|
+
const { webchatState, updateMessage, sendInput } = useContext(WebchatContext)
|
|
22
|
+
|
|
23
|
+
const theme = useContext(ThemeContext)
|
|
24
|
+
const color = theme?.brand?.color ?? ''
|
|
25
|
+
|
|
26
|
+
const [ratingValue, setRatingValue] = useState(
|
|
27
|
+
props.json?.valueSent ? props.json.valueSent : -1
|
|
28
|
+
)
|
|
29
|
+
const [showRating, setShowRating] = useState(true)
|
|
30
|
+
|
|
31
|
+
const ratingChanged = (newRating: number) => {
|
|
32
|
+
setRatingValue(newRating)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const updateMessageJSON = (messageId?: string) => {
|
|
36
|
+
if (messageId) {
|
|
37
|
+
const messageToUpdate = webchatState.messagesJSON.filter(m => {
|
|
38
|
+
return m.id === messageId
|
|
39
|
+
})[0]
|
|
40
|
+
messageToUpdate.data.json.valueSent = ratingValue
|
|
41
|
+
updateMessage(messageToUpdate)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handleButtonSend = () => {
|
|
46
|
+
if (ratingValue !== -1) {
|
|
47
|
+
setShowRating(false)
|
|
48
|
+
|
|
49
|
+
const payload = payloads[ratingValue - 1]
|
|
50
|
+
|
|
51
|
+
updateMessageJSON(props.json?.messageId)
|
|
52
|
+
|
|
53
|
+
const input = {
|
|
54
|
+
type: INPUT.POSTBACK as InputType,
|
|
55
|
+
payload,
|
|
56
|
+
}
|
|
57
|
+
void sendInput(input)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const disabled = ratingValue === -1
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className='rating-message-container'>
|
|
65
|
+
<MessageBubble className='rating-message-bubble'>
|
|
66
|
+
{messageText}
|
|
67
|
+
<RatingSelector
|
|
68
|
+
color={color}
|
|
69
|
+
onRatingChange={ratingChanged}
|
|
70
|
+
ratingValue={ratingValue}
|
|
71
|
+
ratingType={ratingType}
|
|
72
|
+
valueSent={props.json?.valueSent}
|
|
73
|
+
/>
|
|
74
|
+
</MessageBubble>
|
|
75
|
+
{!props.json?.valueSent && showRating && (
|
|
76
|
+
<Button
|
|
77
|
+
autodisable={true}
|
|
78
|
+
disabled={disabled}
|
|
79
|
+
onClick={handleButtonSend}
|
|
80
|
+
>
|
|
81
|
+
{buttonText}
|
|
82
|
+
</Button>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default customMessage({
|
|
89
|
+
name: 'custom-rating',
|
|
90
|
+
component: CustomRatingMessage,
|
|
91
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Smileys } from './smileys'
|
|
4
|
+
import { Stars } from './stars'
|
|
5
|
+
import { RatingSelectorContainer } from './styles'
|
|
6
|
+
import { RatingType } from './types'
|
|
7
|
+
|
|
8
|
+
const NUMBER_OF_RATING_BUTTONS = 5
|
|
9
|
+
interface RatingSelectorProps {
|
|
10
|
+
color: string
|
|
11
|
+
isSent?: boolean
|
|
12
|
+
onRatingChange: (newRating: number) => void
|
|
13
|
+
ratingValue: number
|
|
14
|
+
ratingType: RatingType
|
|
15
|
+
valueSent?: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const RatingSelector = ({
|
|
19
|
+
color,
|
|
20
|
+
isSent,
|
|
21
|
+
onRatingChange,
|
|
22
|
+
ratingValue,
|
|
23
|
+
ratingType,
|
|
24
|
+
valueSent,
|
|
25
|
+
}: RatingSelectorProps) => {
|
|
26
|
+
const [hover, setHover] = useState<number>(valueSent ? valueSent : -1)
|
|
27
|
+
|
|
28
|
+
const onHover = (ratingNumber: number) => {
|
|
29
|
+
if (!valueSent) setHover(ratingNumber)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<RatingSelectorContainer isSent={isSent}>
|
|
34
|
+
{Array.from({ length: NUMBER_OF_RATING_BUTTONS }, (_star, i) => {
|
|
35
|
+
const ratingNumber = i + 1
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
key={i}
|
|
40
|
+
onMouseEnter={() => onHover(ratingNumber)}
|
|
41
|
+
onMouseLeave={() => onHover(ratingValue)}
|
|
42
|
+
onClick={() => onRatingChange(ratingNumber)}
|
|
43
|
+
>
|
|
44
|
+
{ratingType === RatingType.Stars && (
|
|
45
|
+
<Stars color={color} ratingNumber={ratingNumber} hover={hover} />
|
|
46
|
+
)}
|
|
47
|
+
{ratingType === RatingType.Smileys && (
|
|
48
|
+
<Smileys
|
|
49
|
+
color={color}
|
|
50
|
+
ratingNumber={ratingNumber}
|
|
51
|
+
hover={hover}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
})}
|
|
57
|
+
</RatingSelectorContainer>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
FaceAngrySvg,
|
|
5
|
+
FaceFrownSvg,
|
|
6
|
+
FaceGrinBeamSvg,
|
|
7
|
+
FaceMehSvg,
|
|
8
|
+
FaceSmileSvg,
|
|
9
|
+
} from './icons'
|
|
10
|
+
import { RatingItemProps } from './types'
|
|
11
|
+
|
|
12
|
+
const SMILEY_MAP = {
|
|
13
|
+
1: FaceFrownSvg,
|
|
14
|
+
2: FaceAngrySvg,
|
|
15
|
+
3: FaceMehSvg,
|
|
16
|
+
4: FaceSmileSvg,
|
|
17
|
+
5: FaceGrinBeamSvg,
|
|
18
|
+
} as const
|
|
19
|
+
|
|
20
|
+
export const Smileys = ({ color, ratingNumber, hover }: RatingItemProps) => {
|
|
21
|
+
const isSelected = hover === ratingNumber
|
|
22
|
+
const SmileyComponent = SMILEY_MAP[ratingNumber as keyof typeof SMILEY_MAP]
|
|
23
|
+
|
|
24
|
+
return SmileyComponent ? (
|
|
25
|
+
<SmileyComponent color={color} selected={isSelected} />
|
|
26
|
+
) : null
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { StarSvg } from './icons/index'
|
|
4
|
+
import { RatingItemProps } from './types'
|
|
5
|
+
|
|
6
|
+
export const Stars = ({ color, ratingNumber, hover }: RatingItemProps) => {
|
|
7
|
+
const isSelected = hover >= ratingNumber
|
|
8
|
+
return <StarSvg color={color} selected={isSelected} />
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
|
|
3
|
+
// TODO: Review how define all this styles
|
|
4
|
+
export const MessageBubble = styled.div`
|
|
5
|
+
margin: 0px 0px 5px 0px;
|
|
6
|
+
`
|
|
7
|
+
|
|
8
|
+
interface RatingSelectorContainerProps {
|
|
9
|
+
isSent?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const RatingSelectorContainer = styled.div<RatingSelectorContainerProps>`
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
margin-top: 16px;
|
|
17
|
+
|
|
18
|
+
& > div {
|
|
19
|
+
cursor: ${props => (props.isSent ? 'default' : 'pointer')};
|
|
20
|
+
|
|
21
|
+
svg {
|
|
22
|
+
height: 27px;
|
|
23
|
+
width: 27px;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export enum RatingType {
|
|
2
|
+
Stars = 'stars',
|
|
3
|
+
Smileys = 'smileys',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface RatingItemProps {
|
|
7
|
+
color: string
|
|
8
|
+
ratingNumber: number
|
|
9
|
+
hover: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface RatingIconProps {
|
|
13
|
+
color: string
|
|
14
|
+
selected?: boolean
|
|
15
|
+
}
|
package/src/webchat/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import SendButtonIcon from '../../assets/send-button.svg'
|
|
4
|
-
import { ROLES
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
5
|
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|