@carbonplan/components 10.1.0 → 10.3.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.
@@ -98,7 +98,10 @@ const Link = (_ref) => {
98
98
  passHref: true
99
99
  }, /*#__PURE__*/React.createElement(Link$1, props, children));
100
100
  } else if (tracking) {
101
- if (href.includes('pdf')) {
101
+ let action;
102
+ let category;
103
+
104
+ if (href && href.includes('pdf')) {
102
105
  action = 'PDF';
103
106
  category = 'download';
104
107
  } else {
@@ -106,7 +109,7 @@ const Link = (_ref) => {
106
109
  category = 'external';
107
110
  }
108
111
 
109
- const onClick = e => {
112
+ const track = e => {
110
113
  event({
111
114
  action: action,
112
115
  category: category,
@@ -115,7 +118,8 @@ const Link = (_ref) => {
115
118
  };
116
119
 
117
120
  return /*#__PURE__*/React.createElement(Link$1, _extends({
118
- onClick: onClick,
121
+ onClick: track,
122
+ onContextMenu: track,
119
123
  href: href
120
124
  }, props), children);
121
125
  } else {
@@ -826,7 +830,6 @@ const Settings = (_ref) => {
826
830
  fill: 'none',
827
831
  strokeWidth: '2px',
828
832
  stroke: 'text',
829
- fill: 'background',
830
833
  '.paren': {
831
834
  opacity: '0'
832
835
  },
@@ -850,22 +853,22 @@ const Settings = (_ref) => {
850
853
  x1: "24",
851
854
  y1: "2.1",
852
855
  x2: "24",
856
+ y2: "6.1"
857
+ }), /*#__PURE__*/React.createElement("line", {
858
+ x1: "24",
859
+ y1: "24.1",
860
+ x2: "24",
853
861
  y2: "33.9"
854
862
  }), /*#__PURE__*/React.createElement("line", {
855
863
  x1: "44",
856
864
  y1: "2.1",
857
865
  x2: "44",
866
+ y2: "12.1"
867
+ }), /*#__PURE__*/React.createElement("line", {
868
+ x1: "44",
869
+ y1: "30.1",
870
+ x2: "44",
858
871
  y2: "33.9"
859
- }), /*#__PURE__*/React.createElement("circle", {
860
- cx: "24",
861
- cy: "15.1",
862
- r: "9",
863
- stroke: "none"
864
- }), /*#__PURE__*/React.createElement("circle", {
865
- cx: "44",
866
- cy: "21.1",
867
- r: "9",
868
- stroke: "none"
869
872
  }), /*#__PURE__*/React.createElement("circle", {
870
873
  cx: "24",
871
874
  cy: "15.1",
@@ -2349,19 +2352,23 @@ const Toggle = (_ref) => {
2349
2352
  })));
2350
2353
  };
2351
2354
 
2352
- const GA_TRACKING_ID = 'UA-165985850-1';
2355
+ const Tracking = ({
2356
+ id
2357
+ }) => {
2358
+ if (!id) {
2359
+ return null;
2360
+ }
2353
2361
 
2354
- const Tracking = () => {
2355
2362
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("script", {
2356
2363
  async: true,
2357
- src: `https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`
2364
+ src: `https://www.googletagmanager.com/gtag/js?id=${id}`
2358
2365
  }), /*#__PURE__*/React.createElement("script", {
2359
2366
  dangerouslySetInnerHTML: {
2360
2367
  __html: `
2361
2368
  window.dataLayer = window.dataLayer || [];
2362
2369
  function gtag(){dataLayer.push(arguments);}
2363
2370
  gtag('js', new Date());
2364
- gtag('config', '${GA_TRACKING_ID}', {
2371
+ gtag('config', '${id}', {
2365
2372
  page_path: window.location.pathname,
2366
2373
  });
2367
2374
  `
@@ -2408,7 +2415,7 @@ const Tray = ({
2408
2415
  ml: [-3, -4, -5, -6],
2409
2416
  pl: [3, 4, 5, 6],
2410
2417
  pr: [3, 4, 5, 6],
2411
- transform: expanded ? 'translateY(0)' : 'translateY(-400px)'
2418
+ transform: expanded ? 'translateY(0)' : 'translateY(-100%)'
2412
2419
  }, sx)
2413
2420
  }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
2414
2421
  start: [1, 1, 1, 1],
@@ -2416,15 +2423,36 @@ const Tray = ({
2416
2423
  }, children))));
2417
2424
  };
2418
2425
 
2419
- const formatDate = date => {
2420
- let d = new Date(date.replace(/-/g, '/'));
2421
- let month = d.toLocaleString('default', {
2422
- month: 'short'
2426
+ const defaultOptions = {
2427
+ month: 'short',
2428
+ day: 'numeric',
2429
+ year: 'numeric'
2430
+ };
2431
+
2432
+ const formatDateElement = (date, element, option) => {
2433
+ if (!option) {
2434
+ return null;
2435
+ }
2436
+
2437
+ const format = typeof option === 'string' ? option : defaultOptions[element];
2438
+ const result = date.toLocaleString('default', {
2439
+ [element]: format
2423
2440
  });
2424
- let day = String(d.getDate()).padStart(2, '0');
2425
- let year = d.getFullYear();
2426
- return month + ' ' + day + ' ' + year;
2441
+
2442
+ if (format === 'numeric' && element === 'day') {
2443
+ return result.padStart(2, '0');
2444
+ } else {
2445
+ return result;
2446
+ }
2447
+ };
2448
+
2449
+ const formatDate = (date, options = defaultOptions) => {
2450
+ const d = new Date(date.replace(/-/g, '/'));
2451
+ const month = formatDateElement(d, 'month', options.month);
2452
+ const day = formatDateElement(d, 'day', options.day);
2453
+ const year = formatDateElement(d, 'year', options.year);
2454
+ return [month, day, year].filter(Boolean).join(' ');
2427
2455
  };
2428
2456
 
2429
- export { Badge, Button, Callout, Column, Custom404, Dimmer, Expander, FadeIn, Filter, Footer, Group, Guide, Header, Input, Layout, Link, Logo, Menu, Meta, Monogram, Row, Scrollbar, Select, Slider, Table, Tag, Toggle, Tracking, Tray, formatDate, getScrollbarWidth };
2457
+ export { Badge, Button, Callout, Column, Custom404, Dimmer, Expander, FadeIn, Filter, Footer, Group, Guide, Header, Input, Layout, Link, Logo, Menu, Meta, Monogram, Row, Scrollbar, Select, Settings, Slider, Table, Tag, Toggle, Tracking, Tray, formatDate, getScrollbarWidth };
2430
2458
  //# sourceMappingURL=index.modern.js.map