Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix state of the icons in Toolbar being too hard to see #2091

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/app/components/editor/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type MarkButtonProps = { format: MarkType; icon: IconSrc; tooltip: ReactNode };
export function MarkButton({ format, icon, tooltip }: MarkButtonProps) {
const editor = useSlate();
const disableInline = isBlockActive(editor, BlockType.CodeBlock);
const isActive = isMarkActive(editor, format);

if (disableInline) {
removeAllMark(editor);
Expand All @@ -75,12 +76,12 @@ export function MarkButton({ format, icon, tooltip }: MarkButtonProps) {
ref={triggerRef}
variant="SurfaceVariant"
onClick={handleClick}
aria-pressed={isMarkActive(editor, format)}
aria-pressed={isActive}
size="400"
radii="300"
disabled={disableInline}
>
<Icon size="200" src={icon} />
<Icon size="200" src={icon} filled={isActive} />
</IconButton>
)}
</TooltipProvider>
Expand All @@ -94,6 +95,7 @@ type BlockButtonProps = {
};
export function BlockButton({ format, icon, tooltip }: BlockButtonProps) {
const editor = useSlate();
const isActive = isBlockActive(editor, format);

const handleClick = () => {
toggleBlock(editor, format, { level: 1 });
Expand All @@ -107,11 +109,11 @@ export function BlockButton({ format, icon, tooltip }: BlockButtonProps) {
ref={triggerRef}
variant="SurfaceVariant"
onClick={handleClick}
aria-pressed={isBlockActive(editor, format)}
aria-pressed={isActive}
size="400"
radii="300"
>
<Icon size="200" src={icon} />
<Icon size="200" src={icon} filled={isActive} />
</IconButton>
)}
</TooltipProvider>
Expand Down Expand Up @@ -215,7 +217,11 @@ export function HeadingBlockButton() {
size="400"
radii="300"
>
<Icon size="200" src={level ? Icons[`Heading${level}`] : Icons.Heading1} />
<Icon
size="200"
src={level ? Icons[`Heading${level}`] : Icons.Heading1}
filled={isActive}
/>
<Icon size="200" src={isActive ? Icons.Cross : Icons.ChevronBottom} />
</IconButton>
</PopOut>
Expand Down
Loading