@cloudflare/component-card 10.0.17 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 077d121634: Adds tracking to CardDrawers when they are opened
8
+
9
+ ## 10.0.18
10
+
11
+ ### Patch Changes
12
+
13
+ - @cloudflare/component-arrow-swivel@8.0.17
14
+ - @cloudflare/component-button@8.3.12
15
+ - @cloudflare/component-link@8.0.23
16
+
3
17
  ## 10.0.17
4
18
 
5
19
  ### Patch Changes
package/es/CardDrawers.js CHANGED
@@ -86,6 +86,7 @@ class CardDrawers extends React.Component {
86
86
  } else {
87
87
  triggers.push(content ? /*#__PURE__*/React.createElement(CardToolbarDrawerTrigger, {
88
88
  key: triggerId,
89
+ name: name,
89
90
  id: triggerId,
90
91
  isActive: isActive,
91
92
  onClick: () => this.handleLinkClick(drawerId),
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { TextButton } from '@cloudflare/component-button';
4
4
  import { ArrowSwivel } from '@cloudflare/component-arrow-swivel';
5
+ import sparrow from '@cloudflare/util-sparrow';
5
6
 
6
7
  class CardToolbarDrawerTrigger extends React.Component {
7
8
  constructor(props) {
@@ -9,6 +10,22 @@ class CardToolbarDrawerTrigger extends React.Component {
9
10
  this.handleClick = this.handleClick.bind(this);
10
11
  }
11
12
 
13
+ componentDidUpdate() {
14
+ var {
15
+ isActive,
16
+ name
17
+ } = this.props;
18
+
19
+ if (isActive) {
20
+ sparrow.sendEvent('click help drawer', {
21
+ name,
22
+ category: 'help drawer',
23
+ location: document.location.href,
24
+ open: isActive
25
+ });
26
+ }
27
+ }
28
+
12
29
  handleClick(e) {
13
30
  e.preventDefault();
14
31
  this.props.onClick();
@@ -48,7 +65,8 @@ CardToolbarDrawerTrigger.propTypes = {
48
65
  children: PropTypes.node,
49
66
  ariaControls: PropTypes.string.isRequired,
50
67
  ariaExpanded: PropTypes.bool.isRequired,
51
- ariaLabel: PropTypes.string
68
+ ariaLabel: PropTypes.string,
69
+ name: PropTypes.string.isRequired
52
70
  };
53
71
  CardToolbarDrawerTrigger.defaultProps = {
54
72
  isActive: false
@@ -143,6 +143,7 @@ var CardDrawers = /*#__PURE__*/function (_React$Component) {
143
143
  } else {
144
144
  triggers.push(content ? /*#__PURE__*/_react.default.createElement(_CardToolbarDrawerTrigger.default, {
145
145
  key: triggerId,
146
+ name: name,
146
147
  id: triggerId,
147
148
  isActive: isActive,
148
149
  onClick: function onClick() {
@@ -15,6 +15,8 @@ var _componentButton = require("@cloudflare/component-button");
15
15
 
16
16
  var _componentArrowSwivel = require("@cloudflare/component-arrow-swivel");
17
17
 
18
+ var _utilSparrow = _interopRequireDefault(require("@cloudflare/util-sparrow"));
19
+
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
21
 
20
22
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -53,6 +55,22 @@ var CardToolbarDrawerTrigger = /*#__PURE__*/function (_React$Component) {
53
55
  }
54
56
 
55
57
  _createClass(CardToolbarDrawerTrigger, [{
58
+ key: "componentDidUpdate",
59
+ value: function componentDidUpdate() {
60
+ var _this$props = this.props,
61
+ isActive = _this$props.isActive,
62
+ name = _this$props.name;
63
+
64
+ if (isActive) {
65
+ _utilSparrow.default.sendEvent('click help drawer', {
66
+ name: name,
67
+ category: 'help drawer',
68
+ location: document.location.href,
69
+ open: isActive
70
+ });
71
+ }
72
+ }
73
+ }, {
56
74
  key: "handleClick",
57
75
  value: function handleClick(e) {
58
76
  e.preventDefault();
@@ -61,13 +79,13 @@ var CardToolbarDrawerTrigger = /*#__PURE__*/function (_React$Component) {
61
79
  }, {
62
80
  key: "render",
63
81
  value: function render() {
64
- var _this$props = this.props,
65
- id = _this$props.id,
66
- children = _this$props.children,
67
- isActive = _this$props.isActive,
68
- ariaControls = _this$props.ariaControls,
69
- ariaExpanded = _this$props.ariaExpanded,
70
- ariaLabel = _this$props.ariaLabel;
82
+ var _this$props2 = this.props,
83
+ id = _this$props2.id,
84
+ children = _this$props2.children,
85
+ isActive = _this$props2.isActive,
86
+ ariaControls = _this$props2.ariaControls,
87
+ ariaExpanded = _this$props2.ariaExpanded,
88
+ ariaLabel = _this$props2.ariaLabel;
71
89
  return /*#__PURE__*/_react.default.createElement(_componentButton.TextButton, {
72
90
  id: id,
73
91
  onClick: this.handleClick,
@@ -95,7 +113,8 @@ CardToolbarDrawerTrigger.propTypes = {
95
113
  children: _propTypes.default.node,
96
114
  ariaControls: _propTypes.default.string.isRequired,
97
115
  ariaExpanded: _propTypes.default.bool.isRequired,
98
- ariaLabel: _propTypes.default.string
116
+ ariaLabel: _propTypes.default.string,
117
+ name: _propTypes.default.string.isRequired
99
118
  };
100
119
  CardToolbarDrawerTrigger.defaultProps = {
101
120
  isActive: false
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudflare/component-card",
3
3
  "description": "Cloudflare Card Component",
4
- "version": "10.0.17",
4
+ "version": "10.1.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
7
7
  "author": "James Kyle <jkyle@cloudflare.com>",
@@ -12,9 +12,9 @@
12
12
  "module": "es/index.js"
13
13
  },
14
14
  "dependencies": {
15
- "@cloudflare/component-arrow-swivel": "^8.0.16",
16
- "@cloudflare/component-button": "^8.3.11",
17
- "@cloudflare/component-link": "^8.0.22",
15
+ "@cloudflare/component-arrow-swivel": "^8.0.17",
16
+ "@cloudflare/component-button": "^8.3.12",
17
+ "@cloudflare/component-link": "^8.0.23",
18
18
  "prop-types": "^15.6.0"
19
19
  },
20
20
  "peerDependencies": {
@@ -43,7 +43,6 @@ class CardDrawers extends React.Component {
43
43
 
44
44
  handleLinkClick(id) {
45
45
  this.props.onClick && this.props.onClick(id);
46
-
47
46
  this.setState(
48
47
  ({ active }) => ({ active: active === id ? null : id }),
49
48
  () => this.runToggleFunctions(id, this.state.active === id)
@@ -74,7 +73,6 @@ class CardDrawers extends React.Component {
74
73
  const triggerId = `trigger-${this._cardId}-${drawerIdProps}`;
75
74
  const drawerId = `drawer-${this._cardId}-${drawerIdProps}`;
76
75
  const isActive = drawerId === active;
77
-
78
76
  onClick && this.addToggleFunction(drawerId, onClick);
79
77
  if (!content && !href) {
80
78
  console.error(
@@ -89,6 +87,7 @@ class CardDrawers extends React.Component {
89
87
  content ? (
90
88
  <CardToolbarDrawerTrigger
91
89
  key={triggerId}
90
+ name={name}
92
91
  id={triggerId}
93
92
  isActive={isActive}
94
93
  onClick={() => this.handleLinkClick(drawerId)}
@@ -104,7 +103,6 @@ class CardDrawers extends React.Component {
104
103
  </CardToolbarLink>
105
104
  )
106
105
  );
107
-
108
106
  content &&
109
107
  drawers.push(
110
108
  <Drawer
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { TextButton } from '@cloudflare/component-button';
4
4
  import { ArrowSwivel } from '@cloudflare/component-arrow-swivel';
5
+ import sparrow from '@cloudflare/util-sparrow';
5
6
 
6
7
  class CardToolbarDrawerTrigger extends React.Component {
7
8
  constructor(props) {
@@ -9,6 +10,18 @@ class CardToolbarDrawerTrigger extends React.Component {
9
10
  this.handleClick = this.handleClick.bind(this);
10
11
  }
11
12
 
13
+ componentDidUpdate() {
14
+ const { isActive, name } = this.props;
15
+ if (isActive) {
16
+ sparrow.sendEvent('click help drawer', {
17
+ name,
18
+ category: 'help drawer',
19
+ location: document.location.href,
20
+ open: isActive
21
+ });
22
+ }
23
+ }
24
+
12
25
  handleClick(e) {
13
26
  e.preventDefault();
14
27
  this.props.onClick();
@@ -50,7 +63,8 @@ CardToolbarDrawerTrigger.propTypes = {
50
63
  children: PropTypes.node,
51
64
  ariaControls: PropTypes.string.isRequired,
52
65
  ariaExpanded: PropTypes.bool.isRequired,
53
- ariaLabel: PropTypes.string
66
+ ariaLabel: PropTypes.string,
67
+ name: PropTypes.string.isRequired
54
68
  };
55
69
 
56
70
  CardToolbarDrawerTrigger.defaultProps = {