Bug 1456828 - Part 1: Introduce ProgressInspectionPanel. r?gl draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 15 Jun 2018 13:38:26 +0900
changeset 807725 e3fe54fdda7b6799bae5ec9af314cc031d137f5d
parent 807585 e51f8dbf0397a7f7055dc792c3ee5ad2409e1e2c
child 807726 010a1ab9f0aa771dd49ab8fdc0e376b852a4d4d4
push id113187
push userbmo:dakatsuka@mozilla.com
push dateFri, 15 Jun 2018 15:16:41 +0000
reviewersgl
bugs1456828
milestone62.0a1
Bug 1456828 - Part 1: Introduce ProgressInspectionPanel. r?gl MozReview-Commit-ID: Jc5LEAOYvxr
devtools/client/inspector/animation/components/ProgressInspectionPanel.js
devtools/client/inspector/animation/components/TickLabels.js
devtools/client/inspector/animation/components/TickLines.js
devtools/client/inspector/animation/components/moz.build
devtools/client/themes/animation.css
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/components/ProgressInspectionPanel.js
@@ -0,0 +1,46 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
+const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+const dom = require("devtools/client/shared/vendor/react-dom-factories");
+
+const TickLabels = createFactory(require("./TickLabels"));
+const TickLines = createFactory(require("./TickLines"));
+
+/**
+ * This component is a panel for the progress of animations or keyframes, supports
+ * displaying the ticks, take the areas of indicator and the list.
+ */
+class ProgressInspectionPanel extends PureComponent {
+  static get propTypes() {
+    return {
+      indicator: PropTypes.any.isRequired,
+      list: PropTypes.any.isRequired,
+      ticks: PropTypes.arrayOf(PropTypes.object).isRequired,
+    };
+  }
+
+  render() {
+    const {
+      indicator,
+      list,
+      ticks,
+    } = this.props;
+
+    return dom.div(
+      {
+        className: "progress-inspection-panel",
+      },
+      dom.div({ className: "background" }, TickLines({ ticks })),
+      dom.div({ className: "indicator" }, indicator),
+      dom.div({ className: "header devtools-toolbar" }, TickLabels({ ticks })),
+      list
+    );
+  }
+}
+
+module.exports = ProgressInspectionPanel;
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/components/TickLabels.js
@@ -0,0 +1,41 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { PureComponent } = require("devtools/client/shared/vendor/react");
+const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+const dom = require("devtools/client/shared/vendor/react-dom-factories");
+
+/**
+ * This component is intended to show tick labels on the header.
+ */
+class TickLabels extends PureComponent {
+  static get propTypes() {
+    return {
+      ticks: PropTypes.array.isRequired,
+    };
+  }
+
+  render() {
+    const { ticks } = this.props;
+
+    return dom.div(
+      {
+        className: "tick-labels"
+      },
+      ticks.map(tick =>
+        dom.div(
+          {
+            className: "tick-label",
+            style: { left: `${ tick.position }%` },
+          },
+          tick.label
+        )
+      )
+    );
+  }
+}
+
+module.exports = TickLabels;
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/components/TickLines.js
@@ -0,0 +1,40 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { PureComponent } = require("devtools/client/shared/vendor/react");
+const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
+const dom = require("devtools/client/shared/vendor/react-dom-factories");
+
+/**
+ * This component is intended to show the tick line as the background.
+ */
+class TickLines extends PureComponent {
+  static get propTypes() {
+    return {
+      ticks: PropTypes.array.isRequired,
+    };
+  }
+
+  render() {
+    const { ticks } = this.props;
+
+    return dom.div(
+      {
+        className: "tick-lines"
+      },
+      ticks.map(tick =>
+        dom.div(
+          {
+            className: "tick-line",
+            style: { left: `${ tick.position }%` }
+          }
+        )
+      )
+    );
+  }
+}
+
+module.exports = TickLines;
--- a/devtools/client/inspector/animation/components/moz.build
+++ b/devtools/client/inspector/animation/components/moz.build
@@ -28,10 +28,13 @@ DevToolsModules(
     'CurrentTimeScrubber.js',
     'CurrentTimeScrubberController.js',
     'KeyframesProgressBar.js',
     'KeyframesProgressTickItem.js',
     'KeyframesProgressTickList.js',
     'NoAnimationPanel.js',
     'PauseResumeButton.js',
     'PlaybackRateSelector.js',
+    'ProgressInspectionPanel.js',
     'RewindButton.js',
+    'TickLabels.js',
+    'TickLines.js',
 )
--- a/devtools/client/themes/animation.css
+++ b/devtools/client/themes/animation.css
@@ -668,16 +668,74 @@ select.playback-rate-selector.devtools-b
 .animated-property-list-container.csstransition .keyframe-marker-item {
   background-color: var(--fill-color-csstransition);
 }
 
 .animated-property-list-container.scriptanimation .keyframe-marker-item {
   background-color: var(--fill-color-scriptanimation);
 }
 
+/* Common Components */
+/* Progress Inspection Panel */
+.progress-inspection-panel {
+  height: 100%;
+  overflow-y: auto;
+  overflow-x: hidden;
+}
+
+.progress-inspection-panel > .header {
+  padding: 0;
+  position: sticky;
+  top: 0;
+  z-index: 1;
+}
+
+.progress-inspection-panel > ul {
+  list-style-type: none;
+  margin: 0;
+  padding: 0;
+}
+
+.progress-inspection-panel > div,
+.progress-inspection-panel > ul > li {
+  display: grid;
+  grid-template-columns:
+    var(--sidebar-width) calc(100% - var(--sidebar-width) - var(--graph-right-offset)) var(--graph-right-offset);
+}
+
+/* Tick Lines */
+.tick-lines {
+  grid-column: 2 / 3;
+  position: relative;
+}
+
+.tick-line {
+  position: absolute;
+}
+
+.tick-line::before {
+  border-left: var(--tick-line-style);
+  content: "";
+  height: 100vh;
+  position: fixed;
+}
+
+/* Tick Labels */
+.tick-labels {
+  grid-column: 2 / 3;
+  height: 100%;
+  position: relative;
+}
+
+.tick-label {
+  border-left: var(--tick-line-style);
+  height: 100%;
+  position: absolute;
+}
+
 /* No Animation Panel */
 .animation-error-message {
   overflow: auto;
 }
 
 .animation-error-message > p {
   white-space: pre;
 }