@carbonplan/components 10.4.0 → 11.0.1

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.
@@ -1,9 +1,10 @@
1
- import React, { cloneElement, useCallback, useState, useEffect, useRef } from 'react';
2
- import { Box, Link as Link$1, Grid, IconButton, useColorMode, Container, useThemeUI, Text, Flex, Styled, Input as Input$1, Slider as Slider$1 } from 'theme-ui';
1
+ import React, { forwardRef, cloneElement, useRef, useState, useEffect, useCallback } from 'react';
2
+ import { Box, Link as Link$2, Flex, Grid, IconButton, Container, useColorMode, useThemeUI, Text, Styled, Input as Input$1, Slider as Slider$1 } from 'theme-ui';
3
3
  import { transparentize } from '@theme-ui/color';
4
4
  import NextLink from 'next/link';
5
5
  import { Arrow, Sun } from '@carbonplan/icons';
6
6
  import { PoopSad } from '@carbonplan/emoji';
7
+ import { useBreakpointIndex } from '@theme-ui/match-media';
7
8
  import Head from 'next/head';
8
9
  import { keyframes } from '@emotion/react';
9
10
 
@@ -88,7 +89,7 @@ const event = ({
88
89
  });
89
90
  };
90
91
 
91
- const Link = (_ref) => {
92
+ const Link = (_ref, ref) => {
92
93
  let {
93
94
  href,
94
95
  children,
@@ -101,7 +102,9 @@ const Link = (_ref) => {
101
102
  return /*#__PURE__*/React.createElement(NextLink, {
102
103
  href: href,
103
104
  passHref: true
104
- }, /*#__PURE__*/React.createElement(Link$1, props, children));
105
+ }, /*#__PURE__*/React.createElement(Link$2, _extends({
106
+ ref: ref
107
+ }, props), children));
105
108
  } else if (tracking) {
106
109
  let action;
107
110
  let category;
@@ -122,18 +125,22 @@ const Link = (_ref) => {
122
125
  });
123
126
  };
124
127
 
