gatsby-theme-carbon 2.0.0-next.1 → 2.0.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/gatsby-config.js CHANGED
@@ -33,6 +33,7 @@ module.exports = (themeOptions) => {
33
33
  remarkPlugins = [],
34
34
  gatsbyPluginSharpOptions = {},
35
35
  isServiceWorkerEnabled = false,
36
+ isSwitcherEnabled = true,
36
37
  } = themeOptions;
37
38
 
38
39
  const theme = { ...defaultTheme, ...themeOption };
@@ -78,6 +79,7 @@ module.exports = (themeOptions) => {
78
79
  homepageTheme: theme.homepage,
79
80
  interiorTheme: theme.interior,
80
81
  isServiceWorkerEnabled,
82
+ isSwitcherEnabled,
81
83
  title: 'Gatsby Theme Carbon',
82
84
  description:
83
85
  'Add a description by supplying it to siteMetadata in your gatsby-config.js file.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-theme-carbon",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0",
4
4
  "main": "index.js",
5
5
  "author": "vpicone <vp@vincepic.one> (@vpicone)",
6
6
  "repository": {
@@ -22,47 +22,47 @@
22
22
  "react-dom": "^17.0.2"
23
23
  },
24
24
  "dependencies": {
25
- "@babel/core": "^7.13.16",
26
- "@carbon/elements": "^10.32.0",
27
- "@carbon/icons-react": "^10.30.0",
28
- "@carbon/themes": "^10.32.0",
25
+ "@babel/core": "^7.14.6",
26
+ "@carbon/elements": "^10.38.0",
27
+ "@carbon/icons-react": "^10.35.0",
28
+ "@carbon/themes": "^10.38.0",
29
29
  "@mdx-js/mdx": "^1.5.5",
30
30
  "@mdx-js/react": "^1.5.5",
31
31
  "@reach/router": "^1.2.1",
32
32
  "@vimeo/player": "^2.9.1",
33
33
  "beautiful-react-hooks": "^0.23.1",
34
- "carbon-components": "^10.33.0",
35
- "carbon-components-react": "^7.33.0",
34
+ "carbon-components": "^10.39.0",
35
+ "carbon-components-react": "^7.39.0",
36
36
  "carbon-icons": "^7.0.7",
37
37
  "classnames": "^2.2.6",
38
38
  "copy-to-clipboard": "^3.2.0",
39
39
  "focus-trap-react": "^8.4.2",
40
- "gatsby-plugin-catch-links": "^3.3.0",
40
+ "gatsby-plugin-catch-links": "^3.7.1",
41
41
  "gatsby-plugin-lunr": "^1.5.2",
42
- "gatsby-plugin-manifest": "^3.3.0",
43
- "gatsby-plugin-mdx": "^2.3.0",
44
- "gatsby-plugin-offline": "^4.3.0",
45
- "gatsby-plugin-react-helmet": "^4.3.0",
46
- "gatsby-plugin-sass": "^4.3.0",
42
+ "gatsby-plugin-manifest": "^3.7.1",
43
+ "gatsby-plugin-mdx": "^2.7.1",
44
+ "gatsby-plugin-offline": "^4.7.1",
45
+ "gatsby-plugin-react-helmet": "^4.7.1",
46
+ "gatsby-plugin-sass": "^4.7.1",
47
47
  "gatsby-plugin-sass-resources": "^2.0.0",
48
- "gatsby-plugin-sharp": "^3.3.1",
48
+ "gatsby-plugin-sharp": "^3.7.1",
49
49
  "gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.22",
50
- "gatsby-remark-copy-linked-files": "^4.0.0",
51
- "gatsby-remark-images": "^5.0.0",
52
- "gatsby-remark-responsive-iframe": "^4.0.0",
53
- "gatsby-remark-smartypants": "^4.0.0",
50
+ "gatsby-remark-copy-linked-files": "^4.4.1",
51
+ "gatsby-remark-images": "^5.4.1",
52
+ "gatsby-remark-responsive-iframe": "^4.4.1",
53
+ "gatsby-remark-smartypants": "^4.4.1",
54
54
  "gatsby-remark-unwrap-images": "^1.0.1",
55
- "gatsby-source-filesystem": "^3.3.0",
55
+ "gatsby-source-filesystem": "^3.7.1",
56
56
  "gatsby-source-medium-feed": "^1.0.6",
57
- "gatsby-transformer-yaml": "^3.3.0",
57
+ "gatsby-transformer-yaml": "^3.7.1",
58
58
  "lodash.startcase": "^4.4.0",
59
59
  "lodash.throttle": "^4.1.1",
60
60
  "mkdirp": "^1.0.3",
61
- "node-sass": "^4.11.0",
62
- "prism-react-renderer": "^1.0.2",
61
+ "node-sass": "5",
62
+ "prism-react-renderer": "^1.2.1",
63
63
  "prop-types": "^15.7.2",
64
64
  "react-helmet": "^6.0.0-beta",
65
- "react-transition-group": "^4.3.0",
65
+ "react-transition-group": "^4.4.2",
66
66
  "react-use": "^15.3.4",
67
67
  "remark-slug": "^6.0.0",
68
68
  "slugify": "^1.3.4",
@@ -43,6 +43,10 @@
43
43
  }
44
44
  }
