Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Nov 25, 2024
1 parent c1f8268 commit 8052ee5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/ui/WidgetButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ export const WidgetButton = ({
}: WidgetButtonProps) => {
return (
<ButtonContainer
dir={dir}
id={elementIds.widgetToggleButton}
aria-label="Widget toggle button"
className={className}
onClick={onClick}
backgroundColor={accentColor}
animated={animated}
dir={dir}
>
<OpenIconWrapper isOpen={isOpen} animated={animated}>
<Icon.Open url={imageUrl} />
Expand Down
7 changes: 4 additions & 3 deletions src/components/widget/WidgetToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ const FloatingWidgetButton = styled(WidgetButton)`
}
`;

export type ToggleButtonProps = Omit<WidgetButtonProps, 'imageUrl'>;
export default function WidgetToggleButton() {
const { botStyle } = useWidgetSetting();
const { dir, renderWidgetToggleButton } = useConstantState();
const { isOpen, setIsOpen } = useWidgetState();

const toggleButtonProps: ToggleButtonProps = {
const toggleButtonProps: WidgetButtonProps = {
dir,
isOpen,
onClick: () => setIsOpen(!isOpen),
accentColor: botStyle.accentColor,
imageUrl: botStyle.toggleButtonUrl,
};

if (typeof renderWidgetToggleButton === 'function') {
return renderWidgetToggleButton(toggleButtonProps);
}

return <FloatingWidgetButton {...toggleButtonProps} imageUrl={botStyle.toggleButtonUrl} dir={dir} />;
return <FloatingWidgetButton {...toggleButtonProps} />;
}
9 changes: 1 addition & 8 deletions src/components/widget/WidgetWindowFullScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ function WidgetWindowFullScreen(props: ChatAiWidgetProps) {
<ProviderContainer {...props}>
<div
id={elementIds.widgetWindow}
style={{
position: 'fixed',
top: 0,
insetInlineStart: 0,
width: '100%',
height: '100%',
transform: 'scale(1)',
}}
style={{ position: 'fixed', top: 0, left: 0, width: '100%', height: '100%', transform: 'scale(1)' }}
>
<Chat fullscreen />
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from 'react';

import { StringSet } from '@uikit/ui/Label/stringSet';

import type { ToggleButtonProps } from './components/widget/WidgetToggleButton';
import type { WidgetButtonProps } from './components/ui/WidgetButton';
import { BotStyle } from './context/WidgetSettingContext';
import RefreshIcon from './icons/ic-refresh.svg';
import { FunctionCallAdapter, SendbirdChatAICallbacks, WidgetCarouselItem } from './types';
Expand Down Expand Up @@ -241,7 +241,7 @@ export interface Constant extends ConstantFeatureFlags, ConstantAIFeatures, Cons
* @private
* @description Custom widget toggle button renderer.
*/
renderWidgetToggleButton?: (props: ToggleButtonProps) => React.ReactElement;
renderWidgetToggleButton?: (props: WidgetButtonProps) => React.ReactElement;
/**
* @private
* @description Service name to be used in the widget.
Expand Down

0 comments on commit 8052ee5

Please sign in to comment.