Skip to content

Commit

Permalink
(feat:Widget) enhanced transition, buttonText param
Browse files Browse the repository at this point in the history
  • Loading branch information
ManishMadan2882 committed Nov 9, 2024
1 parent 84377ee commit 06518c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
56 changes: 26 additions & 30 deletions extensions/react-widget/src/components/DocsGPTWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,44 +69,39 @@ const WidgetContainer = styled.div<{ modal?: boolean, isOpen?: boolean }>`
display: none;
transform-origin:100% 100%;
&.open {
animation: createBox 500ms cubic-bezier(0.25, 0.1, 0.25, 1) forwards;;
animation: createBox 250ms cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}
&.close {
animation: closeBox 500ms cubic-bezier(0.6, 0.05, 0.15, 1) forwards;
animation: closeBox 250ms cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}
${props => props.modal &&
"transform : translate(50%,50%);"
}
align-items: center;
text-align: left;
@keyframes createBox {
0% {
transform: scale(0.5);
}
60% {
transform: scale(1.05) translate(-2%,-2%);
}
100% {
transform: scale(1);
}
}
0% {
transform: scale(0.5);
}
90% {
transform: scale(1.02);
}
100% {
transform: scale(1);
}
}
@keyframes closeBox {
0% {
transform: scale(1) translate(0, 0);
}
40% {
transform: scale(1.05) translate(-2%, -2%);
}
100% {
transform: scale(0);
}
}
@keyframes closeBox {
0% {
transform: scale(1);
}
10% {
transform: scale(1.02);
}
100% {
transform: scale(0);
}
}
`;
const StyledContainer = styled.div`
all: initial;
Expand Down Expand Up @@ -427,6 +422,7 @@ export const DocsGPTWidget = ({
size = 'small',
theme = 'dark',
buttonIcon = 'https://d3dg1063dc54p9.cloudfront.net/widget/chat.svg',
buttonText = 'Ask a question',
buttonBg = 'linear-gradient(to bottom right, #5AF0EC, #E80D9D)',
collectFeedback = true,
deafultOpen = false
Expand Down Expand Up @@ -555,7 +551,7 @@ export const DocsGPTWidget = ({
size !== "large" ? setTimeout(() => {
if (widgetRef.current)
widgetRef.current.style.display = "none"
}, 500)
}, 250)
:
widgetRef.current && (widgetRef.current.style.display = "none")
};
Expand All @@ -576,7 +572,7 @@ export const DocsGPTWidget = ({
}
<FloatingButton bgcolor={buttonBg} onClick={handleOpen} hidden={open}>
<img width={24} src={buttonIcon} />
<span>Ask a question</span>
<span>{buttonText}</span>
</FloatingButton>
<WidgetContainer ref={widgetRef} className={`${size != "large" && (open ? "open" : "close")}`} modal={size == 'large'}>
{<StyledContainer>
Expand Down
1 change: 1 addition & 0 deletions extensions/react-widget/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface WidgetProps {
};
theme?:THEME,
buttonIcon?:string;
buttonText?:string;
buttonBg?:string;
collectFeedback?:boolean;
deafultOpen?: boolean;
Expand Down

0 comments on commit 06518c2

Please sign in to comment.