Skip to content

Commit

Permalink
removed expand/collapse button (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcho authored Apr 25, 2024
1 parent 821fb18 commit 5960559
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/components/CustomChannelHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export default function CustomChannelHeader({
position: 'relative',
right: isMobile
? 0
: // to make the refresh icon appear next to the expand & close icons in the widget window
60,
: // to make the refresh icon appear next to the close icon in the widget window
26,
}
: customRefreshComponent.style
}
Expand Down
41 changes: 7 additions & 34 deletions src/components/WidgetWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { useState } from 'react';
import styled, { css } from 'styled-components';

import { MAX_Z_INDEX, elementIds } from '../const';
import { useWidgetOpen } from '../context/WidgetOpenContext';
import { ReactComponent as CloseIcon } from '../icons/ic-widget-close.svg';
import { ReactComponent as CollapseIcon } from '../icons/icon-collapse.svg';
import { ReactComponent as ExpandIcon } from '../icons/icon-expand.svg';

const StyledWidgetWindowWrapper = styled.div<{
isOpen: boolean;
isExpanded: boolean;
}>`
overscroll-behavior: none;
-webkit-overflow-scrolling: auto;
Expand Down Expand Up @@ -52,26 +48,6 @@ const StyledWidgetWindowWrapper = styled.div<{
.widget-close-button {
display: none;
}
${({ isExpanded }) =>
isExpanded &&
css`
width: 743px;
height: 723px;
`}
`;

const StyledExpandButton = styled.button`
position: fixed;
right: 42px;
top: 16px;
width: 24px;
height: 24px;
background: transparent;
border: none;
display: flex;
align-items: center;
justify-content: center;
`;

const StyledCloseButton = styled.button`
Expand All @@ -85,27 +61,24 @@ const StyledCloseButton = styled.button`
display: flex;
align-items: center;
justify-content: center;
svg {
cursor: pointer;
}
`;

const WidgetWindow = ({ children }: { children: React.ReactNode }) => {
const { isOpen, setIsOpen } = useWidgetOpen();
const [isExpanded, setIsExpanded] = useState(false);

return (
<StyledWidgetWindowWrapper
isOpen={isOpen}
isExpanded={isExpanded}
id={elementIds.widgetWindow}
>
<StyledExpandButton onClick={() => setIsExpanded((prev) => !prev)}>
{isExpanded ? (
<CollapseIcon id={elementIds.collapseIcon} />
) : (
<ExpandIcon id={elementIds.expandIcon} />
)}
</StyledExpandButton>
<StyledCloseButton onClick={() => setIsOpen(false)}>
<CloseIcon id={elementIds.closeIcon} />
<CloseIcon
id={elementIds.closeIcon}
/>
</StyledCloseButton>
{children}
</StyledWidgetWindowWrapper>
Expand Down
2 changes: 0 additions & 2 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ export interface CustomRefreshComponent {
export const elementIds = {
widgetWindow: 'aichatbot-widget-window',
widgetToggleButton: 'aichatbot-widget-button',
collapseIcon: 'aichatbot-widget-collapse-icon',
expandIcon: 'aichatbot-widget-expand-icon',
closeIcon: 'aichatbot-widget-close-icon',
refreshIcon: 'aichatbot-widget-refresh-icon',
uikitModal: 'sendbird-modal-root',
Expand Down
2 changes: 1 addition & 1 deletion src/icons/ic-widget-close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/icons/icon-collapse.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/icons/icon-expand.svg

This file was deleted.

0 comments on commit 5960559

Please sign in to comment.