You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
3 years ago
|
import React from 'react';
|
||
|
import { useDispatch, useSelector } from 'react-redux';
|
||
3 years ago
|
import styled from 'styled-components';
|
||
3 years ago
|
import { resetOverlayMode, setOverlayMode } from '../../state/ducks/section';
|
||
|
import { getOverlayMode } from '../../state/selectors/section';
|
||
|
import { SessionIcon } from '../icon';
|
||
|
// tslint:disable: use-simple-attributes
|
||
|
|
||
3 years ago
|
const StyledMenuButton = styled.button`
|
||
3 years ago
|
position: relative;
|
||
|
display: inline-block;
|
||
|
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
3 years ago
|
background: var(--menu-button-background-color);
|
||
3 years ago
|
|
||
|
border-radius: 2px;
|
||
|
width: 51px;
|
||
|
height: 33px;
|
||
|
cursor: pointer;
|
||
|
|
||
3 years ago
|
transition: var(--default-duration);
|
||
|
|
||
3 years ago
|
:hover {
|
||
3 years ago
|
background: var(--menu-button-background-hover-color);
|
||
3 years ago
|
}
|
||
|
`;
|
||
|
|
||
|
/**
|
||
|
* This is the Session Menu Botton. i.e. the button on top of the conversation list to start a new conversation.
|
||
|
* It has two state: selected or not and so we use an checkbox input to keep the state in sync.
|
||
|
*/
|
||
|
export const MenuButton = () => {
|
||
|
const overlayMode = useSelector(getOverlayMode);
|
||
|
const dispatch = useDispatch();
|
||
|
|
||
|
const isToggled = Boolean(overlayMode);
|
||
|
|
||
|
const onClickFn = () =>
|
||
|
dispatch(isToggled ? resetOverlayMode() : setOverlayMode('choose-action'));
|
||
|
|
||
|
return (
|
||
3 years ago
|
<StyledMenuButton data-testid="new-conversation-button" onClick={onClickFn}>
|
||
3 years ago
|
<SessionIcon
|
||
|
iconSize="small"
|
||
|
iconType="plusFat"
|
||
3 years ago
|
iconColor="var(--menu-button-icon-color)"
|
||
3 years ago
|
iconRotation={isToggled ? 45 : 0}
|
||
3 years ago
|
aria-label={window.i18n('chooseAnAction')}
|
||
3 years ago
|
/>
|
||
|
</StyledMenuButton>
|
||
|
);
|
||
|
};
|