gatsby-theme-carbon 2.0.0-next.3 → 2.1.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/index.js CHANGED
@@ -13,6 +13,7 @@ export { default as Aside } from './src/components/Aside';
13
13
  export { default as FeatureCard } from './src/components/FeatureCard';
14
14
  export { default as FourOhFour } from './src/components/FourOhFour';
15
15
  export { default as ImageCard } from './src/components/ImageCard';
16
+ export { default as SquareCard } from './src/components/SquareCard';
16
17
  export { Tabs, Tab } from './src/components/Tabs';
17
18
  export { default as InlineNotification } from './src/components/InlineNotification';
18
19
  // Homepage Template Components
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-theme-carbon",
3
- "version": "2.0.0-next.3",
3
+ "version": "2.1.1",
4
4
  "main": "index.js",
5
5
  "author": "vpicone <vp@vincepic.one> (@vpicone)",
6
6
  "repository": {
@@ -23,16 +23,17 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@babel/core": "^7.14.6",
26
- "@carbon/elements": "^10.36.0",
27
- "@carbon/icons-react": "^10.33.0",
28
- "@carbon/themes": "^10.36.0",
26
+ "@carbon/elements": "^10.38.0",
27
+ "@carbon/icons-react": "^10.35.0",
28
+ "@carbon/pictograms-react": "^11.14.0",
29
+ "@carbon/themes": "^10.38.0",
29
30
  "@mdx-js/mdx": "^1.5.5",
30
31
  "@mdx-js/react": "^1.5.5",
31
32
  "@reach/router": "^1.2.1",
32
33
  "@vimeo/player": "^2.9.1",
33
34
  "beautiful-react-hooks": "^0.23.1",
34
- "carbon-components": "^10.37.0",
35
- "carbon-components-react": "^7.37.1",
35
+ "carbon-components": "^10.39.0",
36
+ "carbon-components-react": "^7.39.0",
36
37
  "carbon-icons": "^7.0.7",
37
38
  "classnames": "^2.2.6",
38
39
  "copy-to-clipboard": "^3.2.0",
@@ -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;
@@ -138,38 +138,43 @@ header.header {
138
138
  transition: background-color $duration--fast-02 $carbon--standard-easing;
139
139
  }
140
140
 
141
- // Switcher button, extra specificity to override Carbon styles
141
+ // Switcher button, extra specificity to override Carbon tooltip button styles
142
142
  // Hex values used pending shell theming
143
- .header .header-button.switcher-button {
144
- background-color: $carbon--gray-100;
145
- position: relative;
146
- border: none;
147
- border-color: $ui-05;
148
- border-bottom: 1px solid $carbon--gray-80;
143
+ .header :global(.bx--tooltip__trigger).header-button.switcher-button {
149
144
  &:focus {
150
- outline: 2px solid $carbon--white-0;
151
- outline-offset: -2px;
145
+ box-shadow: none;
146
+ border-color: $carbon--white-0;
152
147
  }
148
+ }
149
+
150
+ .header :global(a.bx--header__menu-item:hover) {
151
+ color: $carbon--white-0;
152
+ }
153
+
154
+ .header .header-button.switcher-button {
153
155
  &:hover {
154
156
  background-color: $carbon--gray-80;
155
157
  }
158
+ &:focus,
159
+ &:focus:active {
160
+ outline: 2px solid $carbon--white-0;
161
+ outline-offset: -2px;
162
+ }
156
163
  &:active {
157
164
  background-color: #3d3d3d;
158
- border-left: 1px solid $ui-05;
159
- border-right: 1px solid $ui-05;
165
+ border-left: 2px solid $ui-05;
166
+ border-right: 2px solid $ui-05;
160
167
  }
161
168
  }
162
169
 
163
170
  .header-button.switcher-button.switcher-button--open {
164
- border: 1px solid transparent;
165
- border-left: 1px solid $carbon--gray-80;
166
- border-bottom: 1px solid $carbon--gray-100;
171
+ border: 2px solid transparent;
172
+ border-left: 2px solid $carbon--gray-80;
173
+ border-bottom: 2px solid $carbon--gray-100;
167
174
  background-color: $carbon--gray-100;
168
175
  &:active {
169
- border-left: 1px solid $carbon--white-0;
176
+ border-left: 2px solid $carbon--white-0;
177
+ box-shadow: none;
178
+ border-color: $carbon--white-0;
170
179
  }
171
180
  }
172
-
173
- .header :global(a.bx--header__menu-item:hover) {
174
- color: $carbon--white-0;
175
- }
@@ -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';
@@ -24,7 +24,7 @@ const Layout = ({
24
24
  const is404 = children.key === null;
25
25
  const { isSwitcherEnabled } = useMetadata();
26
26
 
27
- useLayoutEffect(() => {
27
+ useEffect(() => {
28
28
  // eslint-disable-next-line global-require
29
29
  const scroll = require('smooth-scroll')('a[href*="#"]', {
30
30
  speed: 400,
@@ -30,6 +30,7 @@ import Title from '../Title';
30
30
  import { MiniCard, CardGroup } from '../MiniCard';
31
31
  import Sup from '../markdown/Sup';
32
32
  import Abbr from '../markdown/Abbr';
33
+ import SquareCard from '../SquareCard';
33
34
 
34
35
  const components = {
35
36
  wrapper: function Wrapper({ children, ...props }) {
@@ -81,6 +82,7 @@ const components = {
81
82
  Title,
82
83
  MiniCard,
83
84
  CardGroup,
85
+ SquareCard,
84
86
  };
85
87
 
86
88
  export default components;
@@ -36,6 +36,7 @@ const MiniCard = ({
36
36
  title,
37
37
  actionIcon,
38
38
  className,
39
+ linkProps,
39
40
  ...rest
40
41
  }) => {
41
42
  const cardContent = (
@@ -57,11 +58,11 @@ const MiniCard = ({
57
58
  }
58
59
 
59
60
  const cardContainer = isLink ? (
60
- <Link to={href} className={`${prefix}--tile--clickable`}>
61
+ <Link to={href} className={`${prefix}--tile--clickable`} {...linkProps}>
61
62
  {cardContent}
62
63
  </Link>
63
64
  ) : (
64
- <a href={href} className={`${prefix}--tile--clickable`}>
65
+ <a href={href} className={`${prefix}--tile--clickable`} {...linkProps}>
65
66
  {cardContent}
66
67
  </a>
67
68
  );
@@ -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
 
@@ -0,0 +1,175 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cx from 'classnames';
4
+ import { Link, withPrefix } from 'gatsby';
5
+ import {
6
+ Launch20,
7
+ Download20,
8
+ ArrowRight20,
9
+ Error20,
10
+ Email20,
11
+ } from '@carbon/icons-react';
12
+ import { settings } from 'carbon-components';
13
+ import { Column } from '../Grid';
14
+ import * as styles from './SquareCard.module.scss';
15
+
16
+ const { prefix } = settings;
17
+
18
+ export default class SquareCard extends React.Component {
19
+ render() {
20
+ const {
21
+ children,
22
+ href,
23
+ title,
24
+ smallTitle,
25
+ disabled,
26
+ bodyText,
27
+ helperText,
28
+ className,
29
+ actionIcon,
30
+ color,
31
+ ...rest
32
+ } = this.props;
33
+
34
+ let isLink;
35
+ if (href !== undefined) {
36
+ isLink = href.charAt(0) === '/';
37
+ }
38
+
39
+ const SquareCardClassNames = cx(className, styles.squareCard, {
40
+ [styles.disabled]: disabled,
41
+ [styles.darkMode]: color === 'dark',
42
+ });
43
+
44
+ const SquareCardTitleClassNames = cx(className, styles.title, {
45
+ [styles.titleSmall]: smallTitle,
46
+ });
47
+
48
+ const carbonTileclassNames = cx(
49
+ [`${prefix}--tile`],
50
+ [`${prefix}--tile--clickable`]
51
+ );
52
+
53
+ const aspectRatioClassNames = cx(
54
+ `${prefix}--aspect-ratio`,
55
+ `${prefix}--aspect-ratio--1x1`
56
+ );
57
+
58
+ const cardContent = (
59
+ <>
60
+ <h2 className={SquareCardTitleClassNames}>{title}</h2>
61
+ {bodyText ? <p className={styles.body}>{bodyText}</p> : null}
62
+ {helperText ? <p className={styles.helperText}>{helperText}</p> : null}
63
+ {children ? <div className={styles.helperIcon}>{children}</div> : null}
64
+ <div className={styles.actionIcon}>
65
+ {actionIcon === 'arrowRight' && !disabled ? (
66
+ <ArrowRight20 aria-label="Open resource" />
67
+ ) : null}
68
+ {actionIcon === 'launch' && !disabled ? (
69
+ <Launch20 aria-label="Open resource" />
70
+ ) : null}
71
+ {actionIcon === 'download' && !disabled ? (
72
+ <Download20 aria-label="Download" />
73
+ ) : null}
74
+ {actionIcon === 'email' && !disabled ? (
75
+ <Email20 aria-label="Email" />
76
+ ) : null}
77
+ {actionIcon === 'disabled' || disabled === true ? (
78
+ <Error20 aria-label="disabled" />
79
+ ) : null}
80
+ </div>
81
+ </>
82
+ );
83
+
84
+ let cardContainer;
85
+ if (disabled === true) {
86
+ cardContainer = <div className={carbonTileclassNames}>{cardContent}</div>;
87
+ } else if (isLink === true) {
88
+ cardContainer = (
89
+ <Link to={href} className={carbonTileclassNames} {...rest}>
90
+ {cardContent}
91
+ </Link>
92
+ );
93
+ } else {
94
+ cardContainer = (
95
+ <a href={href} className={carbonTileclassNames} {...rest}>
96
+ {cardContent}
97
+ </a>
98
+ );
99
+ }
100
+
101
+ return (
102
+ <Column
103
+ colMd={4}
104
+ colLg={4}
105
+ noGutterSm
106
+ className={SquareCardClassNames}
107
+ {...rest}>
108
+ <div className={aspectRatioClassNames}>
109
+ <div className={`${prefix}--aspect-ratio--object`}>
110
+ {cardContainer}
111
+ </div>
112
+ </div>
113
+ </Column>
114
+ );
115
+ }
116
+ }
117
+
118
+ SquareCard.propTypes = {
119
+ /**
120
+ * Use to set a pictogram
121
+ */
122
+ children: PropTypes.node,
123
+
124
+ /**
125
+ * Set url for card
126
+ */
127
+ href: PropTypes.string,
128
+
129
+ /**
130
+ * Large heading
131
+ */
132
+ title: PropTypes.string,
133
+
134
+ /**
135
+ * Use to enable the smaller heading
136
+ */
137
+ smallTitle: PropTypes.bool,
138
+
139
+ /**
140
+ * Action icon, default is Arrow Right, options are Launch, ArrowRight, Download, Error
141
+ */
142
+ actionIcon: PropTypes.string,
143
+
144
+ /**
145
+ * Use for disabled card
146
+ */
147
+ disabled: PropTypes.bool,
148
+
149
+ /**
150
+ * Body text
151
+ */
152
+ bodyText: PropTypes.string,
153
+
154
+ /**
155
+ * Helper text
156
+ */
157
+ helperText: PropTypes.string,
158
+
159
+ /**
160
+ * set to "dark" for dark background card
161
+ */
162
+ color: PropTypes.string,
163
+
164
+ /**
165
+ * Specify a custom class
166
+ */
167
+ className: PropTypes.string,
168
+ };
169
+
170
+ SquareCard.defaultProps = {
171
+ color: 'light',
172
+ disabled: false,
173
+ smallTitle: false,
174
+ actionIcon: 'arrowRight',
175
+ };
@@ -0,0 +1,172 @@
1
+ // Square Card Group
2
+ :global(.square-card-group) > * {
3
+ margin-bottom: 0;
4
+ }
5
+ .squareCard {
6
+ //overrides global vertical spacing
7
+ --space: 0;
8
+ border-top: 1px solid #e0e0e0;
9
+ border-left: 1px solid transparent;
10
+
11
+ @include carbon--breakpoint('md') {
12
+ border-left: 1px solid #e0e0e0;
13
+ }
14
+ }
15
+
16
+ :global(.square-card-group) .squareCard:first-child {
17
+ border-top: 0 solid transparent;
18
+ }
19
+ :global(.square-card-group) .squareCard:nth-child(2) {
20
+ @include carbon--breakpoint('md') {
21
+ border-top: 0 solid transparent;
22
+ }
23
+ }
24
+ :global(.square-card-group) .squareCard:nth-child(3) {
25
+ @include carbon--breakpoint('lg') {
26
+ border-top: 0 solid transparent;
27
+ }
28
+ }
29
+ :global(.square-card-group) .squareCard:nth-child(2n + 1) {
30
+ @include carbon--breakpoint('md') {
31
+ border-left: 1px solid transparent;
32
+ }
33
+
34
+ @include carbon--breakpoint('lg') {
35
+ border-left: 1px solid #e0e0e0;
36
+ }
37
+ }
38
+ :global(.square-card-group) .squareCard:nth-child(3n + 1) {
39
+ @include carbon--breakpoint('lg') {
40
+ border-left: 1px solid transparent;
41
+ }
42
+ }
43
+
44
+ .squareCard :global(.#{$prefix}--tile) {
45
+ height: 100%;
46
+ padding: $spacing-05 15% $spacing-05 $spacing-05;
47
+ position: relative;
48
+ text-decoration: none;
49
+
50
+ &::after {
51
+ position: absolute;
52
+ top: 0;
53
+ left: 0;
54
+ content: '';
55
+ width: calc(100% - 1px); // 1px to offset negative `left` positioning
56
+ height: calc(100% - 1px); // 1px to offset negative `top` positioning
57
+ outline: 3px solid transparent;
58
+ outline-offset: -3px;
59
+ transition: outline motion(standard, productive) $duration--fast-01;
60
+ }
61
+ }
62
+
63
+ .squareCard :global(.#{$prefix}--tile:focus) {
64
+ outline: none;
65
+
66
+ &::after {
67
+ outline: 3px solid $focus;
68
+ }
69
+ }
70
+
71
+ .title {
72
+ @include carbon--type-style('productive-heading-04');
73
+
74
+ text-decoration: none;
75
+ position: relative;
76
+ z-index: 1;
77
+
78
+ @include carbon--breakpoint-between('lg', 'xlg') {
79
+ @include carbon--type-style('productive-heading-03');
80
+ }
81
+ }
82
+
83
+ .titleSmall {
84
+ @include carbon--type-style('productive-heading-03');
85
+
86
+ @include carbon--breakpoint-between('lg', 'xlg') {
87
+ @include carbon--type-style('productive-heading-02');
88
+ }
89
+ }
90
+
91
+ .body {
92
+ @include carbon--type-style('body-short-02');
93
+
94
+ padding-top: $spacing-05;
95
+ }
96
+
97
+ .titleSmall + .body {
98
+ @include carbon--breakpoint-between('lg', 'xlg') {
99
+ padding-top: 0;
100
+ }
101
+ }
102
+
103
+ .helperText {
104
+ @include carbon--type-style('body-short-01');
105
+
106
+ position: absolute;
107
+ bottom: 1rem;
108
+ left: 1rem;
109
+ display: flex;
110
+ align-items: flex-end;
111
+ padding-right: $spacing-07;
112
+ margin-right: $spacing-06;
113
+ }
114
+
115
+ .helperIcon {
116
+ position: absolute;
117
+ bottom: 1rem;
118
+ left: 1rem;
119
+ min-width: 32px;
120
+ min-height: 32px;
121
+ display: flex;
122
+ align-items: flex-end;
123
+ }
124
+
125
+ .actionIcon {
126
+ position: absolute;
127
+ bottom: 1rem;
128
+ right: 1rem;
129
+ width: 20px;
130
+ height: 20px;
131
+ }
132
+
133
+ // Dark
134
+ .darkMode :global(.#{$prefix}--tile) {
135
+ background: $carbon--gray-90; //$ui-background for gray 90 theme
136
+ }
137
+
138
+ .darkMode :global(.#{$prefix}--tile:hover) {
139
+ background: $carbon--gray-80; //$hover-ui for gray 90 theme
140
+ }
141
+
142
+ .darkMode .title,
143
+ .darkMode .body,
144
+ .darkMode .helperText {
145
+ color: $text-04;
146
+ }
147
+
148
+ .darkMode .actionIcon svg,
149
+ .darkMode .helperIcon svg {
150
+ fill: $carbon--gray-10;
151
+ }
152
+
153
+ // Disabled
154
+ .disabled {
155
+ cursor: not-allowed;
156
+ }
157
+
158
+ .disabled :global(.#{$prefix}--tile:hover) {
159
+ background: $ui-01;
160
+ cursor: not-allowed;
161
+ }
162
+
163
+ .disabled .title,
164
+ .disabled .body,
165
+ .disabled .helperText {
166
+ color: $disabled-03;
167
+ }
168
+
169
+ .disabled .actionIcon svg,
170
+ .disabled .helperIcon svg {
171
+ fill: $disabled-02;
172
+ }
@@ -0,0 +1,3 @@
1
+ import SquareCard from './SquareCard';
2
+
3
+ export default SquareCard;
@@ -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/">
@@ -44,15 +44,14 @@
44
44
  .h3,
45
45
  .h4,
46
46
  .h5,
47
- .h6,
48
- .list {
49
- padding-right: 0;
47
+ .h6 {
48
+ padding-right: $spacing-05;
50
49
  margin-right: 0;
51
50
  margin-left: 0;
52
51
 
53
52
  @include carbon--breakpoint('md') {
54
- width: 100%;
55
- padding-right: 0;
53
+ width: 75%;
54
+ padding-right: $spacing-07;
56
55
  margin-right: 0;
57
56
  margin-left: 0;
58
57
  }
@@ -66,6 +65,23 @@
66
65
  --space: 0;
67
66
  }
68
67
 
68
+ .list {
69
+ padding-right: $spacing-05;
70
+ margin-right: 0;
71
+ margin-left: 0;
72
+
73
+ @include carbon--breakpoint('md') {
74
+ width: 100%;
75
+ padding-right: $spacing-07;
76
+ margin-right: 0;
77
+ margin-left: 0;
78
+ }
79
+
80
+ @include carbon--breakpoint('lg') {
81
+ width: 66.667%;
82
+ }
83
+ }
84
+
69
85
  //spacing exception for nested list items
70
86
  :global(.bx--list--nested) {
71
87
  --space: 0;
@@ -13,7 +13,7 @@
13
13
 
14
14
  @include carbon--breakpoint('lg') {
15
15
  padding-left: calc(
16
- 25% + 2rem
16
+ 25% + 1.5rem
17
17
  ); //2rem to account for 2rem left padding default on grid
18
18
  padding-right: 2rem;
19
19
  }
@@ -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