-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
botonic-react: new typing indicator component (#2914)
## Description Create a typing indicator without scss and typescript
- Loading branch information
Showing
5 changed files
with
67 additions
and
56 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
packages/botonic-react/src/webchat/components/typing-indicator.jsx
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
packages/botonic-react/src/webchat/components/typing-indicator.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/botonic-react/src/webchat/typing-indicator/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
|
||
import { COLORS, ROLES } from '../../constants' | ||
import { Dot, TypingIndicatorWrapper } from './styles' | ||
|
||
export const TypingIndicator = () => ( | ||
<TypingIndicatorWrapper | ||
role={ROLES.TYPING_INDICATOR} | ||
className='typing-indicator' | ||
backgroundColor={COLORS.SEASHELL_WHITE} | ||
> | ||
<Dot /> | ||
<Dot /> | ||
<Dot /> | ||
</TypingIndicatorWrapper> | ||
) |
50 changes: 50 additions & 0 deletions
50
packages/botonic-react/src/webchat/typing-indicator/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import styled, { keyframes } from 'styled-components' | ||
|
||
const blink = keyframes` | ||
50% { | ||
opacity: 1; | ||
} | ||
` | ||
|
||
const bulge = keyframes` | ||
50% { | ||
transform: scale(1.05); | ||
} | ||
` | ||
|
||
interface TypingIndicatorWrapperProps { | ||
backgroundColor: string | ||
} | ||
|
||
export const TypingIndicatorWrapper = styled.div<TypingIndicatorWrapperProps>` | ||
will-change: transform; | ||
width: 44px; | ||
line-height: 0px; | ||
border-radius: 20px; | ||
padding: 8px 2px 8px; | ||
text-align: center; | ||
display: block; | ||
margin: 8px; | ||
position: relative; | ||
animation: 2s ${bulge} infinite ease-out; | ||
background-color: ${props => props.backgroundColor}; | ||
` | ||
|
||
export const Dot = styled.span` | ||
height: 6px; | ||
width: 6px; | ||
margin: 0 1px; | ||
background-color: #9e9ea1; | ||
display: inline-block; | ||
border-radius: 50%; | ||
opacity: 0.4; | ||
&:nth-of-type(1) { | ||
animation: 1s ${blink} infinite 0.3333s; | ||
} | ||
&:nth-of-type(2) { | ||
animation: 1s ${blink} infinite 0.6666s; | ||
} | ||
&:nth-of-type(3) { | ||
animation: 1s ${blink} infinite 1s; | ||
} | ||
` |