From d0d615b55ed961e665a8fc69192697a160e32524 Mon Sep 17 00:00:00 2001 From: Alun Turner Date: Wed, 18 Jan 2023 13:22:30 +0000 Subject: [PATCH 1/4] add disabled css state --- .../wysiwyg_composer/components/_FormattingButtons.pcss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/res/css/views/rooms/wysiwyg_composer/components/_FormattingButtons.pcss b/res/css/views/rooms/wysiwyg_composer/components/_FormattingButtons.pcss index fa8078279f5..8e3dd22c997 100644 --- a/res/css/views/rooms/wysiwyg_composer/components/_FormattingButtons.pcss +++ b/res/css/views/rooms/wysiwyg_composer/components/_FormattingButtons.pcss @@ -50,6 +50,12 @@ limitations under the License. } } + .mx_FormattingButtons_disabled { + .mx_FormattingButtons_Icon { + color: $quinary-content; + } + } + .mx_FormattingButtons_Icon { --size: 16px; height: var(--size); From abedaccfae6326ffc048cedf6dc85f64f1b52028 Mon Sep 17 00:00:00 2001 From: Alun Turner Date: Wed, 18 Jan 2023 13:22:42 +0000 Subject: [PATCH 2/4] conditionally apply disabled css state --- .../components/FormattingButtons.tsx | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/components/views/rooms/wysiwyg_composer/components/FormattingButtons.tsx b/src/components/views/rooms/wysiwyg_composer/components/FormattingButtons.tsx index 7c1601b4416..d93f515f16d 100644 --- a/src/components/views/rooms/wysiwyg_composer/components/FormattingButtons.tsx +++ b/src/components/views/rooms/wysiwyg_composer/components/FormattingButtons.tsx @@ -15,7 +15,7 @@ limitations under the License. */ import React, { MouseEventHandler, ReactNode } from "react"; -import { FormattingFunctions, AllActionStates } from "@matrix-org/matrix-wysiwyg"; +import { FormattingFunctions, AllActionStates, ActionState } from "@matrix-org/matrix-wysiwyg"; import classNames from "classnames"; import { Icon as BoldIcon } from "../../../../../../res/img/element-icons/room/composer/bold.svg"; @@ -53,21 +53,22 @@ function Tooltip({ label, keyCombo }: TooltipProps): JSX.Element { interface ButtonProps extends TooltipProps { icon: ReactNode; - isActive: boolean; + state: ActionState; onClick: MouseEventHandler; } -function Button({ label, keyCombo, onClick, isActive, icon }: ButtonProps): JSX.Element { +function Button({ label, keyCombo, onClick, state, icon }: ButtonProps): JSX.Element { return ( void} title={label} className={classNames("mx_FormattingButtons_Button", { - mx_FormattingButtons_active: isActive, - mx_FormattingButtons_Button_hover: !isActive, + mx_FormattingButtons_active: state === "reversed", + mx_FormattingButtons_Button_hover: state === "enabled", + mx_FormattingButtons_disabled: state === "disabled", })} - tooltip={keyCombo && } + tooltip={keyCombo && } alignment={Alignment.Top} > {icon} @@ -85,53 +86,53 @@ export function FormattingButtons({ composer, actionStates }: FormattingButtonsP return (