summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/animation/components/AnimatedPropertyListContainer.js
blob: 965099b37eb7ca1e95ce6836743a4de858aeb60e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* 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("resource://devtools/client/shared/vendor/react.js");
const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js");
const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.js");

const AnimatedPropertyList = createFactory(
  require("resource://devtools/client/inspector/animation/components/AnimatedPropertyList.js")
);
const KeyframesProgressBar = createFactory(
  require("resource://devtools/client/inspector/animation/components/KeyframesProgressBar.js")
);
const ProgressInspectionPanel = createFactory(
  require("resource://devtools/client/inspector/animation/components/ProgressInspectionPanel.js")
);

const {
  getFormatStr,
} = require("resource://devtools/client/inspector/animation/utils/l10n.js");

class AnimatedPropertyListContainer extends PureComponent {
  static get propTypes() {
    return {
      addAnimationsCurrentTimeListener: PropTypes.func.isRequired,
      animation: PropTypes.object.isRequired,
      emitEventForTest: PropTypes.func.isRequired,
      getAnimatedPropertyMap: PropTypes.func.isRequired,
      getAnimationsCurrentTime: PropTypes.func.isRequired,
      getComputedStyle: PropTypes.func.isRequired,
      removeAnimationsCurrentTimeListener: PropTypes.func.isRequired,
      simulateAnimation: PropTypes.func.isRequired,
      simulateAnimationForKeyframesProgressBar: PropTypes.func.isRequired,
      timeScale: PropTypes.object.isRequired,
    };
  }

  render() {
    const {
      addAnimationsCurrentTimeListener,
      animation,
      emitEventForTest,
      getAnimatedPropertyMap,
      getAnimationsCurrentTime,
      getComputedStyle,
      removeAnimationsCurrentTimeListener,
      simulateAnimation,
      simulateAnimationForKeyframesProgressBar,
      timeScale,
    } = this.props;

    return dom.div(
      {
        className: `animated-property-list-container ${animation.state.type}`,
      },
      ProgressInspectionPanel({
        indicator: KeyframesProgressBar({
          addAnimationsCurrentTimeListener,
          animation,
          getAnimationsCurrentTime,
          removeAnimationsCurrentTimeListener,
          simulateAnimationForKeyframesProgressBar,
          timeScale,
        }),
        list: AnimatedPropertyList({
          animation,
          emitEventForTest,
          getAnimatedPropertyMap,
          getComputedStyle,
          simulateAnimation,
        }),
        ticks: [0, 50, 100].map(position => {
          const label = getFormatStr(
            "detail.propertiesHeader.percentage",
            position
          );
          return { position, label };
        }),
      })
    );
  }
}

module.exports = AnimatedPropertyListContainer;