hide fill icons when fill color transparent (#2414)

Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
This commit is contained in:
Aakansha Doshi 2020-11-27 02:13:38 +05:30 committed by GitHub
parent 6c0296c434
commit ca60244aa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 289 additions and 16 deletions

View file

@ -12,7 +12,7 @@ import {
import { t } from "../i18n";
import { SHAPES } from "../shapes";
import { ToolButton } from "./ToolButton";
import { capitalizeString, setCursorForShape } from "../utils";
import { capitalizeString, isTransparent, setCursorForShape } from "../utils";
import Stack from "./Stack";
import useIsMobile from "../is-mobile";
import { getNonDeletedElements } from "../element";
@ -34,20 +34,22 @@ export const SelectedShapeActions = ({
);
const isEditing = Boolean(appState.editingElement);
const isMobile = useIsMobile();
const isRTL = document.documentElement.getAttribute("dir") === "rtl";
const showFillIcons =
hasBackground(elementType) ||
targetElements.some(
(element) =>
hasBackground(element.type) && !isTransparent(element.backgroundColor),
);
const showChangeBackgroundIcons =
hasBackground(elementType) ||
targetElements.some((element) => hasBackground(element.type));
return (
<div className="panelColumn">
{renderAction("changeStrokeColor")}
{(hasBackground(elementType) ||
targetElements.some((element) => hasBackground(element.type))) && (
<>
{renderAction("changeBackgroundColor")}
{renderAction("changeFillStyle")}
</>
)}
{showChangeBackgroundIcons && renderAction("changeBackgroundColor")}
{showFillIcons && renderAction("changeFillStyle")}
{(hasStroke(elementType) ||
targetElements.some((element) => hasStroke(element.type))) && (