125
- return /*#__PURE__*/React.createElement(Link$1, _extends({
128
+ return /*#__PURE__*/React.createElement(Link$2, _extends({
129
+ ref: ref,
126
130
  onClick: track,
127
131
  onContextMenu: track,
128
132
  href: href
129
133
  }, props), children);
130
134
  } else {
131
- return /*#__PURE__*/React.createElement(Link$1, _extends({
135
+ return /*#__PURE__*/React.createElement(Link$2, _extends({
136
+ ref: ref,
132
137
  href: href
133
138
  }, props), children);
134
139
  }
135
140
  };
136
141
 
142
+ var Link$1 = forwardRef(Link);
143
+
137
144
  const getSizeStyles = size => {
138
145
  if (!['xs', 'sm', 'md', 'lg', 'xl'].includes(size)) {
139
146
  throw new Error('Size must be xs, sm, md, lg, or xl');
@@ -184,7 +191,7 @@ const getSizeStyles = size => {
184
191
  };
185
192
  };
186
193
 
187
- const Button = (_ref) => {
194
+ const Button = (_ref, ref) => {
188
195
  let {
189
196
  size = 'sm',
190
197
  prefix,
@@ -355,7 +362,8 @@ const Button = (_ref) => {
355
362
  }, suffix && suffix));
356
363
 
357
364
  if (href) {
358
- return /*#__PURE__*/React.createElement(Link, _extends({
365
+ return /*#__PURE__*/React.createElement(Link$1, _extends({
366
+ ref: ref,
359
367
  href: href,
360
368
  internal: internal,
361
369
  tracking: tracking,
@@ -365,13 +373,16 @@ const Button = (_ref) => {
365
373
  }, props), Inner);
366
374
  } else {
367
375
  return /*#__PURE__*/React.createElement(Box, _extends({
376
+ ref: ref,
368
377
  as: "button",
369
378
  sx: style
370
379
  }, props), Inner);
371
380
  }
372
381
  };
373
382
 
374
- const Callout = (_ref) => {
383
+ var button = forwardRef(Button);
384
+
385
+ const Callout = (_ref, ref) => {
375
386
  let {
376
387
  label,
377
388
  children,
@@ -447,7 +458,8 @@ const Callout = (_ref) => {
447
458
  })));
448
459
 
449
460
  if (href) {
450
- return /*#__PURE__*/React.createElement(Link, _extends({
461
+ return /*#__PURE__*/React.createElement(Link$1, _extends({
462
+ ref: ref,
451
463
  href: href,
452
464
  internal: internal,
453
465
  tracking: tracking,
@@ -455,12 +467,305 @@ const Callout = (_ref) => {
455
467
  }, props), Inner);
456
468
  } else {
457
469
  return /*#__PURE__*/React.createElement(Box, _extends({
470
+ ref: ref,
458
471
  as: "button",
459
472
  sx: style
460
473
  }, props), Inner);
461
474
  }
462
475
  };
463
476
 
477
+ var callout = forwardRef(Callout);
478
+
479
+ const styles = {
480
+ clim: setClim => {
481
+ return {
482
+ fontFamily: 'mono',
483
+ fontSize: ['9px', 0, 0, 1],
484
+ letterSpacing: 'smallcaps',
485
+ textTransform: 'uppercase',
486
+ '@media (hover: hover) and (pointer: fine)': {
487
+ '&:hover': {
488
+ borderBottom: setClim ? ({
489
+ colors
490
+ }) => `solid 1px ${colors.primary} !important` : 'unset'
491
+ }
492
+ },
493
+ '&:focus': {
494
+ outline: 'none',
495
+ borderBottom: setClim ? ({
496
+ colors
497
+ }) => `solid 1px ${colors.primary} !important` : 'unset'
498
+ },
499
+ transition: 'border 0.15s',
500
+ userSelect: setClim ? 'none !important' : 'unset',
501
+ width: 'fit-content',
502
+ minWidth: 'fit-content'
503
+ };
504
+ }
505
+ };
506
+ const DIMENSIONS = {
507
+ width: ['10px', '16px', '16px', '17px'],
508
+ height: ['80px', '110px', '110px', '130px']
509
+ };
510
+
511
+ const Gradient = ({
512
+ colormap,
513
+ discrete,
514
+ horizontal,
515
+ width,
516
+ height
517
+ }) => {
518
+ const step = 1 / colormap.length * 100;
519
+ const values = colormap.map((d, i) => {
520
+ return `rgb(${d}) ${i * step}% ${discrete && i < colormap.length - 1 ? `${(i + 1) * step}%` : ''}`;
521
+ });
522
+ const css = `linear-gradient(to ${horizontal ? 'right' : 'top'}, ${values.join(',')})`;
523
+ return /*#__PURE__*/React.createElement(Box, {
524
+ sx: _extends({}, horizontal ? {
525
+ width: width || DIMENSIONS.height,
526
+ height: height || DIMENSIONS.width
527
+ } : {
528
+ width: width || DIMENSIONS.width,
529
+ minHeight: height || DIMENSIONS.height
530
+ }, {
531
+ mt: horizontal ? ['1px', '1px', '1px', 0] : 0,
532
+ border: ({
533
+ colors
534
+ }) => `solid 1px ${colors.hinted}`,
535
+ background: css
536
+ })
537
+ });
538
+ };
539
+
540
+ const Label = ({
541
+ label,
542
+ units,
543
+ horizontal
544
+ }) => /*#__PURE__*/React.createElement(Box, {
545
+ sx: !horizontal && {
546
+ width: ['12px', '17px', '17px', '19px'],
547
+ alignSelf: 'flex-end'
548
+ }
549
+ }, /*#__PURE__*/React.createElement(Box, {
550
+ sx: _extends({
551
+ mb: horizontal ? 0 : ['-4px', '-4px', '-4px', '-3px'],
552
+ fontFamily: 'mono',
553
+ fontSize: ['9px', 0, 0, 1],
554
+ letterSpacing: 'smallcaps',
555
+ textTransform: 'uppercase'
556
+ }, horizontal ? {} : {
557
+ writingMode: 'vertical-rl',
558
+ transform: 'rotate(180deg)',
559
+ whiteSpace: 'nowrap',
560
+ display: 'inline-block',
561
+ overflow: 'visible'
562
+ })
563
+ }, label, ' ', /*#__PURE__*/React.createElement(Box, {
564
+ as: "span",
565
+ sx: {
566
+ textTransform: 'none',
567
+ color: 'secondary',
568
+ display: 'inline-block'
569
+ }
570
+ }, units)));
571
+
572
+ const Colorbar = (_ref) => {
573
+ let {
574
+ colormap,
575
+ label,
576
+ clim,
577
+ setClim,
578
+ setClimStep = 1,
579
+ discrete,
580
+ units,
581
+ width,
582
+ height,
583
+ format = d => d,
584
+ horizontal = false,
585
+ bottom = false,
586
+ sx,
587
+ sxClim
588
+ } = _ref,
589
+ props = _objectWithoutPropertiesLoose(_ref, ["colormap", "label", "clim", "setClim", "setClimStep", "discrete", "units", "width", "height", "format", "horizontal", "bottom", "sx", "sxClim"]);
590
+
591
+ if (!Array.isArray(colormap)) {
592
+ throw new Error(`expected array for colormap, got '${colormap}'.`);
593
+ }
594
+
595
+ const climRef = [useRef(), useRef()];
596
+ const [climMinDragging, setClimMinDragging] = useState(false);
597
+ const [climMaxDragging, setClimMaxDragging] = useState(false);
598
+ let x,
599
+ y,
600
+ dx,
601
+ dy = 0;
602
+ let id = null;
603
+ let init = [0, 0];
604
+ let scale = setClimStep;
605
+
606
+ const draggingFunction = e => {
607
+ if (id === 'min' && !climMinDragging) setClimMinDragging(true);
608
+ if (id === 'max' && !climMaxDragging) setClimMaxDragging(true);
609
+ dx = e.pageX - x;
610
+ dy = e.pageY - y;
611
+
612
+ if (horizontal) {
613
+ if (id === 'min') setClim(prev => [Math.min(init[0] + dx * scale, init[1]), prev[1]]);
614
+ if (id === 'max') setClim(prev => [prev[0], Math.max(init[1] + dx * scale, init[0])]);
615
+ } else {
616
+ if (id === 'min') setClim(prev => [Math.min(init[0] - dy * scale, init[1]), prev[1]]);
617
+ if (id === 'max') setClim(prev => [prev[0], Math.max(init[1] - dy * scale, init[0])]);
618
+ }
619
+ };
620
+
621
+ const handleMouseDown = e => {
622
+ y = e.pageY;
623
+ x = e.pageX;
624
+ id = e.target.id;
625
+ init = clim;
626
+ document.body.setAttribute('style', horizontal ? 'cursor: ew-resize !important' : 'cursor: ns-resize !important');
627
+ document.addEventListener('mousemove', draggingFunction);
628
+
629
+ const updater = () => {
630
+ document.body.setAttribute('style', 'cursor: unset');
631
+ document.removeEventListener('mousemove', draggingFunction);
632
+ window.removeEventListener('mouseup', updater);
633
+ if (id === 'min') setClimMinDragging(false);
634
+ if (id === 'max') setClimMaxDragging(false);
635
+ };
636
+
637
+ window.addEventListener('mouseup', updater);
638
+ };
639
+
640
+ const increment = e => {
641
+ if (climRef[0].current === document.activeElement) {
642
+ e.preventDefault();
643
+ setClim(prev => [Math.min(prev[0] + scale, prev[1]), prev[1]]);
644
+ climRef[0].current.focus();
645
+ }
646
+
647
+ if (climRef[1].current === document.activeElement) {
648
+ e.preventDefault();
649
+ setClim(prev => [prev[0], Math.max(prev[1] + scale, prev[0])]);
650
+ climRef[1].current.focus();
651
+ }
652
+ };
653
+
654
+ const decrement = e => {
655
+ if (climRef[0].current === document.activeElement) {
656
+ e.preventDefault();
657
+ setClim(prev => [Math.min(prev[0] - scale, prev[1]), prev[1]]);
658
+ climRef[0].current.focus();
659
+ }
660
+
661
+ if (climRef[1].current === document.activeElement) {
662
+ e.preventDefault();
663
+ setClim(prev => [prev[0], Math.max(prev[1] - scale, prev[0])]);
664
+ climRef[1].current.focus();
665
+ }
666
+ };
667
+
668
+ useEffect(() => {
669
+ const listener = e => {
670
+ if (['ArrowUp', 'ArrowRight'].includes(e.code) || ['ArrowUp', 'ArrowRight'].includes(e.key)) {
671
+ increment(e);
672
+ }
673
+
674
+ if (['ArrowDown', 'ArrowLeft'].includes(e.code) || ['ArrowDown', 'ArrowLeft'].includes(e.key)) {
675
+ decrement(e);
676
+ }
677
+ };
678
+
679
+ window.addEventListener('keydown', listener);
680
+ return () => {
681
+ window.removeEventListener('keydown', listener);
682
+ };
683
+ }, [clim]);
684
+
685
+ const ClimMin = () => {
686
+ return /*#__PURE__*/React.createElement(Box, {
687
+ id: "min",
688
+ ref: climRef[0],
689
+ tabIndex: 0,
690
+ sx: _extends({}, styles.clim(setClim), {
691
+ ml: label ? horizontal ? bottom ? '0px' : '10px' : ['2px', '1px', '1px', '2px'] : 0,
692
+ mr: horizontal ? ['2px', '1px', '1px', '2px'] : 0,
693
+ mb: horizontal ? 0 : ['-2px', '-2px', '-2px', '-3px'],
694
+ borderBottom: setClim ? climMinDragging ? ({
695
+ colors
696
+ }) => `solid 1px ${colors.primary}` : ({
697
+ colors
698
+ }) => `solid 1px ${colors.secondary}` : 'unset',
699
+ cursor: setClim ? horizontal ? 'ew-resize' : 'ns-resize' : 'default'
700
+ }, sxClim),
701
+ onMouseDown: setClim ? handleMouseDown : () => {},
702
+ onClick: () => climRef[0].current.focus()
703
+ }, format(clim[0]));
704
+ };
705
+
706
+ const ClimMax = () => {
707
+ return /*#__PURE__*/React.createElement(Box, {
708
+ id: "max",
709
+ ref: climRef[1],
710
+ tabIndex: 0,
711
+ sx: _extends({}, styles.clim(setClim), {
712
+ ml: horizontal ? ['2px', '1px', '1px', '2px'] : ['2px', '1px', '1px', '2px'],
713
+ mt: horizontal ? 0 : ['-2px', '-3px', '-3px', '-3px'],
714
+ borderBottom: setClim ? climMaxDragging ? ({
715
+ colors
716
+ }) => `solid 1px ${colors.primary}` : ({
717
+ colors
718
+ }) => `solid 1px ${colors.secondary}` : 'unset',
719
+ cursor: setClim ? horizontal ? 'ew-resize' : 'ns-resize' : 'default'
720
+ }, sxClim),
721
+ onMouseDown: setClim ? handleMouseDown : () => {},
722
+ onClick: () => climRef[1].current.focus()
723
+ }, format(clim[1]));
724
+ };
725
+
726
+ return /*#__PURE__*/React.createElement(Flex, _extends({}, props, {
727
+ sx: _extends({
728
+ flexDirection: 'row',
729
+ alignItems: 'start',
730
+ justifyContent: 'flex-start',
731
+ gap: ['3px', '6px', '6px', '7px'],
732
+ height: !horizontal ? '100%' : 'unset'
733
+ }, sx)
734
+ }), label && /*#__PURE__*/React.createElement(Label, {
735
+ label: label,
736
+ units: units,
737
+ horizontal: horizontal
738
+ }), /*#__PURE__*/React.createElement(Flex, {
739
+ sx: {
740
+ flexGrow: horizontal ? 1 : 'unset',
741
+ flexDirection: 'column',
742
+ ml: bottom && label ? '4px' : '0px',
743
+ height: !horizontal ? '100%' : 'unset'
744
+ }
745
+ }, /*#__PURE__*/React.createElement(Flex, {
746
+ sx: {
747
+ gap: ['3px', '6px', '6px', '7px'],
748
+ height: !horizontal ? '100%' : 'unset'
749
+ }
750
+ }, horizontal && clim && !bottom && /*#__PURE__*/React.createElement(ClimMin, null), /*#__PURE__*/React.createElement(Gradient, {
751
+ colormap: colormap,
752
+ horizontal: horizontal,
753
+ discrete: discrete,
754
+ width: width,
755
+ height: height
756
+ }), horizontal && clim && !bottom && /*#__PURE__*/React.createElement(ClimMax, null)), horizontal && clim && bottom && /*#__PURE__*/React.createElement(Flex, {
757
+ sx: {
758
+ justifyContent: 'space-between'
759
+ }
760
+ }, /*#__PURE__*/React.createElement(ClimMin, null), /*#__PURE__*/React.createElement(ClimMax, null))), !horizontal && /*#__PURE__*/React.createElement(Flex, {
761
+ sx: {
762
+ flexDirection: 'column-reverse',
763
+ justifyContent: 'space-between',
764
+ height: height || DIMENSIONS.height
765
+ }
766
+ }, clim && /*#__PURE__*/React.createElement(ClimMin, null), clim && /*#__PURE__*/React.createElement(ClimMax, null)));
767
+ };
768
+
464
769
  const Column = (_ref) => {
465
770
  let {
466
771
  start,
@@ -822,146 +1127,6 @@ const Menu = (_ref) => {
822
1127
  })));
823
1128
  };
824
1129
 
825
- const Settings = (_ref) => {
826
- let {
827
- value,
828
- sx
829
- } = _ref,
830
- props = _objectWithoutPropertiesLoose(_ref, ["value", "sx"]);
831
-
832
- return /*#__PURE__*/React.createElement(IconButton, _extends({
833
- sx: _extends({
834
- cursor: 'pointer',
835
- fill: 'none',
836
- strokeWidth: '2px',
837
- stroke: 'text',
838
- '.paren': {
839
- opacity: '0'
840
- },
841
- '@media (hover: hover) and (pointer: fine)': {
842
- '&:hover .paren': {
843
- opacity: '1'
844
- }
845
- }
846
- }, sx),
847
- "aria-label": "Toggle Menu"
848
- }, props), !value && /*#__PURE__*/React.createElement("svg", {
849
- style: {
850
- width: '50px',
851
- height: '30px',
852
- transform: 'scale(2)',
853
- marginTop: '-3px'
854
- },
855
- xmlns: "http://www.w3.org/2000/svg",
856
- viewBox: "0 0 68 36"
857
- }, /*#__PURE__*/React.createElement("line", {
858
- x1: "24",
859
- y1: "2.1",
860
- x2: "24",
861
- y2: "6.1"
862
- }), /*#__PURE__*/React.createElement("line", {
863
- x1: "24",
864
- y1: "24.1",
865
- x2: "24",
866
- y2: "33.9"
867
- }), /*#__PURE__*/React.createElement("line", {
868
- x1: "44",
869
- y1: "2.1",
870
- x2: "44",
871
- y2: "12.1"
872
- }), /*#__PURE__*/React.createElement("line", {
873
- x1: "44",
874
- y1: "30.1",
875
- x2: "44",
876
- y2: "33.9"
877
- }), /*#__PURE__*/React.createElement("circle", {
878
- cx: "24",
879
- cy: "15.1",
880
- r: "5"
881
- }), /*#__PURE__*/React.createElement("circle", {
882
- cx: "44",
883
- cy: "21.1",
884
- r: "5"
885
- }), /*#__PURE__*/React.createElement("path", {
886
- style: {
887
- transition: 'all 0.2s'
888
- },
889
- className: "paren",
890
- d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
891
- }), /*#__PURE__*/React.createElement("path", {
892
- style: {
893
- transition: 'all 0.2s'
894
- },
895
- className: "paren",
896
- d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
897
- })), value && /*#__PURE__*/React.createElement("svg", {
898
- style: {
899
- width: '50px',
900
- height: '30px',
901
- transform: 'scale(2)',
902
- marginTop: '-3px'
903
- },
904
- xmlns: "http://www.w3.org/2000/svg",
905
- viewBox: "0 0 68 36"
906
- }, /*#__PURE__*/React.createElement("line", {
907
- x1: "50.85",
908
- y1: "29.79",
909
- x2: "17.15",
910
- y2: "6.21"
911
- }), /*#__PURE__*/React.createElement("line", {
912
- x1: "17.15",
913
- y1: "29.79",
914
- x2: "50.85",
915
- y2: "6.21"
916
- }), /*#__PURE__*/React.createElement("path", {
917
- style: {
918
- transition: 'all 0.2s'
919
- },
920
- className: "paren",
921
- d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
922
- }), /*#__PURE__*/React.createElement("path", {
923
- style: {
924
- transition: 'all 0.2s'
925
- },
926
- className: "paren",
927
- d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
928
- })));
929
- };
930
-
931
- const Dimmer = (_ref) => {
932
- let {
933
- sx
934
- } = _ref,
935
- props = _objectWithoutPropertiesLoose(_ref, ["sx"]);
936
-
937
- const [colorMode, setColorMode] = useColorMode();
938
- const toggle = useCallback(() => {
939
- setColorMode(colorMode === 'light' ? 'dark' : 'light');
940
- }, [colorMode]);
941
- return /*#__PURE__*/React.createElement(IconButton, _extends({
942
- "aria-label": "Toggle dark mode",
943
- onClick: toggle,
944
- role: "checkbox",
945
- sx: _extends({
946
- width: 32,
947
- height: 32,
948
- display: 'inline-block',
949
- cursor: 'pointer',
950
- color: 'secondary'
951
- }, sx)
952
- }, props), /*#__PURE__*/React.createElement(Sun, {
953
- sx: {
954
- strokeWidth: '1.75',
955
- transition: 'stroke 0.15s',
956
- '@media (hover: hover) and (pointer: fine)': {
957
- '&:hover': {
958
- stroke: 'primary'
959
- }
960
- }
961
- }
962
- }));
963
- };
964
-
965
1130
  const sx = {
966
1131
  link: (current, label, first = false) => {
967
1132
  return {
@@ -1028,7 +1193,6 @@ const Nav = ({
1028
1193
  mode,
1029
1194
  nav,
1030
1195
  first,
1031
- dimmer,
1032
1196
  setExpanded
1033
1197
  }) => {
1034
1198
  const {
@@ -1041,14 +1205,14 @@ const Nav = ({
1041
1205
  return /*#__PURE__*/React.createElement(NextLink, {
1042
1206
  href: href,
1043
1207
  passHref: true
1044
- }, /*#__PURE__*/React.createElement(Link$1, {
1208
+ }, /*#__PURE__*/React.createElement(Link$2, {
1045
1209
  onClick: () => {
1046
1210
  if (nav === url) setExpanded(false);
1047
1211
  },
1048
1212
  sx: sx.link(nav, url, first)
1049
1213
  }, /*#__PURE__*/React.createElement(HoverArrow, null), display));
1050
1214
  } else {
1051
- return /*#__PURE__*/React.createElement(Link$1, {
1215
+ return /*#__PURE__*/React.createElement(Link$2, {
1052
1216
  href: href,
1053
1217
  sx: sx.link(nav, url, first)
1054
1218
  }, /*#__PURE__*/React.createElement(HoverArrow, null), display);
@@ -1077,8 +1241,7 @@ const Header = ({
1077
1241
  status,
1078
1242
  mode,
1079
1243
  nav,
1080
- dimmer,
1081
- settings
1244
+ menuItems
1082
1245
  }) => {
1083
1246
  const [expanded, setExpanded] = useState(false);
1084
1247
 
@@ -1088,7 +1251,6 @@ const Header = ({
1088
1251
 
1089
1252
  return /*#__PURE__*/React.createElement(Row, {
1090
1253
  sx: {
1091
- width: '100%',
1092
1254
  pt: ['12px'],
1093
1255
  pb: [3]
1094
1256
  }
@@ -1103,7 +1265,7 @@ const Header = ({
1103
1265
  }, (mode == 'homepage' || mode == 'local') && /*#__PURE__*/React.createElement(NextLink, {
1104
1266
  href: "/",
1105
1267
  passHref: true
1106
- }, /*#__PURE__*/React.createElement(Link$1, {
1268
+ }, /*#__PURE__*/React.createElement(Link$2, {
1107
1269
  "aria-label": "CarbonPlan Homepage",
1108
1270
  sx: {
1109
1271
  display: 'block'
@@ -1114,7 +1276,7 @@ const Header = ({
1114
1276
  cursor: 'pointer',
1115
1277
  color: 'primary'
1116
1278
  }
1117
- }))), (mode == null || mode == 'remote') && /*#__PURE__*/React.createElement(Link$1, {
1279
+ }))), (mode == null || mode == 'remote') && /*#__PURE__*/React.createElement(Link$2, {
1118
1280
  href: "https://carbonplan.org",
1119
1281
  "aria-label": "CarbonPlan Homepage",
1120
1282
  sx: {
@@ -1140,53 +1302,31 @@ const Header = ({
1140
1302
  top: ['-2px', '-3px', '-3px']
1141
1303
  }
1142
1304
  }, status ? `(${status})` : '')), /*#__PURE__*/React.createElement(Column, {
1143
- start: [status ? 6 : 4, 6, 12, 12],
1305
+ start: [status ? 6 : 4, 6, 11, 11],
1144
1306
  width: [status ? 1 : 3, 3, 2, 2],
1145
1307
  sx: {
1146
- display: 'flex',
1147
- alignItems: 'center',
1148
- justifyContent: 'flex-end'
1149
- }
1150
- }, /*#__PURE__*/React.createElement(Box, {
1151
- sx: {
1152
- mr: ['18px'],
1153
- position: 'relative',
1154
- top: ['-1px'],
1155
- pointerEvents: expanded || settings && settings.value ? 'none' : 'all',
1156
- transition: 'opacity 0.15s',
1157
- display: [status ? 'none' : 'block', 'block', dimmer === 'top' ? 'block' : 'none', dimmer === 'top' ? 'block' : 'none']
1158
- }
1159
- }, /*#__PURE__*/React.createElement(Dimmer, {
1160
- sx: {
1161
- opacity: expanded || settings && settings.value ? 0 : 1,
1162
- color: 'primary'
1308
+ zIndex: 5000
1163
1309
  }
1164
- })), settings && /*#__PURE__*/React.createElement(Box, {
1310
+ }, /*#__PURE__*/React.createElement(Flex, {
1165
1311
  sx: {
1166
- mr: ['21px'],
1167
- position: 'relative',
1168
- pointerEvents: expanded ? 'none' : 'all',
1169
- transition: 'opacity 0.15s',
1170
- display: [status ? 'none' : 'block', 'block', 'none', 'none']
1312
+ justifyContent: 'flex-end'
1171
1313
  }
1172
- }, /*#__PURE__*/React.createElement(Settings, {
1173
- value: settings.value,
1174
- onClick: settings.onClick,
1314
+ }, /*#__PURE__*/React.createElement(Flex, {
1175
1315
  sx: {
1316
+ mr: '18px',
1317
+ gap: '18px',
1176
1318
  opacity: expanded ? 0 : 1,
1177
- stroke: 'primary'
1319
+ transition: 'opacity 0.15s',
1320
+ justifyContent: 'space-between',
1321
+ alignItems: 'center'
1178
1322
  }
1179
- })), /*#__PURE__*/React.createElement(Menu, {
1323
+ }, menuItems), /*#__PURE__*/React.createElement(Menu, {
1180
1324
  sx: {
1181
- transition: 'opacity 0.15s',
1182
- pointerEvents: settings && settings.value ? 'none' : 'all',
1183
- opacity: settings && settings.value ? 0 : 1,
1184
- mr: ['-2px'],
1185
- zIndex: 5000
1325
+ mr: ['-2px']
1186
1326
  },
1187
1327
  value: expanded,
1188
1328
  onClick: toggle
1189
- })), /*#__PURE__*/React.createElement(Box, {
1329
+ }))), /*#__PURE__*/React.createElement(Box, {
1190
1330
  sx: {
1191
1331
  opacity: expanded ? 1 : 0,
1192
1332
  pointerEvents: expanded ? 'all' : 'none',
@@ -1258,7 +1398,7 @@ const Footer = () => {
1258
1398
  letterSpacing: 'mono',
1259
1399
  mb: [2]
1260
1400
  }
1261
- }, "EMAIL"), /*#__PURE__*/React.createElement(Link$1, {
1401
+ }, "EMAIL"), /*#__PURE__*/React.createElement(Link$2, {
1262
1402
  href: "mailto:hello@carbonplan.org",
1263
1403
  sx: {
1264
1404
  textDecoration: 'none',
@@ -1292,7 +1432,7 @@ const Footer = () => {
1292
1432
  letterSpacing: 'mono',
1293
1433
  mb: [2]
1294
1434
  }
1295
- }, "FOLLOW"), /*#__PURE__*/React.createElement(Link$1, {
1435
+ }, "FOLLOW"), /*#__PURE__*/React.createElement(Link$2, {
1296
1436
  href: "https://twitter.com/carbonplanorg",
1297
1437
  sx: {
1298
1438
  textDecoration: 'none',
@@ -1386,6 +1526,40 @@ const Footer = () => {
1386
1526
  }))));
1387
1527
  };
1388
1528
 
1529
+ const Dimmer = (_ref) => {
1530
+ let {
1531
+ sx
1532
+ } = _ref,
1533
+ props = _objectWithoutPropertiesLoose(_ref, ["sx"]);
1534
+
1535
+ const [colorMode, setColorMode] = useColorMode();
1536
+ const toggle = useCallback(() => {
1537
+ setColorMode(colorMode === 'light' ? 'dark' : 'light');
1538
+ }, [colorMode]);
1539
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
1540
+ "aria-label": "Toggle dark mode",
1541
+ onClick: toggle,
1542
+ role: "checkbox",
1543
+ sx: _extends({
1544
+ width: 32,
1545
+ height: 32,
1546
+ display: 'inline-block',
1547
+ cursor: 'pointer',
1548
+ color: 'secondary'
1549
+ }, sx)
1550
+ }, props), /*#__PURE__*/React.createElement(Sun, {
1551
+ sx: {
1552
+ strokeWidth: '1.75',
1553
+ transition: 'stroke 0.15s',
1554
+ '@media (hover: hover) and (pointer: fine)': {
1555
+ '&:hover': {
1556
+ stroke: 'primary'
1557
+ }
1558
+ }
1559
+ }
1560
+ }));
1561
+ };
1562
+
1389
1563
  const GitSha = () => {
1390
1564
  const sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA;
1391
1565
  const owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER;
@@ -1404,7 +1578,7 @@ const GitSha = () => {
1404
1578
  }
1405
1579
  }, /*#__PURE__*/React.createElement(Separator, {
1406
1580
  color: color
1407
- }), /*#__PURE__*/React.createElement(Link$1, {
1581
+ }), /*#__PURE__*/React.createElement(Link$2, {
1408
1582
  href: href,
1409
1583
  sx: {
1410
1584
  whiteSpace: 'nowrap',
@@ -1693,6 +1867,112 @@ function GuideColumns({
1693
1867
  }));
1694
1868
  }
1695
1869
 
1870
+ const Settings = (_ref) => {
1871
+ let {
1872
+ value,
1873
+ sx
1874
+ } = _ref,
1875
+ props = _objectWithoutPropertiesLoose(_ref, ["value", "sx"]);
1876
+
1877
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
1878
+ sx: _extends({
1879
+ cursor: 'pointer',
1880
+ fill: 'none',
1881
+ strokeWidth: '2px',
1882
+ stroke: 'text',
1883
+ '.paren': {
1884
+ opacity: '0'
1885
+ },
1886
+ '@media (hover: hover) and (pointer: fine)': {
1887
+ '&:hover .paren': {
1888
+ opacity: '1'
1889
+ }
1890
+ }
1891
+ }, sx),
1892
+ "aria-label": "Toggle Menu"
1893
+ }, props), !value && /*#__PURE__*/React.createElement("svg", {
1894
+ style: {
1895
+ width: '50px',
1896
+ height: '30px',
1897
+ transform: 'scale(2)',
1898
+ marginTop: '-3px'
1899
+ },
1900
+ xmlns: "http://www.w3.org/2000/svg",
1901
+ viewBox: "0 0 68 36"
1902
+ }, /*#__PURE__*/React.createElement("line", {
1903
+ x1: "24",
1904
+ y1: "2.1",
1905
+ x2: "24",
1906
+ y2: "6.1"
1907
+ }), /*#__PURE__*/React.createElement("line", {
1908
+ x1: "24",
1909
+ y1: "24.1",
1910
+ x2: "24",
1911
+ y2: "33.9"
1912
+ }), /*#__PURE__*/React.createElement("line", {
1913
+ x1: "44",
1914
+ y1: "2.1",
1915
+ x2: "44",
1916
+ y2: "12.1"
1917
+ }), /*#__PURE__*/React.createElement("line", {
1918
+ x1: "44",
1919
+ y1: "30.1",
1920
+ x2: "44",
1921
+ y2: "33.9"
1922
+ }), /*#__PURE__*/React.createElement("circle", {
1923
+ cx: "24",
1924
+ cy: "15.1",
1925
+ r: "5"
1926
+ }), /*#__PURE__*/React.createElement("circle", {
1927
+ cx: "44",
1928
+ cy: "21.1",
1929
+ r: "5"
1930
+ }), /*#__PURE__*/React.createElement("path", {
1931
+ style: {
1932
+ transition: 'all 0.2s'
1933
+ },
1934
+ className: "paren",
1935
+ d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
1936
+ }), /*#__PURE__*/React.createElement("path", {
1937
+ style: {
1938
+ transition: 'all 0.2s'
1939
+ },
1940
+ className: "paren",
1941
+ d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
1942
+ })), value && /*#__PURE__*/React.createElement("svg", {
1943
+ style: {
1944
+ width: '50px',
1945
+ height: '30px',
1946
+ transform: 'scale(2)',
1947
+ marginTop: '-3px'
1948
+ },
1949
+ xmlns: "http://www.w3.org/2000/svg",
1950
+ viewBox: "0 0 68 36"
1951
+ }, /*#__PURE__*/React.createElement("line", {
1952
+ x1: "50.85",
1953
+ y1: "29.79",
1954
+ x2: "17.15",
1955
+ y2: "6.21"
1956
+ }), /*#__PURE__*/React.createElement("line", {
1957
+ x1: "17.15",
1958
+ y1: "29.79",
1959
+ x2: "50.85",
1960
+ y2: "6.21"
1961
+ }), /*#__PURE__*/React.createElement("path", {
1962
+ style: {
1963
+ transition: 'all 0.2s'
1964
+ },
1965
+ className: "paren",
1966
+ d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
1967
+ }), /*#__PURE__*/React.createElement("path", {
1968
+ style: {
1969
+ transition: 'all 0.2s'
1970
+ },
1971
+ className: "paren",
1972
+ d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
1973
+ })));
1974
+ };
1975
+
1696
1976
  const Layout = ({
1697
1977
  title,
1698
1978
  description,
@@ -1712,6 +1992,7 @@ const Layout = ({
1712
1992
  container: _container = true
1713
1993
  }) => {
1714
1994
  let content = children;
1995
+ const index = useBreakpointIndex();
1715
1996
 
1716
1997
  if (_fade) {
1717
1998
  content = /*#__PURE__*/React.createElement(FadeIn, {
@@ -1720,7 +2001,34 @@ const Layout = ({
1720
2001
  }
1721
2002
 
1722
2003
  if (_container) {
1723
- content = /*#__PURE__*/React.createElement(Container, null, content);
2004
+ content = /*#__PURE__*/React.createElement(Box, {
2005
+ sx: {
2006
+ mb: [8, 8, 9, 10]
2007
+ }
2008
+ }, /*#__PURE__*/React.createElement(Container, null, content));
2009
+ }
2010
+
2011
+ useEffect(() => {
2012
+ if (index > 2 && settings != null && settings.value && settings != null && settings.onClick) {
2013
+ settings == null ? void 0 : settings.onClick();
2014
+ }
2015
+ }, [index, settings == null ? void 0 : settings.value, settings == null ? void 0 : settings.onClick]);
2016
+ const menuItems = [/*#__PURE__*/React.createElement(Dimmer, {
2017
+ key: "dimmer",
2018
+ sx: {
2019
+ color: 'primary',
2020
+ mt: '-2px',
2021
+ display: ['block', 'block', _dimmer === 'top' ? 'block' : 'none', _dimmer === 'top' ? 'block' : 'none']
2022
+ }
2023
+ })];
2024
+
2025
+ if (settings) {
2026
+ menuItems.push( /*#__PURE__*/React.createElement(Settings, _extends({
2027
+ key: "settings",
2028
+ sx: {
2029
+ display: ['inherit', 'inherit', 'none', 'none']
2030
+ }
2031
+ }, settings)));
1724
2032
  }
1725
2033
 
1726
2034
  return /*#__PURE__*/React.createElement(React.Fragment, null, _guide && /*#__PURE__*/React.createElement(Guide, {
@@ -1752,8 +2060,7 @@ const Layout = ({
1752
2060
  mode: _links,
1753
2061
  status: status,
1754
2062
  nav: nav,
1755
- settings: settings,
1756
- dimmer: _dimmer
2063
+ menuItems: menuItems
1757
2064
  }))), /*#__PURE__*/React.createElement(Box, {
1758
2065
  sx: {
1759
2066
  width: '100%',
@@ -2063,7 +2370,7 @@ const Group = ({
2063
2370
  }));
2064
2371
  };
2065
2372
 
2066
- const Input = (_ref) => {
2373
+ const Input = (_ref, ref) => {
2067
2374
  let {
2068
2375
  size = 'sm',
2069
2376
  inverted,
@@ -2103,10 +2410,13 @@ const Input = (_ref) => {
2103
2410
  }, getSizeStyles(size), sx);
2104
2411
 
2105
2412
  return /*#__PURE__*/React.createElement(Input$1, _extends({}, props, {
2413
+ ref: ref,
2106
2414
  sx: styles
2107
2415
  }));
2108
2416
  };
2109
2417
 
2418
+ var input = forwardRef(Input);
2419
+
2110
2420
  const getProps = test => props => {
2111
2421
  const next = {};
2112
2422
 
@@ -2121,9 +2431,10 @@ const Select = (_ref) => {
2121
2431
  let {
2122
2432
  children,
2123
2433
  size = 'sm',
2124
- sx
2434
+ sx,
2435
+ sxSelect
2125
2436
  } = _ref,
2126
- props = _objectWithoutPropertiesLoose(_ref, ["children", "size", "sx"]);
2437
+ props = _objectWithoutPropertiesLoose(_ref, ["children", "size", "sx", "sxSelect"]);
2127
2438
 
2128
2439
  const color = sx && sx.color ? sx.color : 'primary';
2129
2440
  const sizeStyles = getSizeStyles(size);
@@ -2195,7 +2506,7 @@ const Select = (_ref) => {
2195
2506
  background: 'transparent !important'
2196
2507
  }
2197
2508
  }
2198
- })
2509
+ }, sxSelect)
2199
2510
  }, omitOnChange), children), /*#__PURE__*/React.createElement(Arrow, {
2200
2511
  sx: {
2201
2512
  width: width,
@@ -2210,7 +2521,7 @@ const Select = (_ref) => {
2210
2521
  }));
2211
2522
  };
2212
2523
 
2213
- const Slider = (_ref) => {
2524
+ const Slider = (_ref, ref) => {
2214
2525
  let {
2215
2526
  sx
2216
2527
  } = _ref,
@@ -2223,6 +2534,7 @@ const Slider = (_ref) => {
2223
2534
  }
2224
2535
  } = useThemeUI();
2225
2536
  return /*#__PURE__*/React.createElement(Slider$1, _extends({
2537
+ ref: ref,
2226
2538
  sx: _extends({
2227
2539
  '&::-webkit-slider-thumb': {
2228
2540
  height: [22, 18, 16],
@@ -2254,7 +2566,9 @@ const Slider = (_ref) => {
2254
2566
  }, props));
2255
2567
  };
2256
2568
 
2257
- const styles = {
2569
+ var slider = forwardRef(Slider);
2570
+
2571
+ const styles$1 = {
2258
2572
  reset: {
2259
2573
  verticalAlign: 'baseline',
2260
2574
  border: 0,
@@ -2323,7 +2637,7 @@ const Table = ({
2323
2637
  }
2324
2638
  }, header && /*#__PURE__*/React.createElement(Row, {
2325
2639
  as: "tr",
2326
- sx: _extends({}, styles.reset, styles.header, styles.row, {
2640
+ sx: _extends({}, styles$1.reset, styles$1.header, styles$1.row, {
2327
2641
  color: color,
2328
2642
  borderTopWidth: !_borderTop ? '0px' : '1px'
2329
2643
  })
@@ -2331,13 +2645,13 @@ const Table = ({
2331
2645
  as: "td",
2332
2646
  start: [1],
2333
2647
  width: columns,
2334
- sx: styles.index
2648
+ sx: styles$1.index
2335
2649
  }, header)), data.map((row, i) => {
2336
2650
  return /*#__PURE__*/React.createElement(Row, {
2337
2651
  as: "tr",
2338
2652
  columns: columns,
2339
2653
  key: i,
2340
- sx: _extends({}, styles.reset, styles.row, {
2654
+ sx: _extends({}, styles$1.reset, styles$1.row, {
2341
2655
  pb: _borderBottom && i === data.length - 1 ? ['18px', '18px', '18px', '22px'] : [3, 3, 3, '20px'],
2342
2656
  borderBottomWidth: _borderBottom && i === data.length - 1 ? '1px' : '0px',
2343
2657
  borderTopWidth: !_borderTop && i === 0 && !header ? '0px' : '1px'
@@ -2348,13 +2662,13 @@ const Table = ({
2348
2662
  key: j,
2349
2663
  start: start[j],
2350
2664
  width: width[j],
2351
- sx: j == 0 && _index ? _extends({}, styles.reset, styles.index) : _extends({}, styles.reset, styles.entry)
2665
+ sx: j == 0 && _index ? _extends({}, styles$1.reset, styles$1.index) : _extends({}, styles$1.reset, styles$1.entry)
2352
2666
  }, column);
2353
2667
  }));
2354
2668
  })));
2355
2669
  };
2356
2670
 
2357
- const Toggle = (_ref) => {
2671
+ const Toggle = (_ref, ref) => {
2358
2672
  let {
2359
2673
  value,
2360
2674
  onClick,
@@ -2366,6 +2680,7 @@ const Toggle = (_ref) => {
2366
2680
  const color = sx && sx.color ? sx.color : 'primary';
2367
2681
  value = disabled ? false : value;
2368
2682
  return /*#__PURE__*/React.createElement(Box, _extends({
2683
+ ref: ref,
2369
2684
  as: "button",
2370
2685
  onClick: onClick,
2371
2686
  role: "checkbox",
@@ -2403,6 +2718,8 @@ const Toggle = (_ref) => {
2403
2718
  })));
2404
2719
  };
2405
2720
 
2721
+ var toggle = forwardRef(Toggle);
2722
+
2406
2723
  const Tracking = ({
2407
2724
  id
2408
2725
  }) => {
@@ -2434,7 +2751,6 @@ const Tray = ({
2434
2751
  }) => {
2435
2752
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
2436
2753
  sx: {
2437
- display: ['initial', 'initial', 'none', 'none'],
2438
2754
  position: 'fixed',
2439
2755
  top: '56px',
2440
2756
  bottom: '0px',
@@ -2449,7 +2765,6 @@ const Tray = ({
2449
2765
  }
2450
2766
  }), /*#__PURE__*/React.createElement(Box, {
2451
2767
  sx: _extends({
2452
- display: ['initial', 'initial', 'none', 'none'],
2453
2768
  position: 'fixed',
2454
2769
  width: 'calc(100vw)',
2455
2770
  top: '0px',
@@ -2505,5 +2820,5 @@ const formatDate = (date, options = defaultOptions) => {
2505
2820
  return [month, day, year].filter(Boolean).join(' ');
2506
2821
  };
2507
2822
 
2508
- 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 };
2823
+ export { Badge, button as Button, callout as Callout, Colorbar, Column, Custom404, Dimmer, Expander, FadeIn, Filter, Footer, Group, Guide, Header, input as Input, Layout, Link$1 as Link, Logo, Menu, Meta, Monogram, Row, Scrollbar, Select, Settings, slider as Slider, Table, Tag, toggle as Toggle, Tracking, Tray, formatDate, getScrollbarWidth };
2509
2824
  //# sourceMappingURL=index.modern.js.map