@@ -15,7 +15,7 @@ limitations under the License.
1515*/
1616
1717import React , { MouseEventHandler , ReactNode } from "react" ;
18- import { FormattingFunctions , AllActionStates } from "@matrix-org/matrix-wysiwyg" ;
18+ import { FormattingFunctions , AllActionStates , ActionState } from "@matrix-org/matrix-wysiwyg" ;
1919import classNames from "classnames" ;
2020
2121import { Icon as BoldIcon } from "../../../../../../res/img/element-icons/room/composer/bold.svg" ;
@@ -53,21 +53,23 @@ function Tooltip({ label, keyCombo }: TooltipProps): JSX.Element {
5353
5454interface ButtonProps extends TooltipProps {
5555 icon : ReactNode ;
56- isActive : boolean ;
56+ actionState : ActionState ;
5757 onClick : MouseEventHandler < HTMLButtonElement > ;
5858}
5959
60- function Button ( { label, keyCombo, onClick, isActive , icon } : ButtonProps ) : JSX . Element {
60+ function Button ( { label, keyCombo, onClick, actionState , icon } : ButtonProps ) : JSX . Element {
6161 return (
6262 < AccessibleTooltipButton
6363 element = "button"
6464 onClick = { onClick as ( e : ButtonEvent ) => void }
6565 title = { label }
6666 className = { classNames ( "mx_FormattingButtons_Button" , {
67- mx_FormattingButtons_active : isActive ,
68- mx_FormattingButtons_Button_hover : ! isActive ,
67+ mx_FormattingButtons_active : actionState === "reversed" ,
68+ mx_FormattingButtons_Button_hover : actionState === "enabled" ,
69+ mx_FormattingButtons_disabled : actionState === "disabled" ,
6970 } ) }
7071 tooltip = { keyCombo && < Tooltip label = { label } keyCombo = { keyCombo } /> }
72+ forceHide = { actionState === "disabled" }
7173 alignment = { Alignment . Top }
7274 >
7375 { icon }
@@ -85,53 +87,53 @@ export function FormattingButtons({ composer, actionStates }: FormattingButtonsP
8587 return (
8688 < div className = "mx_FormattingButtons" >
8789 < Button
88- isActive = { actionStates . bold === "reversed" }
90+ actionState = { actionStates . bold }
8991 label = { _td ( "Bold" ) }
9092 keyCombo = { { ctrlOrCmdKey : true , key : "b" } }
9193 onClick = { ( ) => composer . bold ( ) }
9294 icon = { < BoldIcon className = "mx_FormattingButtons_Icon" /> }
9395 />
9496 < Button
95- isActive = { actionStates . italic === "reversed" }
97+ actionState = { actionStates . italic }
9698 label = { _td ( "Italic" ) }
9799 keyCombo = { { ctrlOrCmdKey : true , key : "i" } }
98100 onClick = { ( ) => composer . italic ( ) }
99101 icon = { < ItalicIcon className = "mx_FormattingButtons_Icon" /> }
100102 />
101103 < Button
102- isActive = { actionStates . underline === "reversed" }
104+ actionState = { actionStates . underline }
103105 label = { _td ( "Underline" ) }
104106 keyCombo = { { ctrlOrCmdKey : true , key : "u" } }
105107 onClick = { ( ) => composer . underline ( ) }
106108 icon = { < UnderlineIcon className = "mx_FormattingButtons_Icon" /> }
107109 />
108110 < Button
109- isActive = { actionStates . strikeThrough === "reversed" }
111+ actionState = { actionStates . strikeThrough }
110112 label = { _td ( "Strikethrough" ) }
111113 onClick = { ( ) => composer . strikeThrough ( ) }
112114 icon = { < StrikeThroughIcon className = "mx_FormattingButtons_Icon" /> }
113115 />
114116 < Button
115- isActive = { actionStates . unorderedList === "reversed" }
117+ actionState = { actionStates . unorderedList }
116118 label = { _td ( "Bulleted list" ) }
117119 onClick = { ( ) => composer . unorderedList ( ) }
118120 icon = { < BulletedListIcon className = "mx_FormattingButtons_Icon" /> }
119121 />
120122 < Button
121- isActive = { actionStates . orderedList === "reversed" }
123+ actionState = { actionStates . orderedList }
122124 label = { _td ( "Numbered list" ) }
123125 onClick = { ( ) => composer . orderedList ( ) }
124126 icon = { < NumberedListIcon className = "mx_FormattingButtons_Icon" /> }
125127 />
126128 < Button
127- isActive = { actionStates . inlineCode === "reversed" }
129+ actionState = { actionStates . inlineCode }
128130 label = { _td ( "Code" ) }
129131 keyCombo = { { ctrlOrCmdKey : true , key : "e" } }
130132 onClick = { ( ) => composer . inlineCode ( ) }
131133 icon = { < InlineCodeIcon className = "mx_FormattingButtons_Icon" /> }
132134 />
133135 < Button
134- isActive = { actionStates . link === "reversed" }
136+ actionState = { actionStates . link }
135137 label = { _td ( "Link" ) }
136138 onClick = { ( ) => openLinkModal ( composer , composerContext , actionStates . link === "reversed" ) }
137139 icon = { < LinkIcon className = "mx_FormattingButtons_Icon" /> }
0 commit comments