@carbonplan/components 10.1.1 → 10.4.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/dst/index.esm.js CHANGED
@@ -73,6 +73,12 @@ var event = function event(_ref) {
73
73
  category = _ref.category,
74
74
  label = _ref.label,
75
75
  value = _ref.value;
76
+
77
+ if (typeof window.gtag !== 'function') {
78
+ console.warn("Missing window.gtag, skipping analytics action: '" + action + "'.");
79
+ return;
80
+ }
81
+
76
82
  window.gtag('event', action, {
77
83
  event_category: category,
78
84
  event_label: label,
@@ -813,25 +819,25 @@ var Menu = function Menu(_ref) {
813
819
  };
814
820
 
815
821
  var Settings = function Settings(_ref) {
816
- var _extends2;
817
-
818
822
  var value = _ref.value,
819
823
  sx = _ref.sx,
820
824
  props = _objectWithoutPropertiesLoose(_ref, ["value", "sx"]);
821
825
 
822
826
  return /*#__PURE__*/React.createElement(IconButton, _extends({
823
- sx: _extends((_extends2 = {
827
+ sx: _extends({
824
828
  cursor: 'pointer',
825
829
  fill: 'none',
826
830
  strokeWidth: '2px',
827
- stroke: 'text'
828
- }, _extends2["fill"] = 'background', _extends2['.paren'] = {
829
- opacity: '0'
830
- }, _extends2['@media (hover: hover) and (pointer: fine)'] = {
831
- '&:hover .paren': {
832
- opacity: '1'
831
+ stroke: 'text',
832
+ '.paren': {
833
+ opacity: '0'
834
+ },
835
+ '@media (hover: hover) and (pointer: fine)': {
836
+ '&:hover .paren': {
837
+ opacity: '1'
838
+ }
833
839
  }
834
- }, _extends2), sx),
840
+ }, sx),
835
841
  "aria-label": "Toggle Menu"
836
842
  }, props), !value && /*#__PURE__*/React.createElement("svg", {
837
843
  style: {
@@ -846,22 +852,22 @@ var Settings = function Settings(_ref) {
846
852
  x1: "24",
847
853
  y1: "2.1",
848
854
  x2: "24",
855
+ y2: "6.1"
856
+ }), /*#__PURE__*/React.createElement("line", {
857
+ x1: "24",
858
+ y1: "24.1",
859
+ x2: "24",
849
860
  y2: "33.9"
850
861
  }), /*#__PURE__*/React.createElement("line", {
851
862
  x1: "44",
852
863
  y1: "2.1",
853
864
  x2: "44",
865
+ y2: "12.1"
866
+ }), /*#__PURE__*/React.createElement("line", {
867
+ x1: "44",
868
+ y1: "30.1",
869
+ x2: "44",
854
870
  y2: "33.9"
855
- }), /*#__PURE__*/React.createElement("circle", {
856
- cx: "24",
857
- cy: "15.1",
858
- r: "9",
859
- stroke: "none"
860
- }), /*#__PURE__*/React.createElement("circle", {
861
- cx: "44",
862
- cy: "21.1",
863
- r: "9",
864
- stroke: "none"
865
871
  }), /*#__PURE__*/React.createElement("circle", {
866
872
  cx: "24",
867
873
  cy: "15.1",
@@ -1376,6 +1382,77 @@ var Footer = function Footer() {
1376
1382
  }))));
1377
1383
  };
1378
1384
 
1385
+ var GitSha = function GitSha() {
1386
+ var sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA;
1387
+ var owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER;
1388
+ var slug = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG;
1389
+
1390
+ var _useThemeUI = useThemeUI(),
1391
+ theme = _useThemeUI.theme;
1392
+
1393
+ var color = theme.rawColors.secondary;
1394
+
1395
+ if (sha && owner && slug) {
1396
+ var shortSha = sha.substring(0, 7);
1397
+ var href = 'https://github.com/' + owner + '/' + slug + '/tree/' + sha;
1398
+ return /*#__PURE__*/React.createElement(Box, {
1399
+ sx: {
1400
+ display: 'inline-block'
1401
+ }
1402
+ }, /*#__PURE__*/React.createElement(Separator, {
1403
+ color: color
1404
+ }), /*#__PURE__*/React.createElement(Link$1, {
1405
+ href: href,
1406
+ sx: {
1407
+ whiteSpace: 'nowrap',
1408
+ display: 'inline-block',
1409
+ ml: [2],
1410
+ fontFamily: 'mono',
1411
+ letterSpacing: 'body',
1412
+ color: color,
1413
+ fontSize: [1],
1414
+ textTransform: 'uppercase',
1415
+ textDecoration: 'none'
1416
+ }
1417
+ }, shortSha));
1418
+ } else {
1419
+ // fallback
1420
+ return /*#__PURE__*/React.createElement(Box, {
1421
+ sx: {
1422
+ display: 'inline-block'
1423
+ }
1424
+ }, /*#__PURE__*/React.createElement(Separator, {
1425
+ color: color
1426
+ }), /*#__PURE__*/React.createElement(Text, {
1427
+ sx: {
1428
+ whiteSpace: 'nowrap',
1429
+ display: 'inline-block',
1430
+ ml: [2],
1431
+ fontFamily: 'mono',
1432
+ letterSpacing: 'body',
1433
+ color: color,
1434
+ fontSize: [1],
1435
+ textTransform: 'uppercase'
1436
+ }
1437
+ }, color));
1438
+ }
1439
+ };
1440
+
1441
+ var Separator = function Separator(_ref) {
1442
+ var color = _ref.color;
1443
+ return /*#__PURE__*/React.createElement("svg", {
1444
+ fill: color,
1445
+ opacity: "0.8",
1446
+ viewBox: "0 0 24 24",
1447
+ width: "24",
1448
+ height: "24"
1449
+ }, /*#__PURE__*/React.createElement("circle", {
1450
+ r: 5,
1451
+ cx: 19,
1452
+ cy: 19
1453
+ }));
1454
+ };
1455
+
1379
1456
  var Value = function Value(_ref) {
1380
1457
  var mode = _ref.mode;
1381
1458
 
@@ -1425,11 +1502,6 @@ var Value = function Value(_ref) {
1425
1502
 
1426
1503
  var Metadata = function Metadata(_ref2) {
1427
1504
  var mode = _ref2.mode;
1428
-
1429
- var _useThemeUI = useThemeUI(),
1430
- theme = _useThemeUI.theme;
1431
-
1432
- var color = theme.rawColors.secondary;
1433
1505
  return /*#__PURE__*/React.createElement(Box, {
1434
1506
  sx: {
1435
1507
  userSelect: 'none',
@@ -1442,28 +1514,7 @@ var Metadata = function Metadata(_ref2) {
1442
1514
  }
1443
1515
  }, /*#__PURE__*/React.createElement(Value, {
1444
1516
  mode: mode
1445
- }), /*#__PURE__*/React.createElement("svg", {
1446
- fill: color,
1447
- opacity: "0.8",
1448
- viewBox: "0 0 24 24",
1449
- width: "24",
1450
- height: "24"
1451
- }, /*#__PURE__*/React.createElement("circle", {
1452
- r: 5,
1453
- cx: 19,
1454
- cy: 19
1455
- })), /*#__PURE__*/React.createElement(Text, {
1456
- sx: {
1457
- whiteSpace: 'nowrap',
1458
- display: 'inline-block',
1459
- ml: [2],
1460
- fontFamily: 'mono',
1461
- letterSpacing: 'body',
1462
- color: 'secondary',
1463
- fontSize: [1],
1464
- textTransform: 'uppercase'
1465
- }
1466
- }, color));
1517
+ }), /*#__PURE__*/React.createElement(GitSha, null));
1467
1518
  };
1468
1519
 
1469
1520
  function init(mode) {
@@ -2423,7 +2474,7 @@ var Tray = function Tray(_ref) {
2423
2474
  ml: [-3, -4, -5, -6],
2424
2475
  pl: [3, 4, 5, 6],
2425
2476
  pr: [3, 4, 5, 6],
2426
- transform: expanded ? 'translateY(0)' : 'translateY(-400px)'
2477
+ transform: expanded ? 'translateY(0)' : 'translateY(-100%)'
2427
2478
  }, sx)
2428
2479
  }, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Column, {
2429
2480
  start: [1, 1, 1, 1],
@@ -2431,15 +2482,40 @@ var Tray = function Tray(_ref) {
2431
2482
  }, children))));
2432
2483
  };
