@@ -14,10 +14,15 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- import React , { MouseEventHandler } from "react" ;
17
+ import React , { MouseEventHandler , ReactNode } from "react" ;
18
18
import { FormattingFunctions , AllActionStates } from "@matrix-org/matrix-wysiwyg" ;
19
19
import classNames from "classnames" ;
20
20
21
+ import { Icon as BoldIcon } from '../../../../../../res/img/element-icons/room/composer/bold.svg' ;
22
+ import { Icon as ItalicIcon } from '../../../../../../res/img/element-icons/room/composer/italic.svg' ;
23
+ import { Icon as UnderlineIcon } from '../../../../../../res/img/element-icons/room/composer/underline.svg' ;
24
+ import { Icon as StrikeThroughIcon } from '../../../../../../res/img/element-icons/room/composer/strikethrough.svg' ;
25
+ import { Icon as InlineCodeIcon } from '../../../../../../res/img/element-icons/room/composer/inline_code.svg' ;
21
26
import AccessibleTooltipButton from "../../../elements/AccessibleTooltipButton" ;
22
27
import { Alignment } from "../../../elements/Tooltip" ;
23
28
import { KeyboardShortcut } from "../../../settings/KeyboardShortcut" ;
@@ -38,24 +43,26 @@ function Tooltip({ label, keyCombo }: TooltipProps) {
38
43
}
39
44
40
45
interface ButtonProps extends TooltipProps {
41
- className : string ;
46
+ icon : ReactNode ;
42
47
isActive : boolean ;
43
48
onClick : MouseEventHandler < HTMLButtonElement > ;
44
49
}
45
50
46
- function Button ( { label, keyCombo, onClick, isActive, className } : ButtonProps ) {
51
+ function Button ( { label, keyCombo, onClick, isActive, icon } : ButtonProps ) {
47
52
return < AccessibleTooltipButton
48
53
element = "button"
49
54
onClick = { onClick as ( e : ButtonEvent ) => void }
50
55
title = { label }
51
56
className = {
52
- classNames ( 'mx_FormattingButtons_Button' , className , {
57
+ classNames ( 'mx_FormattingButtons_Button' , {
53
58
'mx_FormattingButtons_active' : isActive ,
54
59
'mx_FormattingButtons_Button_hover' : ! isActive ,
55
60
} ) }
56
61
tooltip = { keyCombo && < Tooltip label = { label } keyCombo = { keyCombo } /> }
57
62
alignment = { Alignment . Top }
58
- /> ;
63
+ >
64
+ { icon }
65
+ </ AccessibleTooltipButton > ;
59
66
}
60
67
61
68
interface FormattingButtonsProps {
@@ -65,10 +72,10 @@ interface FormattingButtonsProps {
65
72
66
73
export function FormattingButtons ( { composer, actionStates } : FormattingButtonsProps ) {
67
74
return < div className = "mx_FormattingButtons" >
68
- < Button isActive = { actionStates . bold === 'reversed' } label = { _td ( "Bold" ) } keyCombo = { { ctrlOrCmdKey : true , key : 'b' } } onClick = { ( ) => composer . bold ( ) } className = "mx_FormattingButtons_Button_bold" />
69
- < Button isActive = { actionStates . italic === 'reversed' } label = { _td ( 'Italic' ) } keyCombo = { { ctrlOrCmdKey : true , key : 'i' } } onClick = { ( ) => composer . italic ( ) } className = "mx_FormattingButtons_Button_italic" />
70
- < Button isActive = { actionStates . underline === 'reversed' } label = { _td ( 'Underline' ) } keyCombo = { { ctrlOrCmdKey : true , key : 'u' } } onClick = { ( ) => composer . underline ( ) } className = "mx_FormattingButtons_Button_underline" />
71
- < Button isActive = { actionStates . strikeThrough === 'reversed' } label = { _td ( 'Strikethrough' ) } onClick = { ( ) => composer . strikeThrough ( ) } className = "mx_FormattingButtons_Button_strikethrough" />
72
- < Button isActive = { actionStates . inlineCode === 'reversed' } label = { _td ( 'Code' ) } keyCombo = { { ctrlOrCmdKey : true , key : 'e' } } onClick = { ( ) => composer . inlineCode ( ) } className = "mx_FormattingButtons_Button_inline_code" />
75
+ < Button isActive = { actionStates . bold === 'reversed' } label = { _td ( "Bold" ) } keyCombo = { { ctrlOrCmdKey : true , key : 'b' } } onClick = { ( ) => composer . bold ( ) } icon = { < BoldIcon className = "mx_FormattingButtons_Icon" /> } />
76
+ < Button isActive = { actionStates . italic === 'reversed' } label = { _td ( 'Italic' ) } keyCombo = { { ctrlOrCmdKey : true , key : 'i' } } onClick = { ( ) => composer . italic ( ) } icon = { < ItalicIcon className = "mx_FormattingButtons_Icon" /> } />
77
+ < Button isActive = { actionStates . underline === 'reversed' } label = { _td ( 'Underline' ) } keyCombo = { { ctrlOrCmdKey : true , key : 'u' } } onClick = { ( ) => composer . underline ( ) } icon = { < UnderlineIcon className = "mx_FormattingButtons_Icon" /> } />
78
+ < Button isActive = { actionStates . strikeThrough === 'reversed' } label = { _td ( 'Strikethrough' ) } onClick = { ( ) => composer . strikeThrough ( ) } icon = { < StrikeThroughIcon className = "mx_FormattingButtons_Icon" /> } />
79
+ < Button isActive = { actionStates . inlineCode === 'reversed' } label = { _td ( 'Code' ) } keyCombo = { { ctrlOrCmdKey : true , key : 'e' } } onClick = { ( ) => composer . inlineCode ( ) } icon = { < InlineCodeIcon className = "mx_FormattingButtons_Icon" /> } />
73
80
</ div > ;
74
81
}
0 commit comments