-
Notifications
You must be signed in to change notification settings - Fork 1.6k
merge #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
merge #340
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,9 @@ type Props = ButtonTheme & { | |
| toggleBot: () => void; | ||
| setButtonPosition: (position: { bottom: number; right: number }) => void; | ||
| dragAndDrop: boolean; | ||
| autoOpen?: boolean; // Optional parameter to control automatic window opening | ||
| openDelay?: number; // Optional parameter for delay time in seconds | ||
| autoOpenOnMobile?: boolean; // Optional parameter for opening on mobile | ||
| autoOpen?: boolean; | ||
| openDelay?: number; | ||
| autoOpenOnMobile?: boolean; | ||
| }; | ||
|
|
||
| const defaultButtonColor = '#3B81F6'; | ||
|
|
@@ -18,8 +18,6 @@ const defaultBottom = 20; | |
| const defaultRight = 20; | ||
|
|
||
| export const BubbleButton = (props: Props) => { | ||
| const buttonSize = getBubbleButtonSize(props.size); | ||
|
|
||
| const [position, setPosition] = createSignal({ | ||
| bottom: props.bottom ?? defaultBottom, | ||
| right: props.right ?? defaultRight, | ||
|
|
@@ -46,7 +44,7 @@ export const BubbleButton = (props: Props) => { | |
| const newRight = initialRight + deltaX; | ||
|
|
||
| const screenWidth = window.innerWidth; | ||
| const maxRight = screenWidth - buttonSize; | ||
| const maxRight = screenWidth - 200; // Adjusted for wider button | ||
|
|
||
| const newPosition = { | ||
| right: Math.min(Math.max(newRight, defaultRight), maxRight), | ||
|
|
@@ -64,17 +62,16 @@ export const BubbleButton = (props: Props) => { | |
|
|
||
| const handleButtonClick = () => { | ||
| props.toggleBot(); | ||
| setUserInteracted(true); // Mark that the user has interacted | ||
| setUserInteracted(true); | ||
| if (window.innerWidth <= 640) { | ||
| setIsSmallScreen(true); | ||
| } | ||
| }; | ||
|
|
||
| createEffect(() => { | ||
| // Automatically open the chat window if autoOpen is true | ||
| if (props.autoOpen && (props.autoOpenOnMobile || window.innerWidth > 640)) { | ||
| const delayInSeconds = props.openDelay ?? 2; // Default to 2 seconds if openDelay is not defined | ||
| const delayInMilliseconds = delayInSeconds * 1000; // Convert seconds to milliseconds | ||
| const delayInSeconds = props.openDelay ?? 2; | ||
| const delayInMilliseconds = delayInSeconds * 1000; | ||
| setTimeout(() => { | ||
| if (!props.isBotOpened && !userInteracted()) { | ||
| props.toggleBot(); | ||
|
|
@@ -89,57 +86,67 @@ export const BubbleButton = (props: Props) => { | |
| part="button" | ||
| onClick={handleButtonClick} | ||
| onMouseDown={onMouseDown} | ||
| class={`fixed shadow-md rounded-full hover:scale-110 active:scale-95 transition-transform duration-200 flex justify-center items-center animate-fade-in`} | ||
| class={`fixed shadow-md rounded-full hover:scale-105 active:scale-95 transition-transform duration-200 flex justify-center items-center animate-fade-in gap-2 px-4`} | ||
| style={{ | ||
| 'background-color': props.backgroundColor ?? defaultButtonColor, | ||
| 'z-index': 42424242, | ||
| right: `${position().right}px`, | ||
| bottom: `${position().bottom}px`, | ||
| width: `${buttonSize}px`, | ||
| height: `${buttonSize}px`, | ||
| height: '56px', | ||
| cursor: props.dragAndDrop ? 'grab' : 'pointer', | ||
| 'min-width': '180px', | ||
| }} | ||
|
Comment on lines
90
to
98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The button's style is static, with a |
||
| > | ||
| <Show when={isNotDefined(props.customIconSrc)} keyed> | ||
| <svg | ||
| viewBox="0 0 24 24" | ||
| <Show when={!props.isBotOpened}> | ||
| {/* Logo/Icon */} | ||
| <Show when={isNotDefined(props.customIconSrc)} keyed> | ||
| <svg | ||
| viewBox="0 0 24 24" | ||
| style={{ | ||
| stroke: props.iconColor ?? defaultIconColor, | ||
| }} | ||
| class="stroke-2 fill-transparent" | ||
| width={32} | ||
| height={32} | ||
| > | ||
| <path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" /> | ||
| </svg> | ||
| </Show> | ||
| <Show when={props.customIconSrc}> | ||
| <img | ||
| src={props.customIconSrc} | ||
| class="rounded-full object-cover" | ||
| style={{ | ||
| width: '32px', | ||
| height: '32px', | ||
| }} | ||
| alt="AquaSolar logo" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| /> | ||
| </Show> | ||
|
|
||
| {/* Text */} | ||
| <span | ||
| style={{ | ||
| stroke: props.iconColor ?? defaultIconColor, | ||
| color: props.iconColor ?? defaultIconColor, | ||
| 'font-size': '16px', | ||
| 'font-weight': '600', | ||
| 'white-space': 'nowrap', | ||
| }} | ||
| class={ | ||
| `stroke-2 fill-transparent absolute duration-200 transition ` + (props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100') | ||
| } | ||
| width={buttonSize * 0.6} | ||
| height={buttonSize * 0.6} | ||
| > | ||
| <path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" /> | ||
| </svg> | ||
| </Show> | ||
| <Show when={props.customIconSrc}> | ||
| <img | ||
| src={props.customIconSrc} | ||
| class={'rounded-full object-cover' + (props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100')} | ||
| style={{ | ||
| width: `${buttonSize * 0.6}px`, | ||
| height: `${buttonSize * 0.6}px`, | ||
| }} | ||
| alt="Bubble button icon" | ||
| /> | ||
| Ask Aquamen🤖 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </span> | ||
| </Show> | ||
|
|
||
| <svg | ||
| viewBox="0 0 24 24" | ||
| style={{ fill: props.iconColor ?? 'white' }} | ||
| class={`absolute duration-200 transition ` + (props.isBotOpened ? 'scale-100 rotate-0 opacity-100' : 'scale-0 -rotate-180 opacity-0')} | ||
| width={buttonSize * 0.6} | ||
| height={buttonSize * 0.6} | ||
| > | ||
| <path | ||
| fill-rule="evenodd" | ||
| clip-rule="evenodd" | ||
| d="M18.601 8.39897C18.269 8.06702 17.7309 8.06702 17.3989 8.39897L12 13.7979L6.60099 8.39897C6.26904 8.06702 5.73086 8.06702 5.39891 8.39897C5.06696 8.73091 5.06696 9.2691 5.39891 9.60105L11.3989 15.601C11.7309 15.933 12.269 15.933 12.601 15.601L18.601 9.60105C18.9329 9.2691 18.9329 8.73091 18.601 8.39897Z" | ||
| /> | ||
| </svg> | ||
| {/* Close icon when opened */} | ||
| <Show when={props.isBotOpened}> | ||
| <svg viewBox="0 0 24 24" style={{ fill: props.iconColor ?? 'white' }} width={24} height={24}> | ||
| <path | ||
| fill-rule="evenodd" | ||
| clip-rule="evenodd" | ||
| d="M18.601 8.39897C18.269 8.06702 17.7309 8.06702 17.3989 8.39897L12 13.7979L6.60099 8.39897C6.26904 8.06702 5.73086 8.06702 5.39891 8.39897C5.06696 8.73091 5.06696 9.2691 5.39891 9.60105L11.3989 15.601C11.7309 15.933 12.269 15.933 12.601 15.601L18.601 9.60105C18.9329 9.2691 18.9329 8.73091 18.601 8.39897Z" | ||
| /> | ||
| </svg> | ||
| </Show> | ||
| </button> | ||
| </Show> | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
buttonSizevariable, which was calculated based on thesizeprop, has been removed. Consequently, the button's dimensions and related calculations now use hardcoded values (e.g.,height: '56px',min-width: '180px', and200formaxRight). This has two main implications:sizeprop fromButtonThemeis no longer used to control the button's dimensions, which is a breaking change for consumers of this component. If this is intentional, it should be documented.