@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.
package/dst/index.esm.js CHANGED
@@ -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
 
@@ -86,7 +87,7 @@ var event = function event(_ref) {
86
87
  });
87
88
  };
88
89
 
89
- var Link = function Link(_ref2) {
90
+ var Link = function Link(_ref2, ref) {
90
91
  var href = _ref2.href,
91
92
  children = _ref2.children,
92
93
  _ref2$internal = _ref2.internal,
@@ -99,7 +100,9 @@ var Link = function Link(_ref2) {
99
100
  return /*#__PURE__*/React.createElement(NextLink, {
100
101
  href: href,
101
102
  passHref: true
102
- }, /*#__PURE__*/React.createElement(Link$1, props, children));
103
+ }, /*#__PURE__*/React.createElement(Link$2, _extends({
104
+ ref: ref
105
+ }, props), children));
103
106
  } else if (tracking) {
104
107
  var action;
105
108
  var category;
@@ -120,18 +123,22 @@ var Link = function Link(_ref2) {
120
123
  });
121
124
  };
122
125
 
123
- return /*#__PURE__*/React.createElement(Link$1, _extends({
126
+ return /*#__PURE__*/React.createElement(Link$2, _extends({
127
+ ref: ref,
124
128
  onClick: track,
125
129
  onContextMenu: track,
126
130
  href: href
127
131
  }, props), children);
128
132
  } else {
129
- return /*#__PURE__*/React.createElement(Link$1, _extends({
133
+ return /*#__PURE__*/React.createElement(Link$2, _extends({
134
+ ref: ref,
130
135
  href: href
131
136
  }, props), children);
132
137
  }
133
138
  };
134
139
 
140
+ var Link$1 = forwardRef(Link);
141
+
135
142
  var getSizeStyles = function getSizeStyles(size) {
136
143
  if (!['xs', 'sm', 'md', 'lg', 'xl'].includes(size)) {
137
144
  throw new Error('Size must be xs, sm, md, lg, or xl');
@@ -182,7 +189,7 @@ var getSizeStyles = function getSizeStyles(size) {
182
189
  };
183
190
  };
184
191
 
185
- var Button = function Button(_ref) {
192
+ var Button = function Button(_ref, ref) {
186
193
  var _ref$size = _ref.size,
187
194
  size = _ref$size === void 0 ? 'sm' : _ref$size,
188
195
  prefix = _ref.prefix,
@@ -352,7 +359,8 @@ var Button = function Button(_ref) {
352
359
  }, suffix && suffix));
353
360
 
354
361
  if (href) {
355
- return /*#__PURE__*/React.createElement(Link, _extends({
362
+ return /*#__PURE__*/React.createElement(Link$1, _extends({
363
+ ref: ref,
356
364
  href: href,
357
365
  internal: internal,
358
366
  tracking: tracking,
@@ -362,13 +370,16 @@ var Button = function Button(_ref) {
362
370
  }, props), Inner);
363
371
  } else {
364
372
  return /*#__PURE__*/React.createElement(Box, _extends({
373
+ ref: ref,
365
374
  as: "button",
366
375
  sx: style
367
376
  }, props), Inner);
368
377
  }
369
378
  };
370
379
 
371
- var Callout = function Callout(_ref) {
380
+ var button = forwardRef(Button);
381
+
382
+ var Callout = function Callout(_ref, ref) {
372
383
  var label = _ref.label,
373
384
  children = _ref.children,
374
385
  inverted = _ref.inverted,
@@ -442,7 +453,8 @@ var Callout = function Callout(_ref) {
442
453
  })));
443
454
 
444
455
  if (href) {
445
- return /*#__PURE__*/React.createElement(Link, _extends({
456
+ return /*#__PURE__*/React.createElement(Link$1, _extends({
457
+ ref: ref,
446
458
  href: href,
447
459
  internal: internal,
448
460
  tracking: tracking,
@@ -450,12 +462,343 @@ var Callout = function Callout(_ref) {
450
462
  }, props), Inner);
451
463
  } else {
452
464
  return /*#__PURE__*/React.createElement(Box, _extends({
465
+ ref: ref,
453
466
  as: "button",
454
467
  sx: style
455
468
  }, props), Inner);
456
469
  }
457
470
  };
458
471
 
472
+ var callout = forwardRef(Callout);
473
+
474
+ var styles = {
475
+ clim: function clim(setClim) {
476
+ return {
477
+ fontFamily: 'mono',
478
+ fontSize: ['9px', 0, 0, 1],
479
+ letterSpacing: 'smallcaps',
480
+ textTransform: 'uppercase',
481
+ '@media (hover: hover) and (pointer: fine)': {
482
+ '&:hover': {
483
+ borderBottom: setClim ? function (_ref) {
484
+ var colors = _ref.colors;
485
+ return "solid 1px " + colors.primary + " !important";
486
+ } : 'unset'
487
+ }
488
+ },
489
+ '&:focus': {
490
+ outline: 'none',
491
+ borderBottom: setClim ? function (_ref2) {
492
+ var colors = _ref2.colors;
493
+ return "solid 1px " + colors.primary + " !important";
494
+ } : 'unset'
495
+ },
496
+ transition: 'border 0.15s',
497
+ userSelect: setClim ? 'none !important' : 'unset',
498
+ width: 'fit-content',
499
+ minWidth: 'fit-content'
500
+ };
501
+ }
502
+ };
503
+ var DIMENSIONS = {
504
+ width: ['10px', '16px', '16px', '17px'],
505
+ height: ['80px', '110px', '110px', '130px']
506
+ };
507
+
508
+ var Gradient = function Gradient(_ref3) {
509
+ var colormap = _ref3.colormap,
510
+ discrete = _ref3.discrete,
511
+ horizontal = _ref3.horizontal,
512
+ width = _ref3.width,
513
+ height = _ref3.height;
514
+ var step = 1 / colormap.length * 100;
515
+ var values = colormap.map(function (d, i) {
516
+ return "rgb(" + d + ") " + i * step + "% " + (discrete && i < colormap.length - 1 ? (i + 1) * step + "%" : '');
517
+ });
518
+ var css = "linear-gradient(to " + (horizontal ? 'right' : 'top') + ", " + values.join(',') + ")";
519
+ return /*#__PURE__*/React.createElement(Box, {
520
+ sx: _extends({}, horizontal ? {
521
+ width: width || DIMENSIONS.height,
522
+ height: height || DIMENSIONS.width
523
+ } : {
524
+ width: width || DIMENSIONS.width,
525
+ minHeight: height || DIMENSIONS.height
526
+ }, {
527
+ mt: horizontal ? ['1px', '1px', '1px', 0] : 0,
528
+ border: function border(_ref4) {
529
+ var colors = _ref4.colors;
530
+ return "solid 1px " + colors.hinted;
531
+ },
532
+ background: css
533
+ })
534
+ });
535
+ };
536
+
537
+ var Label = function Label(_ref5) {
538
+ var label = _ref5.label,
539
+ units = _ref5.units,
540
+ horizontal = _ref5.horizontal;
541
+ return /*#__PURE__*/React.createElement(Box, {
542
+ sx: !horizontal && {
543
+ width: ['12px', '17px', '17px', '19px'],
544
+ alignSelf: 'flex-end'
545
+ }
546
+ }, /*#__PURE__*/React.createElement(Box, {
547
+ sx: _extends({
548
+ mb: horizontal ? 0 : ['-4px', '-4px', '-4px', '-3px'],
549
+ fontFamily: 'mono',
550
+ fontSize: ['9px', 0, 0, 1],
551
+ letterSpacing: 'smallcaps',
552
+ textTransform: 'uppercase'
553
+ }, horizontal ? {} : {
554
+ writingMode: 'vertical-rl',
555
+ transform: 'rotate(180deg)',
556
+ whiteSpace: 'nowrap',
557
+ display: 'inline-block',
558
+ overflow: 'visible'
559
+ })
560
+ }, label, ' ', /*#__PURE__*/React.createElement(Box, {
561
+ as: "span",
562
+ sx: {
563
+ textTransform: 'none',
564
+ color: 'secondary',
565
+ display: 'inline-block'
566
+ }
567
+ }, units)));
568
+ };
569
+
570
+ var Colorbar = function Colorbar(_ref6) {
571
+ var colormap = _ref6.colormap,
572
+ label = _ref6.label,
573
+ clim = _ref6.clim,
574
+ setClim = _ref6.setClim,
575
+ _ref6$setClimStep = _ref6.setClimStep,
576
+ setClimStep = _ref6$setClimStep === void 0 ? 1 : _ref6$setClimStep,
577
+ discrete = _ref6.discrete,
578
+ units = _ref6.units,
579
+ width = _ref6.width,
580
+ height = _ref6.height,
581
+ _ref6$format = _ref6.format,
582
+ format = _ref6$format === void 0 ? function (d) {
583
+ return d;
584
+ } : _ref6$format,
585
+ _ref6$horizontal = _ref6.horizontal,
586
+ horizontal = _ref6$horizontal === void 0 ? false : _ref6$horizontal,
587
+ _ref6$bottom = _ref6.bottom,
588
+ bottom = _ref6$bottom === void 0 ? false : _ref6$bottom,
589
+ sx = _ref6.sx,
590
+ sxClim = _ref6.sxClim,
591
+ props = _objectWithoutPropertiesLoose(_ref6, ["colormap", "label", "clim", "setClim", "setClimStep", "discrete", "units", "width", "height", "format", "horizontal", "bottom", "sx", "sxClim"]);
592
+
593
+ if (!Array.isArray(colormap)) {
594
+ throw new Error("expected array for colormap, got '" + colormap + "'.");
595
+ }
596
+
597
+ var climRef = [useRef(), useRef()];
598
+
599
+ var _useState = useState(false),
600
+ climMinDragging = _useState[0],
601
+ setClimMinDragging = _useState[1];
602
+
603
+ var _useState2 = useState(false),
604
+ climMaxDragging = _useState2[0],
605
+ setClimMaxDragging = _useState2[1];
606
+
607
+ var x,
608
+ y,
609
+ dx,
610
+ dy = 0;
611
+ var id = null;
612
+ var init = [0, 0];
613
+ var scale = setClimStep;
614
+
615
+ var draggingFunction = function draggingFunction(e) {
616
+ if (id === 'min' && !climMinDragging) setClimMinDragging(true);
617
+ if (id === 'max' && !climMaxDragging) setClimMaxDragging(true);
618
+ dx = e.pageX - x;
619
+ dy = e.pageY - y;
620
+
621
+ if (horizontal) {
622
+ if (id === 'min') setClim(function (prev) {
623
+ return [Math.min(init[0] + dx * scale, init[1]), prev[1]];
624
+ });
625
+ if (id === 'max') setClim(function (prev) {
626
+ return [prev[0], Math.max(init[1] + dx * scale, init[0])];
627
+ });
628
+ } else {
629
+ if (id === 'min') setClim(function (prev) {
630
+ return [Math.min(init[0] - dy * scale, init[1]), prev[1]];
631
+ });
632
+ if (id === 'max') setClim(function (prev) {
633
+ return [prev[0], Math.max(init[1] - dy * scale, init[0])];
634
+ });
635
+ }
636
+ };
637
+
638
+ var handleMouseDown = function handleMouseDown(e) {
639
+ y = e.pageY;
640
+ x = e.pageX;
641
+ id = e.target.id;
642
+ init = clim;
643
+ document.body.setAttribute('style', horizontal ? 'cursor: ew-resize !important' : 'cursor: ns-resize !important');
644
+ document.addEventListener('mousemove', draggingFunction);
645
+
646
+ var updater = function updater() {
647
+ document.body.setAttribute('style', 'cursor: unset');
648
+ document.removeEventListener('mousemove', draggingFunction);
649
+ window.removeEventListener('mouseup', updater);
650
+ if (id === 'min') setClimMinDragging(false);
651
+ if (id === 'max') setClimMaxDragging(false);
652
+ };
653
+
654
+ window.addEventListener('mouseup', updater);
655
+ };
656
+
657
+ var increment = function increment(e) {
658
+ if (climRef[0].current === document.activeElement) {
659
+ e.preventDefault();
660
+ setClim(function (prev) {
661
+ return [Math.min(prev[0] + scale, prev[1]), prev[1]];
662
+ });
663
+ climRef[0].current.focus();
664
+ }
665
+
666
+ if (climRef[1].current === document.activeElement) {
667
+ e.preventDefault();
668
+ setClim(function (prev) {
669
+ return [prev[0], Math.max(prev[1] + scale, prev[0])];
670
+ });
671
+ climRef[1].current.focus();
672
+ }
673
+ };
674
+
675
+ var decrement = function decrement(e) {
676
+ if (climRef[0].current === document.activeElement) {
677
+ e.preventDefault();
678
+ setClim(function (prev) {
679
+ return [Math.min(prev[0] - scale, prev[1]), prev[1]];
680
+ });
681
+ climRef[0].current.focus();
682
+ }
683
+
684
+ if (climRef[1].current === document.activeElement) {
685
+ e.preventDefault();
686
+ setClim(function (prev) {
687
+ return [prev[0], Math.max(prev[1] - scale, prev[0])];
688
+ });
689
+ climRef[1].current.focus();
690
+ }
691
+ };
692
+
693
+ useEffect(function () {
694
+ var listener = function listener(e) {
695
+ if (['ArrowUp', 'ArrowRight'].includes(e.code) || ['ArrowUp', 'ArrowRight'].includes(e.key)) {
696
+ increment(e);
697
+ }
698
+
699
+ if (['ArrowDown', 'ArrowLeft'].includes(e.code) || ['ArrowDown', 'ArrowLeft'].includes(e.key)) {
700
+ decrement(e);
701
+ }
702
+ };
703
+
704
+ window.addEventListener('keydown', listener);
705
+ return function () {
706
+ window.removeEventListener('keydown', listener);
707
+ };
708
+ }, [clim]);
709
+
710
+ var ClimMin = function ClimMin() {
711
+ return /*#__PURE__*/React.createElement(Box, {
712
+ id: "min",
713
+ ref: climRef[0],
714
+ tabIndex: 0,
715
+ sx: _extends({}, styles.clim(setClim), {
716
+ ml: label ? horizontal ? bottom ? '0px' : '10px' : ['2px', '1px', '1px', '2px'] : 0,
717
+ mr: horizontal ? ['2px', '1px', '1px', '2px'] : 0,
718
+ mb: horizontal ? 0 : ['-2px', '-2px', '-2px', '-3px'],
719
+ borderBottom: setClim ? climMinDragging ? function (_ref7) {
720
+ var colors = _ref7.colors;
721
+ return "solid 1px " + colors.primary;
722
+ } : function (_ref8) {
723
+ var colors = _ref8.colors;
724
+ return "solid 1px " + colors.secondary;
725
+ } : 'unset',
726
+ cursor: setClim ? horizontal ? 'ew-resize' : 'ns-resize' : 'default'
727
+ }, sxClim),
728
+ onMouseDown: setClim ? handleMouseDown : function () {},
729
+ onClick: function onClick() {
730
+ return climRef[0].current.focus();
731
+ }
732
+ }, format(clim[0]));
733
+ };
734
+
735
+ var ClimMax = function ClimMax() {
736
+ return /*#__PURE__*/React.createElement(Box, {
737
+ id: "max",
738
+ ref: climRef[1],
739
+ tabIndex: 0,
740
+ sx: _extends({}, styles.clim(setClim), {
741
+ ml: horizontal ? ['2px', '1px', '1px', '2px'] : ['2px', '1px', '1px', '2px'],
742
+ mt: horizontal ? 0 : ['-2px', '-3px', '-3px', '-3px'],
743
+ borderBottom: setClim ? climMaxDragging ? function (_ref9) {
744
+ var colors = _ref9.colors;
745
+ return "solid 1px " + colors.primary;
746
+ } : function (_ref10) {
747
+ var colors = _ref10.colors;
748
+ return "solid 1px " + colors.secondary;
749
+ } : 'unset',
750
+ cursor: setClim ? horizontal ? 'ew-resize' : 'ns-resize' : 'default'
751
+ }, sxClim),
752
+ onMouseDown: setClim ? handleMouseDown : function () {},
753
+ onClick: function onClick() {
754
+ return climRef[1].current.focus();
755
+ }
756
+ }, format(clim[1]));
757
+ };
758
+
759
+ return /*#__PURE__*/React.createElement(Flex, _extends({}, props, {
760
+ sx: _extends({
761
+ flexDirection: 'row',
762
+ alignItems: 'start',
763
+ justifyContent: 'flex-start',
764
+ gap: ['3px', '6px', '6px', '7px'],
765
+ height: !horizontal ? '100%' : 'unset'
766
+ }, sx)
767
+ }), label && /*#__PURE__*/React.createElement(Label, {
768
+ label: label,
769
+ units: units,
770
+ horizontal: horizontal
771
+ }), /*#__PURE__*/React.createElement(Flex, {
772
+ sx: {
773
+ flexGrow: horizontal ? 1 : 'unset',
774
+ flexDirection: 'column',
775
+ ml: bottom && label ? '4px' : '0px',
776
+ height: !horizontal ? '100%' : 'unset'
777
+ }
778
+ }, /*#__PURE__*/React.createElement(Flex, {
779
+ sx: {
780
+ gap: ['3px', '6px', '6px', '7px'],
781
+ height: !horizontal ? '100%' : 'unset'
782
+ }
783
+ }, horizontal && clim && !bottom && /*#__PURE__*/React.createElement(ClimMin, null), /*#__PURE__*/React.createElement(Gradient, {
784
+ colormap: colormap,
785
+ horizontal: horizontal,
786
+ discrete: discrete,
787
+ width: width,
788
+ height: height
789
+ }), horizontal && clim && !bottom && /*#__PURE__*/React.createElement(ClimMax, null)), horizontal && clim && bottom && /*#__PURE__*/React.createElement(Flex, {
790
+ sx: {
791
+ justifyContent: 'space-between'
792
+ }
793
+ }, /*#__PURE__*/React.createElement(ClimMin, null), /*#__PURE__*/React.createElement(ClimMax, null))), !horizontal && /*#__PURE__*/React.createElement(Flex, {
794
+ sx: {
795
+ flexDirection: 'column-reverse',
796
+ justifyContent: 'space-between',
797
+ height: height || DIMENSIONS.height
798
+ }
799
+ }, clim && /*#__PURE__*/React.createElement(ClimMin, null), clim && /*#__PURE__*/React.createElement(ClimMax, null)));
800
+ };
801
+
459
802
  var Column = function Column(_ref) {
460
803
  var start = _ref.start,
461
804
  width = _ref.width,
@@ -818,145 +1161,6 @@ var Menu = function Menu(_ref) {
818
1161
  })));
819
1162
  };
820
1163
 
821
- var Settings = function Settings(_ref) {
822
- var value = _ref.value,
823
- sx = _ref.sx,
824
- props = _objectWithoutPropertiesLoose(_ref, ["value", "sx"]);
825
-
826
- return /*#__PURE__*/React.createElement(IconButton, _extends({
827
- sx: _extends({
828
- cursor: 'pointer',
829
- fill: 'none',
830
- strokeWidth: '2px',
831
- stroke: 'text',
832
- '.paren': {
833
- opacity: '0'
834
- },
835
- '@media (hover: hover) and (pointer: fine)': {
836
- '&:hover .paren': {
837
- opacity: '1'
838
- }
839
- }
840
- }, sx),
841
- "aria-label": "Toggle Menu"
842
- }, props), !value && /*#__PURE__*/React.createElement("svg", {
843
- style: {
844
- width: '50px',
845
- height: '30px',
846
- transform: 'scale(2)',
847
- marginTop: '-3px'
848
- },
849
- xmlns: "http://www.w3.org/2000/svg",
850
- viewBox: "0 0 68 36"
851
- }, /*#__PURE__*/React.createElement("line", {
852
- x1: "24",
853
- y1: "2.1",
854
- x2: "24",
855
- y2: "6.1"
856
- }), /*#__PURE__*/React.createElement("line", {
857
- x1: "24",
858
- y1: "24.1",
859
- x2: "24",
860
- y2: "33.9"
861
- }), /*#__PURE__*/React.createElement("line", {
862
- x1: "44",
863
- y1: "2.1",
864
- x2: "44",
865
- y2: "12.1"
866
- }), /*#__PURE__*/React.createElement("line", {
867
- x1: "44",
868
- y1: "30.1",
869
- x2: "44",
870
- y2: "33.9"
871
- }), /*#__PURE__*/React.createElement("circle", {
872
- cx: "24",
873
- cy: "15.1",
874
- r: "5"
875
- }), /*#__PURE__*/React.createElement("circle", {
876
- cx: "44",
877
- cy: "21.1",
878
- r: "5"
879
- }), /*#__PURE__*/React.createElement("path", {
880
- style: {
881
- transition: 'all 0.2s'
882
- },
883
- className: "paren",
884
- d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
885
- }), /*#__PURE__*/React.createElement("path", {
886
- style: {
887
- transition: 'all 0.2s'
888
- },
889
- className: "paren",
890
- d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
891
- })), value && /*#__PURE__*/React.createElement("svg", {
892
- style: {
893
- width: '50px',
894
- height: '30px',
895
- transform: 'scale(2)',
896
- marginTop: '-3px'
897
- },
898
- xmlns: "http://www.w3.org/2000/svg",
899
- viewBox: "0 0 68 36"
900
- }, /*#__PURE__*/React.createElement("line", {
901
- x1: "50.85",
902
- y1: "29.79",
903
- x2: "17.15",
904
- y2: "6.21"
905
- }), /*#__PURE__*/React.createElement("line", {
906
- x1: "17.15",
907
- y1: "29.79",
908
- x2: "50.85",
909
- y2: "6.21"
910
- }), /*#__PURE__*/React.createElement("path", {
911
- style: {
912
- transition: 'all 0.2s'
913
- },
914
- className: "paren",
915
- d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
916
- }), /*#__PURE__*/React.createElement("path", {
917
- style: {
918
- transition: 'all 0.2s'
919
- },
920
- className: "paren",
921
- d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
922
- })));
923
- };
924
-
925
- var Dimmer = function Dimmer(_ref) {
926
- var sx = _ref.sx,
927
- props = _objectWithoutPropertiesLoose(_ref, ["sx"]);
928
-
929
- var _useColorMode = useColorMode(),
930
- colorMode = _useColorMode[0],
931
- setColorMode = _useColorMode[1];
932
-
933
- var toggle = useCallback(function () {
934
- setColorMode(colorMode === 'light' ? 'dark' : 'light');
935
- }, [colorMode]);
936
- return /*#__PURE__*/React.createElement(IconButton, _extends({
937
- "aria-label": "Toggle dark mode",
938
- onClick: toggle,
939
- role: "checkbox",
940
- sx: _extends({
941
- width: 32,
942
- height: 32,
943
- display: 'inline-block',
944
- cursor: 'pointer',
945
- color: 'secondary'
946
- }, sx)
947
- }, props), /*#__PURE__*/React.createElement(Sun, {
948
- sx: {
949
- strokeWidth: '1.75',
950
- transition: 'stroke 0.15s',
951
- '@media (hover: hover) and (pointer: fine)': {
952
- '&:hover': {
953
- stroke: 'primary'
954
- }
955
- }
956
- }
957
- }));
958
- };
959
-
960
1164
  var sx = {
961
1165
  link: function link(current, label, first) {
962
1166
  if (first === void 0) {
@@ -1036,14 +1240,14 @@ var Nav = function Nav(_ref) {
1036
1240
  return /*#__PURE__*/React.createElement(NextLink, {
1037
1241
  href: href,
1038
1242
  passHref: true
1039
- }, /*#__PURE__*/React.createElement(Link$1, {
1243
+ }, /*#__PURE__*/React.createElement(Link$2, {
1040
1244
  onClick: function onClick() {
1041
1245
  if (nav === url) setExpanded(false);
1042
1246
  },
1043
1247
  sx: sx.link(nav, url, first)
1044
1248
  }, /*#__PURE__*/React.createElement(HoverArrow, null), display));
1045
1249
  } else {
1046
- return /*#__PURE__*/React.createElement(Link$1, {
1250
+ return /*#__PURE__*/React.createElement(Link$2, {
1047
1251
  href: href,
1048
1252
  sx: sx.link(nav, url, first)
1049
1253
  }, /*#__PURE__*/React.createElement(HoverArrow, null), display);
@@ -1071,8 +1275,7 @@ var Header = function Header(_ref3) {
1071
1275
  var status = _ref3.status,
1072
1276
  mode = _ref3.mode,
1073
1277
  nav = _ref3.nav,
1074
- dimmer = _ref3.dimmer,
1075
- settings = _ref3.settings;
1278
+ menuItems = _ref3.menuItems;
1076
1279
 
1077
1280
  var _useState = useState(false),
1078
1281
  expanded = _useState[0],
@@ -1084,7 +1287,6 @@ var Header = function Header(_ref3) {
1084
1287
 
1085
1288
  return /*#__PURE__*/React.createElement(Row, {
1086
1289
  sx: {
1087
- width: '100%',
1088
1290
  pt: ['12px'],
1089
1291
  pb: [3]
1090
1292
  }
@@ -1099,7 +1301,7 @@ var Header = function Header(_ref3) {
1099
1301
  }, (mode == 'homepage' || mode == 'local') && /*#__PURE__*/React.createElement(NextLink, {
1100
1302
  href: "/",
1101
1303
  passHref: true
1102
- }, /*#__PURE__*/React.createElement(Link$1, {
1304
+ }, /*#__PURE__*/React.createElement(Link$2, {
1103
1305
  "aria-label": "CarbonPlan Homepage",
1104
1306
  sx: {
1105
1307
  display: 'block'
@@ -1110,7 +1312,7 @@ var Header = function Header(_ref3) {
1110
1312
  cursor: 'pointer',
1111
1313
  color: 'primary'
1112
1314
  }
1113
- }))), (mode == null || mode == 'remote') && /*#__PURE__*/React.createElement(Link$1, {
1315
+ }))), (mode == null || mode == 'remote') && /*#__PURE__*/React.createElement(Link$2, {
1114
1316
  href: "https://carbonplan.org",
1115
1317
  "aria-label": "CarbonPlan Homepage",
1116
1318
  sx: {
@@ -1136,53 +1338,31 @@ var Header = function Header(_ref3) {
1136
1338
  top: ['-2px', '-3px', '-3px']
1137
1339
  }
1138
1340
  }, status ? "(" + status + ")" : '')), /*#__PURE__*/React.createElement(Column, {
1139
- start: [status ? 6 : 4, 6, 12, 12],
1341
+ start: [status ? 6 : 4, 6, 11, 11],
1140
1342
  width: [status ? 1 : 3, 3, 2, 2],
1141
1343
  sx: {
1142
- display: 'flex',
1143
- alignItems: 'center',
1144
- justifyContent: 'flex-end'
1145
- }
1146
- }, /*#__PURE__*/React.createElement(Box, {
1147
- sx: {
1148
- mr: ['18px'],
1149
- position: 'relative',
1150
- top: ['-1px'],
1151
- pointerEvents: expanded || settings && settings.value ? 'none' : 'all',
1152
- transition: 'opacity 0.15s',
1153
- display: [status ? 'none' : 'block', 'block', dimmer === 'top' ? 'block' : 'none', dimmer === 'top' ? 'block' : 'none']
1154
- }
1155
- }, /*#__PURE__*/React.createElement(Dimmer, {
1156
- sx: {
1157
- opacity: expanded || settings && settings.value ? 0 : 1,
1158
- color: 'primary'
1344
+ zIndex: 5000
1159
1345
  }
1160
- })), settings && /*#__PURE__*/React.createElement(Box, {
1346
+ }, /*#__PURE__*/React.createElement(Flex, {
1161
1347
  sx: {
1162
- mr: ['21px'],
1163
- position: 'relative',
1164
- pointerEvents: expanded ? 'none' : 'all',
1165
- transition: 'opacity 0.15s',
1166
- display: [status ? 'none' : 'block', 'block', 'none', 'none']
1348
+ justifyContent: 'flex-end'
1167
1349
  }
1168
- }, /*#__PURE__*/React.createElement(Settings, {
1169
- value: settings.value,
1170
- onClick: settings.onClick,
1350
+ }, /*#__PURE__*/React.createElement(Flex, {
1171
1351
  sx: {
1352
+ mr: '18px',
1353
+ gap: '18px',
1172
1354
  opacity: expanded ? 0 : 1,
1173
- stroke: 'primary'
1355
+ transition: 'opacity 0.15s',
1356
+ justifyContent: 'space-between',
1357
+ alignItems: 'center'
1174
1358
  }
1175
- })), /*#__PURE__*/React.createElement(Menu, {
1359
+ }, menuItems), /*#__PURE__*/React.createElement(Menu, {
1176
1360
  sx: {
1177
- transition: 'opacity 0.15s',
1178
- pointerEvents: settings && settings.value ? 'none' : 'all',
1179
- opacity: settings && settings.value ? 0 : 1,
1180
- mr: ['-2px'],
1181
- zIndex: 5000
1361
+ mr: ['-2px']
1182
1362
  },
1183
1363
  value: expanded,
1184
1364
  onClick: toggle
1185
- })), /*#__PURE__*/React.createElement(Box, {
1365
+ }))), /*#__PURE__*/React.createElement(Box, {
1186
1366
  sx: {
1187
1367
  opacity: expanded ? 1 : 0,
1188
1368
  pointerEvents: expanded ? 'all' : 'none',
@@ -1254,7 +1434,7 @@ var Footer = function Footer() {
1254
1434
  letterSpacing: 'mono',
1255
1435
  mb: [2]
1256
1436
  }
1257
- }, "EMAIL"), /*#__PURE__*/React.createElement(Link$1, {
1437
+ }, "EMAIL"), /*#__PURE__*/React.createElement(Link$2, {
1258
1438
  href: "mailto:hello@carbonplan.org",
1259
1439
  sx: {
1260
1440
  textDecoration: 'none',
@@ -1288,7 +1468,7 @@ var Footer = function Footer() {
1288
1468
  letterSpacing: 'mono',
1289
1469
  mb: [2]
1290
1470
  }
1291
- }, "FOLLOW"), /*#__PURE__*/React.createElement(Link$1, {
1471
+ }, "FOLLOW"), /*#__PURE__*/React.createElement(Link$2, {
1292
1472
  href: "https://twitter.com/carbonplanorg",
1293
1473
  sx: {
1294
1474
  textDecoration: 'none',
@@ -1382,6 +1562,41 @@ var Footer = function Footer() {
1382
1562
  }))));
1383
1563
  };
1384
1564
 
1565
+ var Dimmer = function Dimmer(_ref) {
1566
+ var sx = _ref.sx,
1567
+ props = _objectWithoutPropertiesLoose(_ref, ["sx"]);
1568
+
1569
+ var _useColorMode = useColorMode(),
1570
+ colorMode = _useColorMode[0],
1571
+ setColorMode = _useColorMode[1];
1572
+
1573
+ var toggle = useCallback(function () {
1574
+ setColorMode(colorMode === 'light' ? 'dark' : 'light');
1575
+ }, [colorMode]);
1576
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
1577
+ "aria-label": "Toggle dark mode",
1578
+ onClick: toggle,
1579
+ role: "checkbox",
1580
+ sx: _extends({
1581
+ width: 32,
1582
+ height: 32,
1583
+ display: 'inline-block',
1584
+ cursor: 'pointer',
1585
+ color: 'secondary'
1586
+ }, sx)
1587
+ }, props), /*#__PURE__*/React.createElement(Sun, {
1588
+ sx: {
1589
+ strokeWidth: '1.75',
1590
+ transition: 'stroke 0.15s',
1591
+ '@media (hover: hover) and (pointer: fine)': {
1592
+ '&:hover': {
1593
+ stroke: 'primary'
1594
+ }
1595
+ }
1596
+ }
1597
+ }));
1598
+ };
1599
+
1385
1600
  var GitSha = function GitSha() {
1386
1601
  var sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA;
1387
1602
  var owner = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_OWNER;
@@ -1401,7 +1616,7 @@ var GitSha = function GitSha() {
1401
1616
  }
1402
1617
  }, /*#__PURE__*/React.createElement(Separator, {
1403
1618
  color: color
1404
- }), /*#__PURE__*/React.createElement(Link$1, {
1619
+ }), /*#__PURE__*/React.createElement(Link$2, {
1405
1620
  href: href,
1406
1621
  sx: {
1407
1622
  whiteSpace: 'nowrap',
@@ -1693,6 +1908,110 @@ function GuideColumns(_ref2) {
1693
1908
  }));
1694
1909
  }
1695
1910
 
1911
+ var Settings = function Settings(_ref) {
1912
+ var value = _ref.value,
1913
+ sx = _ref.sx,
1914
+ props = _objectWithoutPropertiesLoose(_ref, ["value", "sx"]);
1915
+
1916
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
1917
+ sx: _extends({
1918
+ cursor: 'pointer',
1919
+ fill: 'none',
1920
+ strokeWidth: '2px',
1921
+ stroke: 'text',
1922
+ '.paren': {
1923
+ opacity: '0'
1924
+ },
1925
+ '@media (hover: hover) and (pointer: fine)': {
1926
+ '&:hover .paren': {
1927
+ opacity: '1'
1928
+ }
1929
+ }
1930
+ }, sx),
1931
+ "aria-label": "Toggle Menu"
1932
+ }, props), !value && /*#__PURE__*/React.createElement("svg", {
1933
+ style: {
1934
+ width: '50px',
1935
+ height: '30px',
1936
+ transform: 'scale(2)',
1937
+ marginTop: '-3px'
1938
+ },
1939
+ xmlns: "http://www.w3.org/2000/svg",
1940
+ viewBox: "0 0 68 36"
1941
+ }, /*#__PURE__*/React.createElement("line", {
1942
+ x1: "24",
1943
+ y1: "2.1",
1944
+ x2: "24",
1945
+ y2: "6.1"
1946
+ }), /*#__PURE__*/React.createElement("line", {
1947
+ x1: "24",
1948
+ y1: "24.1",
1949
+ x2: "24",
1950
+ y2: "33.9"
1951
+ }), /*#__PURE__*/React.createElement("line", {
1952
+ x1: "44",
1953
+ y1: "2.1",
1954
+ x2: "44",
1955
+ y2: "12.1"
1956
+ }), /*#__PURE__*/React.createElement("line", {
1957
+ x1: "44",
1958
+ y1: "30.1",
1959
+ x2: "44",
1960
+ y2: "33.9"
1961
+ }), /*#__PURE__*/React.createElement("circle", {
1962
+ cx: "24",
1963
+ cy: "15.1",
1964
+ r: "5"
1965
+ }), /*#__PURE__*/React.createElement("circle", {
1966
+ cx: "44",
1967
+ cy: "21.1",
1968
+ r: "5"
1969
+ }), /*#__PURE__*/React.createElement("path", {
1970
+ style: {
1971
+ transition: 'all 0.2s'
1972
+ },
1973
+ className: "paren",
1974
+ d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
1975
+ }), /*#__PURE__*/React.createElement("path", {
1976
+ style: {
1977
+ transition: 'all 0.2s'
1978
+ },
1979
+ className: "paren",
1980
+ d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
1981
+ })), value && /*#__PURE__*/React.createElement("svg", {
1982
+ style: {
1983
+ width: '50px',
1984
+ height: '30px',
1985
+ transform: 'scale(2)',
1986
+ marginTop: '-3px'
1987
+ },
1988
+ xmlns: "http://www.w3.org/2000/svg",
1989
+ viewBox: "0 0 68 36"
1990
+ }, /*#__PURE__*/React.createElement("line", {
1991
+ x1: "50.85",
1992
+ y1: "29.79",
1993
+ x2: "17.15",
1994
+ y2: "6.21"
1995
+ }), /*#__PURE__*/React.createElement("line", {
1996
+ x1: "17.15",
1997
+ y1: "29.79",
1998
+ x2: "50.85",
1999
+ y2: "6.21"
2000
+ }), /*#__PURE__*/React.createElement("path", {
2001
+ style: {
2002
+ transition: 'all 0.2s'
2003
+ },
2004
+ className: "paren",
2005
+ d: "M6.4,1.2c-6.3,10.3-6.3,23.3,0,33.6"
2006
+ }), /*#__PURE__*/React.createElement("path", {
2007
+ style: {
2008
+ transition: 'all 0.2s'
2009
+ },
2010
+ className: "paren",
2011
+ d: "M61.6,34.8c6.3-10.3,6.3-23.3,0-33.6"
2012
+ })));
2013
+ };
2014
+
1696
2015
  var Layout = function Layout(_ref) {
1697
2016
  var title = _ref.title,
1698
2017
  description = _ref.description,
@@ -1720,6 +2039,7 @@ var Layout = function Layout(_ref) {
1720
2039
  _ref$container = _ref.container,
1721
2040
  container = _ref$container === void 0 ? true : _ref$container;
1722
2041
  var content = children;
2042
+ var index = useBreakpointIndex();
1723
2043
 
1724
2044
  if (fade) {
1725
2045
  content = /*#__PURE__*/React.createElement(FadeIn, {
@@ -1728,7 +2048,34 @@ var Layout = function Layout(_ref) {
1728
2048
  }
1729
2049
 
1730
2050
  if (container) {
1731
- content = /*#__PURE__*/React.createElement(Container, null, content);
2051
+ content = /*#__PURE__*/React.createElement(Box, {
2052
+ sx: {
2053
+ mb: [8, 8, 9, 10]
2054
+ }
2055
+ }, /*#__PURE__*/React.createElement(Container, null, content));
2056
+ }
2057
+
2058
+ useEffect(function () {
2059
+ if (index > 2 && settings != null && settings.value && settings != null && settings.onClick) {
2060
+ settings == null ? void 0 : settings.onClick();
2061
+ }
2062
+ }, [index, settings == null ? void 0 : settings.value, settings == null ? void 0 : settings.onClick]);
2063
+ var menuItems = [/*#__PURE__*/React.createElement(Dimmer, {
2064
+ key: "dimmer",
2065
+ sx: {
2066
+ color: 'primary',
2067
+ mt: '-2px',
2068
+ display: ['block', 'block', dimmer === 'top' ? 'block' : 'none', dimmer === 'top' ? 'block' : 'none']
2069
+ }
2070
+ })];
2071
+
2072
+ if (settings) {
2073
+ menuItems.push( /*#__PURE__*/React.createElement(Settings, _extends({
2074
+ key: "settings",
2075
+ sx: {
2076
+ display: ['inherit', 'inherit', 'none', 'none']
2077
+ }
2078
+ }, settings)));
1732
2079
  }
1733
2080
 
1734
2081
  return /*#__PURE__*/React.createElement(React.Fragment, null, guide && /*#__PURE__*/React.createElement(Guide, {
@@ -1760,8 +2107,7 @@ var Layout = function Layout(_ref) {
1760
2107
  mode: links,
1761
2108
  status: status,
1762
2109
  nav: nav,
1763
- settings: settings,
1764
- dimmer: dimmer
2110
+ menuItems: menuItems
1765
2111
  }))), /*#__PURE__*/React.createElement(Box, {
1766
2112
  sx: {
1767
2113
  width: '100%',
@@ -2086,7 +2432,7 @@ var Group = function Group(_ref) {
2086
2432
  }));
2087
2433
  };
2088
2434
 
2089
- var Input = function Input(_ref) {
2435
+ var Input = function Input(_ref, ref) {
2090
2436
  var _extends2;
2091
2437
 
2092
2438
  var _ref$size = _ref.size,
@@ -2119,10 +2465,13 @@ var Input = function Input(_ref) {
2119
2465
  }, _extends2), getSizeStyles(size), sx);
2120
2466
 
2121
2467
  return /*#__PURE__*/React.createElement(Input$1, _extends({}, props, {
2468
+ ref: ref,
2122
2469
  sx: styles
2123
2470
  }));
2124
2471
  };
2125
2472
 
2473
+ var input = forwardRef(Input);
2474
+
2126
2475
  var getProps = function getProps(test) {
2127
2476
  return function (props) {
2128
2477
  var next = {};
@@ -2142,7 +2491,8 @@ var Select = function Select(_ref) {
2142
2491
  _ref$size = _ref.size,
2143
2492
  size = _ref$size === void 0 ? 'sm' : _ref$size,
2144
2493
  sx = _ref.sx,
2145
- props = _objectWithoutPropertiesLoose(_ref, ["children", "size", "sx"]);
2494
+ sxSelect = _ref.sxSelect,
2495
+ props = _objectWithoutPropertiesLoose(_ref, ["children", "size", "sx", "sxSelect"]);
2146
2496
 
2147
2497
  var color = sx && sx.color ? sx.color : 'primary';
2148
2498
  var sizeStyles = getSizeStyles(size);
@@ -2213,7 +2563,7 @@ var Select = function Select(_ref) {
2213
2563
  outline: 'none !important',
2214
2564
  background: 'transparent !important'
2215
2565
  }
2216
- }, _extends2))
2566
+ }, _extends2), sxSelect)
2217
2567
  }, omitOnChange), children), /*#__PURE__*/React.createElement(Arrow, {
2218
2568
  sx: {
2219
2569
  width: width,
@@ -2228,7 +2578,7 @@ var Select = function Select(_ref) {
2228
2578
  }));
2229
2579
  };
2230
2580
 
2231
- var Slider = function Slider(_ref) {
2581
+ var Slider = function Slider(_ref, ref) {
2232
2582
  var sx = _ref.sx,
2233
2583
  props = _objectWithoutPropertiesLoose(_ref, ["sx"]);
2234
2584
 
@@ -2238,6 +2588,7 @@ var Slider = function Slider(_ref) {
2238
2588
  colors = _useThemeUI.theme.rawColors;
2239
2589
 
2240
2590
  return /*#__PURE__*/React.createElement(Slider$1, _extends({
2591
+ ref: ref,
2241
2592
  sx: _extends({
2242
2593
  '&::-webkit-slider-thumb': {
2243
2594
  height: [22, 18, 16],
@@ -2269,7 +2620,9 @@ var Slider = function Slider(_ref) {
2269
2620
  }, props));
2270
2621
  };
2271
2622
 
2272
- var styles = {
2623
+ var slider = forwardRef(Slider);
2624
+
2625
+ var styles$1 = {
2273
2626
  reset: {
2274
2627
  verticalAlign: 'baseline',
2275
2628
  border: 0,
@@ -2341,7 +2694,7 @@ var Table = function Table(_ref) {
2341
2694
  }
2342
2695
  }, header && /*#__PURE__*/React.createElement(Row, {
2343
2696
  as: "tr",
2344
- sx: _extends({}, styles.reset, styles.header, styles.row, {
2697
+ sx: _extends({}, styles$1.reset, styles$1.header, styles$1.row, {
2345
2698
  color: color,
2346
2699
  borderTopWidth: !borderTop ? '0px' : '1px'
2347
2700
  })
@@ -2349,13 +2702,13 @@ var Table = function Table(_ref) {
2349
2702
  as: "td",
2350
2703
  start: [1],
2351
2704
  width: columns,
2352
- sx: styles.index
2705
+ sx: styles$1.index
2353
2706
  }, header)), data.map(function (row, i) {
2354
2707
  return /*#__PURE__*/React.createElement(Row, {
2355
2708
  as: "tr",
2356
2709
  columns: columns,
2357
2710
  key: i,
2358
- sx: _extends({}, styles.reset, styles.row, {
2711
+ sx: _extends({}, styles$1.reset, styles$1.row, {
2359
2712
  pb: borderBottom && i === data.length - 1 ? ['18px', '18px', '18px', '22px'] : [3, 3, 3, '20px'],
2360
2713
  borderBottomWidth: borderBottom && i === data.length - 1 ? '1px' : '0px',
2361
2714
  borderTopWidth: !borderTop && i === 0 && !header ? '0px' : '1px'
@@ -2366,13 +2719,13 @@ var Table = function Table(_ref) {
2366
2719
  key: j,
2367
2720
  start: start[j],
2368
2721
  width: width[j],
2369
- sx: j == 0 && index ? _extends({}, styles.reset, styles.index) : _extends({}, styles.reset, styles.entry)
2722
+ sx: j == 0 && index ? _extends({}, styles$1.reset, styles$1.index) : _extends({}, styles$1.reset, styles$1.entry)
2370
2723
  }, column);
2371
2724
  }));
2372
2725
  })));
2373
2726
  };
2374
2727
 
2375
- var Toggle = function Toggle(_ref) {
2728
+ var Toggle = function Toggle(_ref, ref) {
2376
2729
  var value = _ref.value,
2377
2730
  onClick = _ref.onClick,
2378
2731
  disabled = _ref.disabled,
@@ -2382,6 +2735,7 @@ var Toggle = function Toggle(_ref) {
2382
2735
  var color = sx && sx.color ? sx.color : 'primary';
2383
2736
  value = disabled ? false : value;
2384
2737
  return /*#__PURE__*/React.createElement(Box, _extends({
2738
+ ref: ref,
2385
2739
  as: "button",
2386
2740
  onClick: onClick,
2387
2741
  role: "checkbox",
@@ -2419,6 +2773,8 @@ var Toggle = function Toggle(_ref) {
2419
2773
  })));
2420
2774
  };
2421
2775
 
2776
+ var toggle = forwardRef(Toggle);
2777
+
2422
2778
  var Tracking = function Tracking(_ref) {
2423
2779
  var id = _ref.id;
2424
2780
 
@@ -2442,7 +2798,6 @@ var Tray = function Tray(_ref) {
2442
2798
  children = _ref.children;
2443
2799
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
2444
2800
  sx: {
2445
- display: ['initial', 'initial', 'none', 'none'],
2446
2801
  position: 'fixed',
2447
2802
  top: '56px',
2448
2803
  bottom: '0px',
@@ -2457,7 +2812,6 @@ var Tray = function Tray(_ref) {
2457
2812
  }
2458
2813
  }), /*#__PURE__*/React.createElement(Box, {
2459
2814
  sx: _extends({
2460
- display: ['initial', 'initial', 'none', 'none'],
2461
2815
  position: 'fixed',
2462
2816
  width: 'calc(100vw)',
2463
2817
  top: '0px',
@@ -2517,5 +2871,5 @@ var formatDate = function formatDate(date, options) {
2517
2871
  return [month, day, year].filter(Boolean).join(' ');
2518
2872
  };
2519
2873
 
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 };
2874
+ 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 };
2521
2875
  //# sourceMappingURL=index.esm.js.map