-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/1499-2
- Loading branch information
Showing
102 changed files
with
3,071 additions
and
757 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"packages": ["packages/*"], | ||
"version": "2.18.0", | ||
"version": "2.20.0", | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
32 changes: 32 additions & 0 deletions
32
...react-components/src/components/AnimatedTextContainer/AnimatedTextContainer.mdx
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,32 @@ | ||
import { Meta, Title, Canvas, ArgTypes } from '@storybook/blocks'; | ||
|
||
import * as Stories from './AnimatedTextContainer.stories'; | ||
|
||
<Meta of={Stories} /> | ||
|
||
<Title>AnimatedTextContainer</Title> | ||
|
||
[Intro](#Intro) | [Usage](#Usage) | [Component API](#ComponentAPI) | ||
|
||
## Intro <a id="Intro" /> | ||
|
||
The `AnimatedTextContainer` components gives the possibility to put own text which will be rendered with typing animation. It also provides possibility to put own handler which will be executed at the end of animation. | ||
|
||
<Canvas of={Stories.Default} /> | ||
|
||
## Usage <a id="Usage" /> | ||
|
||
```tsx | ||
import { AnimatedTextContainer } from '@livechat/design-system-react-components'; | ||
|
||
return ( | ||
<AnimatedTextContainer | ||
text={/* your text here */} | ||
onTypingEnd={/* your handler here */} | ||
/> | ||
) | ||
``` | ||
|
||
## Component API <a id="ComponentAPI" /> | ||
|
||
<ArgTypes of={Stories.Default} sort="requiredFirst" /> |
23 changes: 23 additions & 0 deletions
23
...s/react-components/src/components/AnimatedTextContainer/AnimatedTextContainer.stories.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,23 @@ | ||
import { Meta } from '@storybook/react'; | ||
|
||
import { AnimatedTextContainer } from './AnimatedTextContainer'; | ||
|
||
export default { | ||
title: 'Components/AnimatedTextContainer', | ||
component: AnimatedTextContainer, | ||
} as Meta<typeof AnimatedTextContainer>; | ||
|
||
const TEXT = | ||
'We have prepared the playground ready for you to test all capabilities of chat section. If you have any question, just trigger me from the upper -right corner of the screen!'; | ||
|
||
export const Default = () => { | ||
return ( | ||
<div | ||
style={{ | ||
width: 360, | ||
}} | ||
> | ||
<AnimatedTextContainer text={TEXT} /> | ||
</div> | ||
); | ||
}; |
50 changes: 50 additions & 0 deletions
50
packages/react-components/src/components/AnimatedTextContainer/AnimatedTextContainer.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,50 @@ | ||
import { FC, useEffect, useState } from 'react'; | ||
|
||
import { IAnimatedTextContainerProps } from './types'; | ||
|
||
const TYPING_SPEED = 10; | ||
const TYPING_DELAY = 600; | ||
|
||
export const AnimatedTextContainer: FC<IAnimatedTextContainerProps> = ({ | ||
text, | ||
typingAnimation = true, | ||
typingDelay = TYPING_DELAY, | ||
typingSpeed = TYPING_SPEED, | ||
onTypingEnd, | ||
}) => { | ||
const [displayedText, setDisplayedText] = useState(''); | ||
const [_, setIndex] = useState(0); | ||
|
||
useEffect(() => { | ||
if (!text) return; | ||
|
||
if (!typingAnimation && onTypingEnd) { | ||
return onTypingEnd(); | ||
} | ||
|
||
const startTyping = () => { | ||
const interval = setInterval(() => { | ||
setIndex((prevIndex) => { | ||
if (prevIndex < text.length) { | ||
setDisplayedText((prevText) => prevText + text[prevIndex]); | ||
|
||
return prevIndex + 1; | ||
} else { | ||
clearInterval(interval); | ||
onTypingEnd?.(); | ||
|
||
return prevIndex; | ||
} | ||
}); | ||
}, typingSpeed); | ||
}; | ||
|
||
const timeout = setTimeout(startTyping, typingDelay); | ||
|
||
return () => { | ||
clearTimeout(timeout); | ||
}; | ||
}, [text, typingAnimation]); | ||
|
||
return <>{typingAnimation ? displayedText : text}</>; | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/react-components/src/components/AnimatedTextContainer/index.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 @@ | ||
export { AnimatedTextContainer } from './AnimatedTextContainer'; |
22 changes: 22 additions & 0 deletions
22
packages/react-components/src/components/AnimatedTextContainer/types.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,22 @@ | ||
export interface IAnimatedTextContainerProps { | ||
/** | ||
* Simple text to display | ||
*/ | ||
text: string; | ||
/** | ||
* Should the text typing be animated | ||
*/ | ||
typingAnimation?: boolean; | ||
/** | ||
* Delay before typing starts | ||
*/ | ||
typingDelay?: number; | ||
/** | ||
* Typing animation speed | ||
*/ | ||
typingSpeed?: number; | ||
/** | ||
* Callback when typing animation ends | ||
*/ | ||
onTypingEnd?: () => void; | ||
} |
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
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
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
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
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
Oops, something went wrong.