2433
2484
 
2434
- var formatDate = function formatDate(date) {
2485
+ var defaultOptions = {
2486
+ month: 'short',
2487
+ day: 'numeric',
2488
+ year: 'numeric'
2489
+ };
2490
+
2491
+ var formatDateElement = function formatDateElement(date, element, option) {
2492
+ var _date$toLocaleString;
2493
+
2494
+ if (!option) {
2495
+ return null;
2496
+ }
2497
+
2498
+ var format = typeof option === 'string' ? option : defaultOptions[element];
2499
+ var result = date.toLocaleString('default', (_date$toLocaleString = {}, _date$toLocaleString[element] = format, _date$toLocaleString));
2500
+
2501
+ if (format === 'numeric' && element === 'day') {
2502
+ return result.padStart(2, '0');
2503
+ } else {
2504
+ return result;
2505
+ }
2506
+ };
2507
+
2508
+ var formatDate = function formatDate(date, options) {
2509
+ if (options === void 0) {
2510
+ options = defaultOptions;
2511
+ }
2512
+
2435
2513
  var d = new Date(date.replace(/-/g, '/'));
2436
- var month = d.toLocaleString('default', {
2437
- month: 'short'
2438
- });
2439
- var day = String(d.getDate()).padStart(2, '0');
2440
- var year = d.getFullYear();
2441
- return month + ' ' + day + ' ' + year;
2514
+ var month = formatDateElement(d, 'month', options.month);
2515
+ var day = formatDateElement(d, 'day', options.day);
2516
+ var year = formatDateElement(d, 'year', options.year);
2517
+ return [month, day, year].filter(Boolean).join(' ');
2442
2518
  };
2443
2519
 
2444
- 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 };
2520
+ 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 };
2445
2521
  //# sourceMappingURL=index.esm.js.map