@carbonplan/components 10.3.0 → 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.
@@ -76,6 +76,11 @@ const event = ({
76
76
  label,
77
77
  value
78
78
  }) => {
79
+ if (typeof window.gtag !== 'function') {
80
+ console.warn(`Missing window.gtag, skipping analytics action: '${action}'.`);
81
+ return;
82
+ }
83
+
79
84
  window.gtag('event', action, {
80
85
  event_category: category,
81
86
  event_label: label,
@@ -1381,6 +1386,77 @@ const Footer = () => {
1381
1386
  }))));
1382
1387
  };
1383
1388
 
1389
+ const GitSha = () => {
1390
+ const sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA;
1391
+ const owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER;
1392
+ const slug = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG;
1393
+ const {
1394
+ theme
1395
+ } = useThemeUI();
1396
+ const color = theme.rawColors.secondary;
1397
+
1398
+ if (sha && owner && slug) {
1399
+ const shortSha = sha.substring(0, 7);
1400
+ const href = 'https://github.com/' + owner + '/' + slug + '/tree/' + sha;
1401
+ return /*#__PURE__*/React.createElement(Box, {
1402
+ sx: {
1403
+ display: 'inline-block'
1404
+ }
1405
+ }, /*#__PURE__*/React.createElement(Separator, {
1406
+ color: color
1407
+ }), /*#__PURE__*/React.createElement(Link$1, {
1408
+ href: href,
1409
+ sx: {
1410
+ whiteSpace: 'nowrap',
1411
+ display: 'inline-block',
1412
+ ml: [2],
1413
+ fontFamily: 'mono',
1414
+ letterSpacing: 'body',
1415
+ color: color,
1416
+ fontSize: [1],
1417
+ textTransform: 'uppercase',
1418
+ textDecoration: 'none'
1419
+ }
1420
+ }, shortSha));
1421
+ } else {
1422
+ // fallback
1423
+ return /*#__PURE__*/React.createElement(Box, {
1424
+ sx: {
1425
+ display: 'inline-block'
1426
+ }
1427
+ }, /*#__PURE__*/React.createElement(Separator, {
1428
+ color: color
1429
+ }), /*#__PURE__*/React.createElement(Text, {
1430
+ sx: {
1431
+ whiteSpace: 'nowrap',
1432
+ display: 'inline-block',
1433
+ ml: [2],
1434
+ fontFamily: 'mono',
1435
+ letterSpacing: 'body',
1436
+ color: color,
1437
+ fontSize: [1],
1438
+ textTransform: 'uppercase'
1439
+ }
1440
+ }, color));
1441
+ }
1442
+ };
1443
+
1444
+ const Separator = ({
1445
+ color
1446
+ }) => {
1447
+ return /*#__PURE__*/React.createElement("svg", {
1448
+ fill: color,
1449
+ opacity: "0.8",
1450
+ viewBox: "0 0 24 24",
1451
+ width: "24",
1452
+ height: "24"
1453
+ }, /*#__PURE__*/React.createElement("circle", {
1454
+ r: 5,
1455
+ cx: 19,
1456
+ cy: 19
1457
+ }));
1458
+ };
1459
+
1384
1460
  const Value = ({
1385
1461
  mode
1386
1462
  }) => {
@@ -1428,10 +1504,6 @@ const Value = ({
1428
1504
  const Metadata = ({
1429
1505
  mode
1430
1506
  }) => {
1431
- const {
1432
- theme
1433
- } = useThemeUI();
1434
- const color = theme.rawColors.secondary;
1435
1507
  return /*#__PURE__*/React.createElement(Box, {
1436
1508
  sx: {
1437
1509
  userSelect: 'none',
@@ -1444,28 +1516,7 @@ const Metadata = ({
1444
1516
  }
1445
1517
  }, /*#__PURE__*/React.createElement(Value, {
1446
1518
  mode: mode
1447
- }), /*#__PURE__*/React.createElement("svg", {
1448
- fill: color,
1449
- opacity: "0.8",
1450
- viewBox: "0 0 24 24",
1451
- width: "24",
1452
- height: "24"
1453
- }, /*#__PURE__*/React.createElement("circle", {
1454
- r: 5,
1455
- cx: 19,
1456
- cy: 19
1457
- })), /*#__PURE__*/React.createElement(Text, {
1458
- sx: {
1459
- whiteSpace: 'nowrap',
1460
- display: 'inline-block',
1461
- ml: [2],
1462
- fontFamily: 'mono',
1463
- letterSpacing: 'body',
1464
- color: 'secondary',
1465
- fontSize: [1],
1466
- textTransform: 'uppercase'
1467
- }
1468
- }, color));
1519
+ }), /*#__PURE__*/React.createElement(GitSha, null));
1469
1520
  };
1470
1521
 
1471
1522
  function init(mode) {