@carbonplan/components 11.0.4 → 11.0.5-develop.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.
@@ -4,7 +4,6 @@ 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';
8
7
  import Head from 'next/head';
9
8
  import { keyframes } from '@emotion/react';
10
9
 
@@ -1992,7 +1991,6 @@ const Layout = ({
1992
1991
  container: _container = true
1993
1992
  }) => {
1994
1993
  let content = children;
1995
- const index = useBreakpointIndex();
1996
1994
 
1997
1995
  if (_fade) {
1998
1996
  content = /*#__PURE__*/React.createElement(FadeIn, {
@@ -2008,11 +2006,24 @@ const Layout = ({
2008
2006
  }, /*#__PURE__*/React.createElement(Container, null, content));
2009
2007
  }
2010
2008
 
2009
+ const {
2010
+ theme
2011
+ } = useThemeUI();
2011
2012
  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]);
2013
+ if (!theme) return;
2014
+
2015
+ const handler = () => {
2016
+ if (settings != null && settings.value && settings != null && settings.onClick) {
2017
+ settings == null ? void 0 : settings.onClick();
2018
+ }
2019
+ };
2020
+
2021
+ const query = window.matchMedia(`(max-width: ${theme.breakpoints[1]})`);
2022
+ query.addListener(handler);
2023
+ return () => {
2024
+ query.removeListener(handler);
2025
+ };
2026
+ }, [theme, settings == null ? void 0 : settings.value, settings == null ? void 0 : settings.onClick]);
2016
2027
  const menuItems = [/*#__PURE__*/React.createElement(Dimmer, {
2017
2028
  key: "dimmer",
2018
2029
  sx: {