debugger icon indicating copy to clipboard operation
debugger copied to clipboard

Switch to CSS SVGs

Open jasonLaster opened this issue 9 years ago • 7 comments

We would like to switch from using react-based inline SVGs to CSS-based SVGs. The primary advantage is performance. SVGs created by React are slow to render. CSS drawn SVGs have a significant perf benefit.

Todolist:

  • [x] convert source tree arrows #4351
  • [ ] convert Object Inspector arrows (will be done in devtools-core)
  • [x] convert source tree domain / file / folder #4477
  • [x] convert close button (tabs, breakpoints, watch expressions) #4600
  • [x] convert step buttons #4502
  • [x] convert blackbox / pretty print #4386

jasonLaster avatar Oct 11 '17 15:10 jasonLaster

Gist for Pretty Print / Blackbox

diff --git a/src/components/Editor/Tabs.css b/src/components/Editor/Tabs.css
index 4d85385..4738b13 100644
--- a/src/components/Editor/Tabs.css
+++ b/src/components/Editor/Tabs.css
@@ -71,7 +71,15 @@
   line-height: 0;
 }

-.source-tab .prettyPrint svg {
+.source-tab img.prettyPrint {
+  mask: url(/images/prettyPrint.svg);
+}
+.source-tab img.blackBox {
+  mask: url(/images/prettyPrint.svg);
+}
+
+.source-tab img.prettyPrint,
+.source-tab img.blackBox {
   height: 12px;
   width: 12px;
 }
@@ -86,11 +94,6 @@
   align-self: center;
 }

-.source-tab .blackBox svg {
-  height: 12px;
-  width: 12px;
-}
-
 .source-tab .blackBox path {
   fill: var(--theme-textbox-box-shadow);
 }
 
 diff --git a/src/components/Editor/Tabs.js b/src/components/Editor/Tabs.js
index d78d4e7..026fcf4 100644
--- a/src/components/Editor/Tabs.js
+++ b/src/components/Editor/Tabs.js
@@ -482,10 +482,10 @@ class SourceTabs extends PureComponent {
     const sourceObj = source.toJS();

     if (isPretty(sourceObj)) {
-      return <Svg name="prettyPrint" />;
+      return <img className="prettyPrint" />;
     }
     if (sourceObj.isBlackBoxed) {
-      return <Svg name="blackBox" />;
+      return <img className="blackBox" />;
     }
   }

jasonLaster avatar Oct 11 '17 15:10 jasonLaster

Gist for close button

diff --git a/src/components/shared/Button/Close.css b/src/components/shared/Button/Close.css
index f642670..72ed42a 100644
--- a/src/components/shared/Button/Close.css
+++ b/src/components/shared/Button/Close.css
@@ -1,8 +1,6 @@
-.close-btn path {
-  fill: var(--theme-comment-alt);
-}
-
 .close-btn .close {
+  mask: url(/images/close.svg);
+  background-color: var(--theme-comment-alt);
   width: 14px;
   height: 14px;
   transition: all 0.15s ease-in-out;
@@ -14,7 +12,7 @@
   justify-content: center;
 }

-.close-btn .close svg {
+.close-btn img.close {
   width: 8px;
 }

@@ -26,8 +24,8 @@
   background: var(--theme-selection-background);
 }

-.close-btn:hover .close path {
-  fill: white;
+.close-btn:hover img.close {
+  background-color: white;
 }

 .close-btn.big {
@@ -42,6 +40,6 @@
   height: 16px;
 }

-.close-btn.big .close svg {
+.close-btn.big img.close {
   width: 9px;
 }
diff --git a/src/components/shared/Button/Close.js b/src/components/shared/Button/Close.js
index e9e3700..909b62a 100644
--- a/src/components/shared/Button/Close.js
+++ b/src/components/shared/Button/Close.js
@@ -1,6 +1,5 @@
 // @flow
 import React from "react";
-import Svg from "../Svg";
 import "./Close.css";

 type Props = {
@@ -16,7 +15,7 @@ function CloseButton({ handleClick, buttonClass, tooltip }: Props) {
       onClick={handleClick}
       title={tooltip}
     >
-      <Svg name="close" />
+      <img className="close" />
     </div>
   );

jasonLaster avatar Oct 11 '17 15:10 jasonLaster

/claim

jselmani avatar Oct 11 '17 16:10 jselmani

Thanks for claiming the issue! :wave:

Here are some link for getting setup, contributing, and development tips. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Oct 11 '17 16:10 claim

@jasonLaster has asked me to move on to converting the source tree domain, file, and folder. I will be working on that next. I believe this will aid issue #4168 and be a large improvement to performance.

jselmani avatar Oct 17 '17 23:10 jselmani

I will start working on converting the step buttons now to images.

jselmani avatar Oct 24 '17 01:10 jselmani

@jasonLaster can we update and close this now?

jselmani avatar Nov 16 '17 23:11 jselmani