45
45
 
46
+ :global(.container--dark) .link {
47
+ color: $carbon--gray-10;
48
+ }
49
+
46
50
  .paragraph {
47
51
  @include carbon--type-style('body-long-01');
48
52
  font-size: 1.25rem;
@@ -23,8 +23,9 @@ const Header = ({ children }) => {
23
23
  toggleNavState,
24
24
  switcherIsOpen,
25
25
  searchIsOpen,
26
+ switcherTooltipText = 'Switch sites',
26
27
  } = useContext(NavContext);
27
- const { isSearchEnabled, navigationStyle } = useMetadata();
28
+ const { isSearchEnabled, navigationStyle, isSwitcherEnabled } = useMetadata();
28
29
 
29
30
  return (
30
31
  <ShellHeader
@@ -54,19 +55,21 @@ const Header = ({ children }) => {
54
55
  <HeaderGlobalBar
55
56
  className={cx({ [styles.searchIsOpenOnBar]: searchIsOpen })}>
56
57
  {isSearchEnabled && <GlobalSearch />}
57
- <HeaderGlobalAction
58
- className={cx(styles.headerButton, styles.switcherButton, {
59
- [styles.switcherButtonOpen]: switcherIsOpen,
60
- })}
61
- aria-label="App switcher"
62
- tooltipAlignment="end"
63
- onClick={() => {
64
- toggleNavState('switcherIsOpen');
65
- toggleNavState('searchIsOpen', 'close');
66
- toggleNavState('leftNavIsOpen', 'close');
67
- }}>
68
- {switcherIsOpen ? <Close20 /> : <Switcher20 />}
69
- </HeaderGlobalAction>
58
+ {isSwitcherEnabled && (
59
+ <HeaderGlobalAction
60
+ className={cx(styles.headerButton, styles.switcherButton, {
61
+ [styles.switcherButtonOpen]: switcherIsOpen,
62
+ })}
63
+ aria-label={switcherTooltipText}
64
+ tooltipAlignment="end"
65
+ onClick={() => {
66
+ toggleNavState('switcherIsOpen');
67
+ toggleNavState('searchIsOpen', 'close');
68
+ toggleNavState('leftNavIsOpen', 'close');
69
+ }}>
70
+ {switcherIsOpen ? <Close20 /> : <Switcher20 />}
71
+ </HeaderGlobalAction>
72
+ )}
70
73
  </HeaderGlobalBar>
71
74
  </ShellHeader>
72
75
  );
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable import/no-unresolved */
2
- import React, { useLayoutEffect } from 'react';
2
+ import React, { useEffect } from 'react';
3
3
 
4
4
  import Meta from './Meta';
5
5
  import LeftNav from './LeftNav';
@@ -7,6 +7,7 @@ import Header from './Header';
7
7
  import Switcher from './Switcher';
8
8
  import Footer from './Footer';
9
9
  import Container from './Container';
10
+ import useMetadata from '../util/hooks/useMetadata';
10
11
 
11
12
  import '../styles/index.scss';
12
13
 
@@ -21,8 +22,9 @@ const Layout = ({
21
22
  tabs,
22
23
  }) => {
23
24
  const is404 = children.key === null;
25
+ const { isSwitcherEnabled } = useMetadata();
24
26
 
25
- useLayoutEffect(() => {
27
+ useEffect(() => {
26
28
  // eslint-disable-next-line global-require
27
29
  const scroll = require('smooth-scroll')('a[href*="#"]', {
28
30
  speed: 400,
@@ -43,8 +45,8 @@ const Layout = ({
43
45
  pageDescription={pageDescription}
44
46
  pageKeywords={pageKeywords}
45
47
  />
46
- <Header />
47
- <Switcher />
48
+ <Header isSwitcherEnabled={isSwitcherEnabled} />
49
+ {isSwitcherEnabled && <Switcher />}
48
50
  <LeftNav homepage={homepage} is404Page={is404} theme={theme} />
49
51
  <Container homepage={homepage} theme={theme}>
50
52
  {children}
@@ -3,7 +3,7 @@
3
3
  width: 100%;
4
4
  background: $carbon--black-100;
5
5
  position: sticky;
6
- top: 3rem;
6
+ top: calc(3rem - 1px);
7
7
  z-index: 6000; /* old z('header') #940 */
8
8
  }
9
9
 
@@ -1,10 +1,4 @@
1
- import React, {
2
- useContext,
3
- useRef,
4
- useLayoutEffect,
5
- useEffect,
6
- useState,
7
- } from 'react';
1
+ import React, { useContext, useRef, useEffect, useState } from 'react';
8
2
  import cx from 'classnames';
9
3
  import useMedia from 'use-media';
10
4
  import { Locked16 } from '@carbon/icons-react';
@@ -32,7 +26,7 @@ const Switcher = ({ children }) => {
32
26
  }, [toggleNavState]);
33
27
 
34
28
  // calculate and update height
35
- useLayoutEffect(() => {
29
+ useEffect(() => {
36
30
  if (switcherIsOpen) {
37
31
  setHeight(listRef.current.offsetHeight + 40);
38
32
  } else {
@@ -102,7 +96,7 @@ const DefaultChildren = () => (
102
96
  <SwitcherLink href="https://www.carbondesignsystem.com/">
103
97
  Carbon Design System
104
98
  </SwitcherLink>
105
- <SwitcherLink href="https://www.ibm.com/standards/web/carbon-for-ibm-dotcom/">
99
+ <SwitcherLink href="https://www.ibm.com/standards/carbon/">
106
100
  Carbon for IBM.com
107
101
  </SwitcherLink>
108
102
  <SwitcherLink href="https://www.ibm.com/design/event/">
@@ -31,12 +31,11 @@ const Select = ({ children, _id }) => {
31
31
  index,
32
32
  }));
33
33
  return (
34
- <div style={{ marginLeft: '-1rem', marginRight: '-1rem' }}>
34
+ <div className={styles.dropdownWrapper}>
35
35
  <Dropdown
36
36
  size="xl"
37
37
  onChange={({ selectedItem }) => setActiveTab(selectedItem.index)}
38
38
  initialSelectedItem={items[0]}
39
- light
40
39
  label="tab selection"
41
40
  items={items}
42
41
  id={_id}
@@ -11,6 +11,11 @@
11
11
  }
12
12
  }
13
13
 
14
+ .dropdownWrapper {
15
+ margin-left: -1rem;
16
+ margin-right: -1rem;
17
+ }
18
+
14
19
  .panel {
15
20
  --space: 0;
16
21
  color: $text-01;
@@ -5,6 +5,10 @@ let globalIndex = 0;
5
5
  // eslint-disable-next-line no-plusplus
6
6
  const genId = () => ++globalIndex;
7
7
 
8
+ // https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a
9
+ const useIsomorphicLayoutEffect =
10
+ typeof window !== 'undefined' ? useLayoutEffect : useEffect;
11
+
8
12
  export const useId = (label) => {
9
13
  /*
10
14
  * If this instance isn't part of the initial render, we don't have to do the
@@ -14,7 +18,7 @@ export const useId = (label) => {
14
18
 
15
19
  const [id, setId] = useState(initialId);
16
20
 
17
- useLayoutEffect(() => {
21
+ useIsomorphicLayoutEffect(() => {
18
22
  if (id === null) {
19
23
  /*
20
24
  * Patch the ID after render. We do this in `useLayoutEffect` to avoid any
@@ -9,6 +9,7 @@ const useMetadata = () => {
9
9
  description
10
10
  keywords
11
11
  isSearchEnabled
12
+ isSwitcherEnabled
12
13
  homepageTheme
13
14
  interiorTheme
14
15
  navigationStyle