diff --git a/webapp/channels/src/components/channel_info_rhs/header.tsx b/webapp/channels/src/components/channel_info_rhs/header.tsx index 414a47b7fd..52202b04b3 100644 --- a/webapp/channels/src/components/channel_info_rhs/header.tsx +++ b/webapp/channels/src/components/channel_info_rhs/header.tsx @@ -23,11 +23,6 @@ const Icon = styled.i` font-size:12px; `; -const BackButton = styled.button` - border: 0px; - background: transparent; -`; - const HeaderTitle = styled.span` line-height: 2.4rem; `; @@ -46,19 +41,17 @@ const Header = ({channel, isArchived, isMobile, onClose}: Props) => { return (
- {isMobile && ( - - + )} - void; } -const BackButton = styled.button` - border: 0; - background: transparent; -`; - const HeaderTitle = styled.span` line-height: 2.4rem; `; @@ -46,15 +41,15 @@ const Header = ({channel, canGoBack, onClose, goBack}: Props) => { {canGoBack && ( - - + )} diff --git a/webapp/channels/src/components/rhs_card_header/rhs_card_header.tsx b/webapp/channels/src/components/rhs_card_header/rhs_card_header.tsx index 38228d30ac..a39de92da4 100644 --- a/webapp/channels/src/components/rhs_card_header/rhs_card_header.tsx +++ b/webapp/channels/src/components/rhs_card_header/rhs_card_header.tsx @@ -29,7 +29,7 @@ type Props = { }; class RhsCardHeader extends React.PureComponent { - handleBack = (e: React.MouseEvent): void => { + handleBack = (e: React.MouseEvent): void => { e.preventDefault(); switch (this.props.previousRhsState) { @@ -135,16 +135,15 @@ class RhsCardHeader extends React.PureComponent { placement='top' overlay={backToResultsTooltip} > - - + ); } diff --git a/webapp/channels/src/components/rhs_header_post/rhs_header_post.tsx b/webapp/channels/src/components/rhs_header_post/rhs_header_post.tsx index d0577145dd..1db69e679a 100644 --- a/webapp/channels/src/components/rhs_header_post/rhs_header_post.tsx +++ b/webapp/channels/src/components/rhs_header_post/rhs_header_post.tsx @@ -160,16 +160,15 @@ class RhsHeaderPost extends React.PureComponent { placement='top' overlay={backToResultsTooltip} > - - + ); } diff --git a/webapp/channels/src/components/search_results_header/index.tsx b/webapp/channels/src/components/search_results_header/index.tsx index b0a8e2cb55..7991a97b17 100644 --- a/webapp/channels/src/components/search_results_header/index.tsx +++ b/webapp/channels/src/components/search_results_header/index.tsx @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import type {ConnectedProps} from 'react-redux'; import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import type {AnyAction, Dispatch} from 'redux'; @@ -45,4 +46,8 @@ function mapDispatchToProps(dispatch: Dispatch) { }; } -export default connect(mapStateToProps, mapDispatchToProps)(SearchResultsHeader); +const connector = connect(mapStateToProps, mapDispatchToProps); + +export type PropsFromRedux = ConnectedProps; + +export default connector(SearchResultsHeader); diff --git a/webapp/channels/src/components/search_results_header/search_results_header.test.tsx b/webapp/channels/src/components/search_results_header/search_results_header.test.tsx index ec6dd6aa64..339055e8a7 100644 --- a/webapp/channels/src/components/search_results_header/search_results_header.test.tsx +++ b/webapp/channels/src/components/search_results_header/search_results_header.test.tsx @@ -8,15 +8,16 @@ import {RHSStates} from 'utils/constants'; import type {RhsState} from 'types/store/rhs'; -import Header from './search_results_header'; +import SearchResultsHeader from './search_results_header'; describe('search_results_header', () => { test('should display back button when the parent is channel info', () => { renderWithContext( -
{ }} > {'Title'} -
, + , ); expect(screen.getByLabelText('Back Icon')).toBeInTheDocument(); }); test('should NOT diplay expand when the parent is channel info', () => { renderWithContext( -
{ }} > {'Title'} -
, + , ); expect(screen.queryByLabelText('Expand Sidebar Icon')).not.toBeInTheDocument(); }); test('should diplay expand when the parent is NOT channel info', () => { renderWithContext( -
{ }} > {'Title'} -
, + , ); expect(screen.getByLabelText('Expand Sidebar Icon')).toBeInTheDocument(); diff --git a/webapp/channels/src/components/search_results_header/search_results_header.tsx b/webapp/channels/src/components/search_results_header/search_results_header.tsx index 8acb9c8617..24f2da0a15 100644 --- a/webapp/channels/src/components/search_results_header/search_results_header.tsx +++ b/webapp/channels/src/components/search_results_header/search_results_header.tsx @@ -2,148 +2,120 @@ // See LICENSE.txt for license information. import React from 'react'; -import {FormattedMessage, type WrappedComponentProps, injectIntl} from 'react-intl'; -import styled from 'styled-components'; +import {FormattedMessage, useIntl} from 'react-intl'; -import KeyboardShortcutSequence, { - KEYBOARD_SHORTCUTS, -} from 'components/keyboard_shortcuts/keyboard_shortcuts_sequence'; -import LocalizedIcon from 'components/localized_icon'; +import KeyboardShortcutSequence, {KEYBOARD_SHORTCUTS} from 'components/keyboard_shortcuts/keyboard_shortcuts_sequence'; import OverlayTrigger from 'components/overlay_trigger'; import Tooltip from 'components/tooltip'; import Constants, {RHSStates} from 'utils/constants'; -import {t} from 'utils/i18n'; -import type {RhsState} from 'types/store/rhs'; +import type {PropsFromRedux} from './index'; -const BackButton = styled.button` - border: 0px; - background: transparent; -`; - -const BackButtonIcon = styled(LocalizedIcon)` - display: inline-flex; - align-items: center; - justify-content: center; - font-size: 18px; -`; - -interface Props extends WrappedComponentProps { - isExpanded: boolean; - previousRhsState?: RhsState; - canGoBack: boolean; - children?: React.ReactNode; - actions: { - closeRightHandSide: () => void; - toggleRhsExpanded: () => void; - goBack: () => void; - }; +export interface Props extends PropsFromRedux { + children: React.ReactNode; } -class SearchResultsHeader extends React.PureComponent { - render(): React.ReactNode { - const closeSidebarTooltip = ( - - - - ); +function SearchResultsHeader(props: Props) { + const {formatMessage} = useIntl(); - const expandSidebarTooltip = ( - - - - - ); + const closeSidebarTooltip = ( + + + + ); - const shrinkSidebarTooltip = ( - - - - - ); + const expandSidebarTooltip = ( + + + + + ); - const showExpand = this.props.previousRhsState !== RHSStates.CHANNEL_INFO; + const shrinkSidebarTooltip = ( + + + + + ); - return ( -
- - {this.props.canGoBack && ( - this.props.actions.goBack()} - > - - - )} - {this.props.children} - + const showExpand = props.previousRhsState !== RHSStates.CHANNEL_INFO; -
- {showExpand && ( - - - - )} + return ( +
+ + {props.canGoBack && ( + + )} + {props.children} + +
+ {showExpand && ( -
+ )} + + +
- ); - } +
+ ); } -export default injectIntl(SearchResultsHeader); +export default SearchResultsHeader; diff --git a/webapp/channels/src/sass/layout/_sidebar-right.scss b/webapp/channels/src/sass/layout/_sidebar-right.scss index 0485bf3551..d32e34a73c 100644 --- a/webapp/channels/src/sass/layout/_sidebar-right.scss +++ b/webapp/channels/src/sass/layout/_sidebar-right.scss @@ -87,30 +87,6 @@ flex-direction: column; } - .sidebar--right__back { - display: flex; - width: 2.4rem; - height: 2.4rem; - align-items: center; - justify-content: center; - margin-right: 4px; - border-radius: 4px; - color: rgba(var(--center-channel-color-rgb), 0.56); - font-size: 12px; - text-decoration: none; - transition: all 0.2s ease-in; - - &:hover { - background-color: rgba(var(--center-channel-color-rgb), 0.08); - color: rgba(var(--center-channel-color-rgb), 0.72); - } - - &:active { - background-color: rgba(var(--button-bg-rgb), 0.08); - color: v(button-bg); - } - } - .sidebar-right__body { display: flex; height: 100%; @@ -237,6 +213,10 @@ font-size: 20px; } + .sidebar--right__back { + margin-right: 4px !important; + } + .controls { display: flex; align-items: center;