gatsby-theme-carbon 2.0.0 → 2.1.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/index.js +1 -0
- package/package.json +2 -1
- package/src/components/MDXProvider/defaultComponents.js +2 -0
- package/src/components/MiniCard/MiniCard.js +3 -2
- package/src/components/SquareCard/SquareCard.js +175 -0
- package/src/components/SquareCard/SquareCard.module.scss +172 -0
- package/src/components/SquareCard/index.js +3 -0
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.
|
|
3
|
+
"version": "2.1.0",
|
|
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",
|
|
@@ -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
|
);
|
|
@@ -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
|
+
}
|