@@ -3,9 +3,11 @@ import * as React from 'react';
33import classNames from 'classnames' ;
44import { injectIntl } from 'react-intl' ;
55import type { IntlShape } from 'react-intl' ;
6- import { Tooltip as BPTooltip } from '@box/blueprint-web' ;
6+ import { IconButton , Tooltip as BPTooltip } from '@box/blueprint-web' ;
77import IconHide from '../../icons/general/IconHide' ;
88import IconShow from '../../icons/general/IconShow' ;
9+ import IconRightSidebarChevronOpen from '../../icons/general/IconRightSidebarChevronOpen' ;
10+ import IconRightSidebarChevronClose from '../../icons/general/IconRightSidebarChevronClose' ;
911import PlainButton from '../plain-button' ;
1012import Tooltip from '../tooltip' ;
1113import { useFeatureConfig } from '../../elements/common/feature-checking' ;
@@ -38,34 +40,46 @@ const SidebarToggleButton = ({
3840 const intlText = intl . formatMessage ( intlMessage ) ;
3941 const classes = classNames ( className , 'bdl-SidebarToggleButton' , {
4042 'bdl-is-collapsed' : isCollapsed ,
41- 'bdl-SidebarToggleButton--modernized' : isPreviewModernizationEnabled ,
4243 } ) ;
43- const tooltipPosition = direction === DIRECTION_LEFT ? 'middle-right' : 'middle-left' ;
44- const renderButton = ( ) => {
45- if ( direction === DIRECTION_LEFT ) {
44+ const isDirectionLeft = direction === DIRECTION_LEFT ;
45+ const tooltipPosition = isDirectionLeft ? 'middle-right' : 'middle-left' ;
46+ const renderIcon = ( ) => {
47+ if ( isDirectionLeft ) {
4648 return isOpen ? < IconShow height = { 16 } width = { 16 } /> : < IconHide height = { 16 } width = { 16 } /> ;
4749 }
4850 return isOpen ? < IconHide height = { 16 } width = { 16 } /> : < IconShow height = { 16 } width = { 16 } /> ;
4951 } ;
5052
5153 if ( isPreviewModernizationEnabled ) {
52- const tooltipPositionModernized = direction === DIRECTION_LEFT ? DIRECTION_RIGHT : DIRECTION_LEFT ;
53-
54+ const tooltipPositionModernized = isDirectionLeft ? DIRECTION_RIGHT : DIRECTION_LEFT ;
5455 return (
5556 < BPTooltip content = { intlText } side = { tooltipPositionModernized } >
56- { /* Workaround to attach BP tooltip to legacy button, remove span when buttons are migrated to BP */ }
57- < span >
58- < PlainButton aria-label = { intlText } className = { classes } onClick = { onClick } type = "button" { ...rest } >
59- { renderButton ( ) }
60- </ PlainButton >
61- </ span >
57+ { isDirectionLeft ? (
58+ < IconButton
59+ aria-label = { intlText }
60+ icon = { isOpen ? IconRightSidebarChevronOpen : IconRightSidebarChevronClose }
61+ onClick = { onClick }
62+ size = "large"
63+ variant = "high-contrast"
64+ { ...rest }
65+ />
66+ ) : (
67+ < IconButton
68+ aria-label = { intlText }
69+ icon = { isOpen ? IconRightSidebarChevronClose : IconRightSidebarChevronOpen }
70+ onClick = { onClick }
71+ size = "large"
72+ variant = "high-contrast"
73+ { ...rest }
74+ />
75+ ) }
6276 </ BPTooltip >
6377 ) ;
6478 }
6579 return (
6680 < Tooltip position = { tooltipPosition } text = { intlText } >
6781 < PlainButton aria-label = { intlText } className = { classes } onClick = { onClick } type = "button" { ...rest } >
68- { renderButton ( ) }
82+ { renderIcon ( ) }
6983 </ PlainButton >
7084 </ Tooltip >
7185 ) ;
0 commit comments