gatsby-theme-carbon 2.0.0 → 2.1.3

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
@@ -1,5 +1,5 @@
1
1
  const path = require('path');
2
- const { uiBackground, interactive01 } = require('@carbon/elements');
2
+ const { gray100 } = require('@carbon/elements');
3
3
  const defaultLunrOptions = require('./config/lunr-options');
4
4
 
5
5
  const carbonThemes = {
@@ -162,8 +162,8 @@ module.exports = (themeOptions) => {
162
162
  name: 'Carbon Design Gatsby Theme',
163
163
  short_name: 'Gatsby Theme Carbon',
164
164
  start_url: '/',
165
- background_color: uiBackground,
166
- theme_color: interactive01,
165
+ background_color: gray100,
166
+ theme_color: gray100,
167
167
  display: 'browser',
168
168
  icon: iconPath
169
169
  ? path.resolve(iconPath)
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",
3
+ "version": "2.1.3",
4
4
  "main": "index.js",
5
5
  "author": "vpicone <vp@vincepic.one> (@vpicone)",
6
6
  "repository": {
@@ -25,6 +25,7 @@
25
25
  "@babel/core": "^7.14.6",
26
26
  "@carbon/elements": "^10.38.0",
27
27
  "@carbon/icons-react": "^10.35.0",
28
+ "@carbon/pictograms-react": "^11.14.0",
28
29
  "@carbon/themes": "^10.38.0",
29
30
  "@mdx-js/mdx": "^1.5.5",
30
31
  "@mdx-js/react": "^1.5.5",
@@ -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
- }
@@ -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
  );
@@ -19,7 +19,7 @@
19
19
  }
20
20
 
21
21
  .resource-card-group .#{$prefix}--resource-card--dark {
22
- border-top-color: $ui-03;
22
+ border-color: transparent !important;
23
23
  }
24
24
 
25
25
  .resource-card-group
@@ -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;
@@ -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
  }