@automattic/vip-design-system 2.7.0 → 2.8.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/build/system/Card/Card.d.ts +4 -2
- package/build/system/Card/Card.js +14 -11
- package/build/system/Card/Card.stories.d.ts +2 -1
- package/build/system/Card/Card.stories.js +24 -13
- package/build/system/Card/Card.test.js +2 -2
- package/build/system/Notice/Notice.js +40 -42
- package/build/system/Wizard/WizardStep.js +0 -1
- package/build/system/theme/index.d.ts +73 -57
- package/build/system/theme/index.js +25 -12
- package/package.json +1 -1
- package/src/system/Card/Card.stories.tsx +22 -12
- package/src/system/Card/Card.test.tsx +2 -2
- package/src/system/Card/Card.tsx +15 -10
- package/src/system/Notice/Notice.tsx +38 -39
- package/src/system/Wizard/WizardStep.tsx +0 -1
- package/src/system/theme/index.js +25 -12
|
@@ -8,13 +8,15 @@ import { BoxProps } from 'theme-ui';
|
|
|
8
8
|
export declare enum CardVariant {
|
|
9
9
|
'primary' = 0,
|
|
10
10
|
'secondary' = 1,
|
|
11
|
-
'
|
|
11
|
+
'notice' = 2,
|
|
12
|
+
'indent' = 3
|
|
12
13
|
}
|
|
13
14
|
export interface CardProps {
|
|
14
15
|
variant?: keyof typeof CardVariant;
|
|
15
16
|
sx?: BoxProps['sx'];
|
|
16
17
|
className?: Argument;
|
|
17
|
-
|
|
18
|
+
title?: string;
|
|
18
19
|
children?: React.ReactNode;
|
|
20
|
+
renderHeader?: (title?: string) => React.ReactNode;
|
|
19
21
|
}
|
|
20
22
|
export declare const Card: import("react").ForwardRefExoticComponent<CardProps & BoxProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -6,7 +6,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
6
6
|
var _react = require("react");
|
|
7
7
|
var _ = require("..");
|
|
8
8
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
|
-
var _excluded = ["variant", "
|
|
9
|
+
var _excluded = ["variant", "title", "renderHeader", "sx", "className", "children"];
|
|
10
10
|
/** @jsxImportSource theme-ui */
|
|
11
11
|
/**
|
|
12
12
|
* External dependencies
|
|
@@ -20,13 +20,15 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
20
20
|
var CardVariant = exports.CardVariant = /*#__PURE__*/function (CardVariant) {
|
|
21
21
|
CardVariant[CardVariant["primary"] = 0] = "primary";
|
|
22
22
|
CardVariant[CardVariant["secondary"] = 1] = "secondary";
|
|
23
|
-
CardVariant[CardVariant["
|
|
23
|
+
CardVariant[CardVariant["notice"] = 2] = "notice";
|
|
24
|
+
CardVariant[CardVariant["indent"] = 3] = "indent";
|
|
24
25
|
return CardVariant;
|
|
25
26
|
}({});
|
|
26
27
|
var Card = exports.Card = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
27
28
|
var _ref$variant = _ref.variant,
|
|
28
29
|
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
29
|
-
|
|
30
|
+
title = _ref.title,
|
|
31
|
+
renderHeader = _ref.renderHeader,
|
|
30
32
|
_ref$sx = _ref.sx,
|
|
31
33
|
sx = _ref$sx === void 0 ? {} : _ref$sx,
|
|
32
34
|
className = _ref.className,
|
|
@@ -34,21 +36,22 @@ var Card = exports.Card = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
34
36
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
35
37
|
return (0, _jsxRuntime.jsxs)(_.Box, _extends({
|
|
36
38
|
ref: ref,
|
|
37
|
-
sx:
|
|
38
|
-
// pass variant prop to sx
|
|
39
|
+
sx: {
|
|
39
40
|
variant: "cards." + variant
|
|
40
|
-
},
|
|
41
|
+
},
|
|
41
42
|
className: (0, _classnames["default"])('vip-card-component', className)
|
|
42
43
|
}, props, {
|
|
43
|
-
children: [
|
|
44
|
+
children: [renderHeader ? renderHeader(title) : '', title && !renderHeader && (0, _jsxRuntime.jsx)(_.Box, {
|
|
45
|
+
className: (0, _classnames["default"])('vip-card-header-component', className),
|
|
44
46
|
sx: {
|
|
45
47
|
variant: "cards." + variant + ".header"
|
|
46
48
|
},
|
|
47
|
-
children:
|
|
48
|
-
}), (0, _jsxRuntime.jsx)(
|
|
49
|
-
|
|
49
|
+
children: title
|
|
50
|
+
}), (0, _jsxRuntime.jsx)(_.Box, {
|
|
51
|
+
className: (0, _classnames["default"])('vip-card-body-component', className),
|
|
52
|
+
sx: _extends({
|
|
50
53
|
variant: "cards." + variant + ".children"
|
|
51
|
-
},
|
|
54
|
+
}, sx),
|
|
52
55
|
children: children
|
|
53
56
|
})]
|
|
54
57
|
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
1
2
|
/// <reference types="react" />
|
|
2
3
|
declare const _default: {
|
|
3
4
|
title: string;
|
|
@@ -6,7 +7,7 @@ declare const _default: {
|
|
|
6
7
|
export default _default;
|
|
7
8
|
export declare const Default: () => import("react").JSX.Element;
|
|
8
9
|
export declare const WithHeader: () => import("react").JSX.Element;
|
|
10
|
+
export declare const WithCustomHeader: () => import("react").JSX.Element;
|
|
9
11
|
export declare const DefaultSecondary: () => import("react").JSX.Element;
|
|
10
12
|
export declare const WithHeaderSecondary: () => import("react").JSX.Element;
|
|
11
13
|
export declare const DefaultIndent: () => import("react").JSX.Element;
|
|
12
|
-
export declare const WithHeaderIndent: () => import("react").JSX.Element;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.WithHeaderSecondary = exports.
|
|
4
|
+
exports["default"] = exports.WithHeaderSecondary = exports.WithHeader = exports.WithCustomHeader = exports.DefaultSecondary = exports.DefaultIndent = exports.Default = void 0;
|
|
5
5
|
var _ = require("..");
|
|
6
6
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
7
|
+
/** @jsxImportSource theme-ui */
|
|
10
8
|
var _default = exports["default"] = {
|
|
11
9
|
title: 'Card',
|
|
12
10
|
component: _.Card
|
|
@@ -18,10 +16,30 @@ var Default = exports.Default = function Default() {
|
|
|
18
16
|
};
|
|
19
17
|
var WithHeader = exports.WithHeader = function WithHeader() {
|
|
20
18
|
return (0, _jsxRuntime.jsx)(_.Card, {
|
|
21
|
-
|
|
19
|
+
title: "Header",
|
|
22
20
|
children: "This is a card with a header."
|
|
23
21
|
});
|
|
24
22
|
};
|
|
23
|
+
var WithCustomHeader = exports.WithCustomHeader = function WithCustomHeader() {
|
|
24
|
+
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
25
|
+
sx: {
|
|
26
|
+
maxWidth: 500
|
|
27
|
+
},
|
|
28
|
+
children: (0, _jsxRuntime.jsx)(_.Card, {
|
|
29
|
+
title: "Screenshot of a website",
|
|
30
|
+
renderHeader: function renderHeader(title) {
|
|
31
|
+
return (0, _jsxRuntime.jsx)("img", {
|
|
32
|
+
src: "https://s0.wp.com/mshots/v1/https://google.com/",
|
|
33
|
+
sx: {
|
|
34
|
+
width: '100%'
|
|
35
|
+
},
|
|
36
|
+
alt: title
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
children: "This is a card with a customized header content."
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
};
|
|
25
43
|
var DefaultSecondary = exports.DefaultSecondary = function DefaultSecondary() {
|
|
26
44
|
return (0, _jsxRuntime.jsx)(_.Card, {
|
|
27
45
|
variant: "secondary",
|
|
@@ -30,7 +48,7 @@ var DefaultSecondary = exports.DefaultSecondary = function DefaultSecondary() {
|
|
|
30
48
|
};
|
|
31
49
|
var WithHeaderSecondary = exports.WithHeaderSecondary = function WithHeaderSecondary() {
|
|
32
50
|
return (0, _jsxRuntime.jsx)(_.Card, {
|
|
33
|
-
|
|
51
|
+
title: "Header",
|
|
34
52
|
variant: "secondary",
|
|
35
53
|
children: "This is a card with a header."
|
|
36
54
|
});
|
|
@@ -40,11 +58,4 @@ var DefaultIndent = exports.DefaultIndent = function DefaultIndent() {
|
|
|
40
58
|
variant: "indent",
|
|
41
59
|
children: "Hello"
|
|
42
60
|
});
|
|
43
|
-
};
|
|
44
|
-
var WithHeaderIndent = exports.WithHeaderIndent = function WithHeaderIndent() {
|
|
45
|
-
return (0, _jsxRuntime.jsx)(_.Card, {
|
|
46
|
-
header: "Header",
|
|
47
|
-
variant: "indent",
|
|
48
|
-
children: "This is a card with a header."
|
|
49
|
-
});
|
|
50
61
|
};
|
|
@@ -61,13 +61,13 @@ describe('<Card />', function () {
|
|
|
61
61
|
}
|
|
62
62
|
}, _callee2);
|
|
63
63
|
})));
|
|
64
|
-
it('renders the Card component with a
|
|
64
|
+
it('renders the Card component with a title', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
65
65
|
var _render3, container;
|
|
66
66
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
67
67
|
while (1) switch (_context3.prev = _context3.next) {
|
|
68
68
|
case 0:
|
|
69
69
|
_render3 = (0, _react.render)((0, _jsxRuntime.jsx)(_Card.Card, {
|
|
70
|
-
|
|
70
|
+
title: "Card Header",
|
|
71
71
|
children: "Card text"
|
|
72
72
|
})), container = _render3.container;
|
|
73
73
|
expect(_react.screen.getByText('Card Header')).toBeInTheDocument();
|
|
@@ -25,7 +25,7 @@ var NoticeIcon = function NoticeIcon(_ref) {
|
|
|
25
25
|
color: color,
|
|
26
26
|
flex: '0 0 auto'
|
|
27
27
|
};
|
|
28
|
-
var size =
|
|
28
|
+
var size = 24;
|
|
29
29
|
switch (variant) {
|
|
30
30
|
case 'info':
|
|
31
31
|
return (0, _jsxRuntime.jsx)(_md.MdInfo, {
|
|
@@ -68,15 +68,17 @@ var Notice = exports.Notice = /*#__PURE__*/_react["default"].forwardRef(function
|
|
|
68
68
|
_ref2$variant = _ref2.variant,
|
|
69
69
|
variant = _ref2$variant === void 0 ? 'warning' : _ref2$variant,
|
|
70
70
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
71
|
-
return (0, _jsxRuntime.
|
|
71
|
+
return (0, _jsxRuntime.jsxs)(_.Card, _extends({
|
|
72
|
+
variant: "notice",
|
|
72
73
|
sx: _extends({
|
|
73
74
|
boxShadow: 'none',
|
|
74
75
|
borderRadius: 2,
|
|
75
76
|
bg: inline ? 'transparent' : "notice.background." + variant,
|
|
76
|
-
padding: inline ? 0 : 3,
|
|
77
77
|
color: "notice.text." + variant,
|
|
78
|
+
fontSize: 2,
|
|
78
79
|
p: {
|
|
79
|
-
color: "notice.text." + variant
|
|
80
|
+
color: "notice.text." + variant,
|
|
81
|
+
fontSize: 2
|
|
80
82
|
},
|
|
81
83
|
a: {
|
|
82
84
|
color: "notice.link." + variant + ".default",
|
|
@@ -89,54 +91,50 @@ var Notice = exports.Notice = /*#__PURE__*/_react["default"].forwardRef(function
|
|
|
89
91
|
'&:hover, &:focus': {
|
|
90
92
|
color: "notice.link." + variant + ".hover"
|
|
91
93
|
}
|
|
94
|
+
},
|
|
95
|
+
ul: {
|
|
96
|
+
pl: 5
|
|
92
97
|
}
|
|
93
98
|
}, sx),
|
|
94
99
|
className: (0, _classnames["default"])('vip-notice-component', className),
|
|
95
100
|
ref: forwardRef
|
|
96
101
|
}, props, {
|
|
97
|
-
children: (0, _jsxRuntime.
|
|
102
|
+
children: [(0, _jsxRuntime.jsx)(_.Box, {
|
|
98
103
|
sx: {
|
|
99
|
-
|
|
104
|
+
minWidth: '24px'
|
|
100
105
|
},
|
|
101
|
-
children:
|
|
106
|
+
children: (0, _jsxRuntime.jsxs)(_.Flex, {
|
|
102
107
|
sx: {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
flexDirection: 'column',
|
|
109
|
+
// the trick here is to have a flex column with the icon at the bottom and an empty div that fills the space
|
|
110
|
+
minHeight: '24px',
|
|
111
|
+
maxHeight: '32px',
|
|
112
|
+
// we're forcing the max height so that the icon is, at max, aligned between the first and the second line of text
|
|
113
|
+
alignItems: 'flex-end',
|
|
114
|
+
// we want the icon to be aligned to the bottom
|
|
115
|
+
height: '100%' // specifying the height will allow the box to match the height of the content.
|
|
106
116
|
},
|
|
107
|
-
children: (0, _jsxRuntime.
|
|
108
|
-
sx: {
|
|
109
|
-
flexDirection: 'column',
|
|
110
|
-
// the trick here is to have a flex column with the icon at the bottom and an empty div that fills the space
|
|
111
|
-
minHeight: '20px',
|
|
112
|
-
maxHeight: '32px',
|
|
113
|
-
// we're forcing the max height so that the icon is, at max, aligned between the first and the second line of text
|
|
114
|
-
alignItems: 'flex-end',
|
|
115
|
-
// we want the icon to be aligned to the bottom
|
|
116
|
-
height: '100%' // specifying the height will allow the box to match the height of the content.
|
|
117
|
-
},
|
|
118
|
-
children: [(0, _jsxRuntime.jsx)(_.Box, {
|
|
119
|
-
sx: {
|
|
120
|
-
flex: '1 100%' // we need this empty div to make the icon align to the bottom
|
|
121
|
-
}
|
|
122
|
-
}), (0, _jsxRuntime.jsx)(NoticeIcon, {
|
|
123
|
-
color: "notice.icon." + variant,
|
|
124
|
-
variant: variant
|
|
125
|
-
})]
|
|
126
|
-
})
|
|
127
|
-
}), (0, _jsxRuntime.jsxs)(_.Box, {
|
|
128
|
-
children: [title && (0, _jsxRuntime.jsx)(_.Heading, {
|
|
129
|
-
as: headingVariant,
|
|
117
|
+
children: [(0, _jsxRuntime.jsx)(_.Box, {
|
|
130
118
|
sx: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
119
|
+
flex: '1 100%' // we need this empty div to make the icon align to the bottom
|
|
120
|
+
}
|
|
121
|
+
}), (0, _jsxRuntime.jsx)(NoticeIcon, {
|
|
122
|
+
color: "notice.icon." + variant,
|
|
123
|
+
variant: variant
|
|
124
|
+
})]
|
|
125
|
+
})
|
|
126
|
+
}), (0, _jsxRuntime.jsxs)(_.Box, {
|
|
127
|
+
children: [title && (0, _jsxRuntime.jsx)(_.Heading, {
|
|
128
|
+
as: headingVariant,
|
|
129
|
+
sx: {
|
|
130
|
+
color: "notice.text." + variant,
|
|
131
|
+
mb: 0,
|
|
132
|
+
fontSize: 2,
|
|
133
|
+
fontWeight: 'bold'
|
|
134
|
+
},
|
|
135
|
+
children: title
|
|
136
|
+
}), children]
|
|
137
|
+
})]
|
|
140
138
|
}));
|
|
141
139
|
});
|
|
142
140
|
Notice.displayName = 'Notice';
|
|
@@ -70,7 +70,6 @@ var WizardStep = exports.WizardStep = /*#__PURE__*/_react["default"].forwardRef(
|
|
|
70
70
|
sx: {
|
|
71
71
|
boxShadow: active ? 'low' : 'none',
|
|
72
72
|
borderLeft: '2px solid',
|
|
73
|
-
p: 4,
|
|
74
73
|
backgroundColor: active ? 'background' : 'transparent',
|
|
75
74
|
borderRadius: 0,
|
|
76
75
|
borderBottom: active ? 'none' : '1px solid',
|
|
@@ -33,72 +33,86 @@ declare namespace _default {
|
|
|
33
33
|
}
|
|
34
34
|
export namespace cards {
|
|
35
35
|
namespace primary {
|
|
36
|
-
let borderRadius: number;
|
|
37
36
|
let backgroundColor: string;
|
|
37
|
+
let borderRadius: number;
|
|
38
38
|
let boxShadow: string;
|
|
39
39
|
namespace header {
|
|
40
40
|
let backgroundColor_1: string;
|
|
41
41
|
export { backgroundColor_1 as backgroundColor };
|
|
42
42
|
export let borderTopLeftRadius: number;
|
|
43
43
|
export let borderTopRightRadius: number;
|
|
44
|
-
export let
|
|
44
|
+
export let py: number;
|
|
45
|
+
export let px: number;
|
|
46
|
+
export let gap: number;
|
|
45
47
|
export let fontWeight: string;
|
|
46
48
|
export let display: string;
|
|
49
|
+
export let minHeight: number;
|
|
47
50
|
}
|
|
48
51
|
namespace children {
|
|
49
|
-
let
|
|
50
|
-
|
|
52
|
+
export let padding: number;
|
|
53
|
+
let gap_1: number;
|
|
54
|
+
export { gap_1 as gap };
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
namespace secondary {
|
|
54
|
-
let
|
|
55
|
-
export { borderRadius_1 as borderRadius };
|
|
56
|
-
let boxShadow_1: string;
|
|
57
|
-
export { boxShadow_1 as boxShadow };
|
|
58
|
+
export let variant: string;
|
|
58
59
|
export let border: string;
|
|
59
60
|
export let borderColor: string;
|
|
61
|
+
let boxShadow_1: string;
|
|
62
|
+
export { boxShadow_1 as boxShadow };
|
|
60
63
|
export namespace header_1 {
|
|
61
|
-
let
|
|
62
|
-
export {
|
|
63
|
-
let borderTopLeftRadius_1: number;
|
|
64
|
-
export { borderTopLeftRadius_1 as borderTopLeftRadius };
|
|
65
|
-
let borderTopRightRadius_1: number;
|
|
66
|
-
export { borderTopRightRadius_1 as borderTopRightRadius };
|
|
67
|
-
let p_2: number;
|
|
68
|
-
export { p_2 as p };
|
|
69
|
-
let fontWeight_1: string;
|
|
70
|
-
export { fontWeight_1 as fontWeight };
|
|
71
|
-
let display_1: string;
|
|
72
|
-
export { display_1 as display };
|
|
64
|
+
let variant_1: string;
|
|
65
|
+
export { variant_1 as variant };
|
|
73
66
|
}
|
|
74
67
|
export { header_1 as header };
|
|
75
68
|
export namespace children_1 {
|
|
76
|
-
let
|
|
77
|
-
export {
|
|
69
|
+
let variant_2: string;
|
|
70
|
+
export { variant_2 as variant };
|
|
78
71
|
}
|
|
79
72
|
export { children_1 as children };
|
|
80
73
|
}
|
|
74
|
+
namespace notice {
|
|
75
|
+
let boxShadow_2: string;
|
|
76
|
+
export { boxShadow_2 as boxShadow };
|
|
77
|
+
let borderRadius_1: number;
|
|
78
|
+
export { borderRadius_1 as borderRadius };
|
|
79
|
+
export let fontSize: number;
|
|
80
|
+
let padding_1: number;
|
|
81
|
+
export { padding_1 as padding };
|
|
82
|
+
export namespace children_2 {
|
|
83
|
+
export let height: string;
|
|
84
|
+
let display_1: string;
|
|
85
|
+
export { display_1 as display };
|
|
86
|
+
export let flexDirection: string;
|
|
87
|
+
let py_1: number;
|
|
88
|
+
export { py_1 as py };
|
|
89
|
+
let px_1: number;
|
|
90
|
+
export { px_1 as px };
|
|
91
|
+
let gap_2: number;
|
|
92
|
+
export { gap_2 as gap };
|
|
93
|
+
}
|
|
94
|
+
export { children_2 as children };
|
|
95
|
+
}
|
|
81
96
|
namespace indent {
|
|
82
97
|
let borderRadius_2: number;
|
|
83
98
|
export { borderRadius_2 as borderRadius };
|
|
84
|
-
let
|
|
85
|
-
export {
|
|
86
|
-
let
|
|
87
|
-
export {
|
|
99
|
+
let boxShadow_3: string;
|
|
100
|
+
export { boxShadow_3 as boxShadow };
|
|
101
|
+
let backgroundColor_2: string;
|
|
102
|
+
export { backgroundColor_2 as backgroundColor };
|
|
88
103
|
export namespace header_2 {
|
|
89
104
|
let display_2: string;
|
|
90
105
|
export { display_2 as display };
|
|
91
|
-
let
|
|
92
|
-
export {
|
|
93
|
-
let
|
|
94
|
-
export { p_4 as p };
|
|
106
|
+
let fontWeight_1: string;
|
|
107
|
+
export { fontWeight_1 as fontWeight };
|
|
108
|
+
export let p: number;
|
|
95
109
|
}
|
|
96
110
|
export { header_2 as header };
|
|
97
|
-
export namespace
|
|
98
|
-
let
|
|
99
|
-
export {
|
|
111
|
+
export namespace children_3 {
|
|
112
|
+
let p_1: number;
|
|
113
|
+
export { p_1 as p };
|
|
100
114
|
}
|
|
101
|
-
export {
|
|
115
|
+
export { children_3 as children };
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
118
|
export namespace buttons {
|
|
@@ -209,8 +223,9 @@ declare namespace _default {
|
|
|
209
223
|
};
|
|
210
224
|
export { border_1 as border };
|
|
211
225
|
export namespace text {
|
|
212
|
-
let
|
|
213
|
-
|
|
226
|
+
let variant_3: string;
|
|
227
|
+
export { variant_3 as variant };
|
|
228
|
+
export let color: string;
|
|
214
229
|
}
|
|
215
230
|
export let icon: {
|
|
216
231
|
variant: string;
|
|
@@ -1125,41 +1140,42 @@ declare namespace _default {
|
|
|
1125
1140
|
export let top: string;
|
|
1126
1141
|
export let left: string;
|
|
1127
1142
|
export let maxWidth: string;
|
|
1128
|
-
let
|
|
1129
|
-
export {
|
|
1130
|
-
let
|
|
1131
|
-
export {
|
|
1143
|
+
let backgroundColor_3: string;
|
|
1144
|
+
export { backgroundColor_3 as backgroundColor };
|
|
1145
|
+
let boxShadow_4: string;
|
|
1146
|
+
export { boxShadow_4 as boxShadow };
|
|
1132
1147
|
}
|
|
1133
1148
|
export namespace sidebar_1 {
|
|
1134
1149
|
let position_1: string;
|
|
1135
1150
|
export { position_1 as position };
|
|
1136
1151
|
let top_1: string;
|
|
1137
1152
|
export { top_1 as top };
|
|
1138
|
-
|
|
1153
|
+
let height_1: string;
|
|
1154
|
+
export { height_1 as height };
|
|
1139
1155
|
let left_1: string;
|
|
1140
1156
|
export { left_1 as left };
|
|
1141
1157
|
export let overflow: string;
|
|
1142
1158
|
export let margin: number;
|
|
1143
1159
|
let borderRadius_3: number;
|
|
1144
1160
|
export { borderRadius_3 as borderRadius };
|
|
1145
|
-
let
|
|
1146
|
-
export {
|
|
1147
|
-
let
|
|
1148
|
-
export {
|
|
1161
|
+
let boxShadow_5: string;
|
|
1162
|
+
export { boxShadow_5 as boxShadow };
|
|
1163
|
+
let backgroundColor_4: string;
|
|
1164
|
+
export { backgroundColor_4 as backgroundColor };
|
|
1149
1165
|
}
|
|
1150
1166
|
export { sidebar_1 as sidebar };
|
|
1151
1167
|
export namespace cover {
|
|
1152
1168
|
let position_2: string;
|
|
1153
1169
|
export { position_2 as position };
|
|
1154
|
-
let
|
|
1155
|
-
export {
|
|
1170
|
+
let backgroundColor_5: string;
|
|
1171
|
+
export { backgroundColor_5 as backgroundColor };
|
|
1156
1172
|
export let width: string;
|
|
1157
1173
|
let left_2: number;
|
|
1158
1174
|
export { left_2 as left };
|
|
1159
1175
|
let top_2: number;
|
|
1160
1176
|
export { top_2 as top };
|
|
1161
|
-
let
|
|
1162
|
-
export {
|
|
1177
|
+
let height_2: string;
|
|
1178
|
+
export { height_2 as height };
|
|
1163
1179
|
export let transform: string;
|
|
1164
1180
|
let borderRadius_4: number;
|
|
1165
1181
|
export { borderRadius_4 as borderRadius };
|
|
@@ -1215,12 +1231,12 @@ declare namespace _default {
|
|
|
1215
1231
|
namespace root {
|
|
1216
1232
|
export let fontFamily: string;
|
|
1217
1233
|
export let lineHeight: string;
|
|
1218
|
-
let
|
|
1219
|
-
export {
|
|
1234
|
+
let fontWeight_2: string;
|
|
1235
|
+
export { fontWeight_2 as fontWeight };
|
|
1220
1236
|
let color_1: string;
|
|
1221
1237
|
export { color_1 as color };
|
|
1222
|
-
let
|
|
1223
|
-
export {
|
|
1238
|
+
let backgroundColor_6: string;
|
|
1239
|
+
export { backgroundColor_6 as backgroundColor };
|
|
1224
1240
|
export let webkitFontSmoothing: string;
|
|
1225
1241
|
export let mozOsxFontmoothing: string;
|
|
1226
1242
|
export let a: {
|
|
@@ -1239,11 +1255,11 @@ declare namespace _default {
|
|
|
1239
1255
|
let fontFamily_1: string;
|
|
1240
1256
|
export { fontFamily_1 as fontFamily };
|
|
1241
1257
|
}
|
|
1242
|
-
export namespace
|
|
1258
|
+
export namespace p_2 {
|
|
1243
1259
|
let color_2: string;
|
|
1244
1260
|
export { color_2 as color };
|
|
1245
1261
|
}
|
|
1246
|
-
export {
|
|
1262
|
+
export { p_2 as p };
|
|
1247
1263
|
}
|
|
1248
1264
|
}
|
|
1249
1265
|
}
|
|
@@ -1252,8 +1268,8 @@ declare namespace outline {
|
|
|
1252
1268
|
export let outlineStyle: string;
|
|
1253
1269
|
export let outlineColor: any;
|
|
1254
1270
|
export let outlineWidth: string;
|
|
1255
|
-
let
|
|
1256
|
-
export {
|
|
1271
|
+
let boxShadow_6: string;
|
|
1272
|
+
export { boxShadow_6 as boxShadow };
|
|
1257
1273
|
}
|
|
1258
1274
|
declare namespace fonts {
|
|
1259
1275
|
let body_1: string;
|
|
@@ -250,36 +250,49 @@ export default {
|
|
|
250
250
|
|
|
251
251
|
cards: {
|
|
252
252
|
primary: {
|
|
253
|
-
borderRadius: 2,
|
|
254
253
|
backgroundColor: 'layer.2',
|
|
254
|
+
borderRadius: 2,
|
|
255
255
|
boxShadow: 'low',
|
|
256
256
|
header: {
|
|
257
257
|
backgroundColor: 'layer.1',
|
|
258
258
|
borderTopLeftRadius: 2,
|
|
259
259
|
borderTopRightRadius: 2,
|
|
260
|
-
|
|
260
|
+
py: 3,
|
|
261
|
+
px: 5,
|
|
262
|
+
gap: 2,
|
|
261
263
|
fontWeight: 'bold',
|
|
262
264
|
display: 'flex',
|
|
265
|
+
minHeight: 46,
|
|
263
266
|
},
|
|
264
267
|
children: {
|
|
265
|
-
|
|
268
|
+
padding: 5,
|
|
269
|
+
gap: 6,
|
|
266
270
|
},
|
|
267
271
|
},
|
|
268
272
|
secondary: {
|
|
269
|
-
|
|
270
|
-
boxShadow: 'none',
|
|
273
|
+
variant: 'cards.primary',
|
|
271
274
|
border: '1px solid',
|
|
272
275
|
borderColor: 'borders.2',
|
|
276
|
+
boxShadow: 'none',
|
|
273
277
|
header: {
|
|
274
|
-
|
|
275
|
-
borderTopLeftRadius: 2,
|
|
276
|
-
borderTopRightRadius: 2,
|
|
277
|
-
p: 3,
|
|
278
|
-
fontWeight: 'bold',
|
|
279
|
-
display: 'flex',
|
|
278
|
+
variant: 'cards.primary.header',
|
|
280
279
|
},
|
|
281
280
|
children: {
|
|
282
|
-
|
|
281
|
+
variant: 'cards.primary.children',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
notice: {
|
|
285
|
+
boxShadow: 'none',
|
|
286
|
+
borderRadius: 2,
|
|
287
|
+
fontSize: 2,
|
|
288
|
+
padding: 0,
|
|
289
|
+
children: {
|
|
290
|
+
height: '100%',
|
|
291
|
+
display: 'flex',
|
|
292
|
+
flexDirection: 'row',
|
|
293
|
+
py: 3,
|
|
294
|
+
px: 4,
|
|
295
|
+
gap: 4,
|
|
283
296
|
},
|
|
284
297
|
},
|
|
285
298
|
indent: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { Card } from '..';
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
import { Box, Card } from '..';
|
|
5
4
|
|
|
6
5
|
export default {
|
|
7
6
|
title: 'Card',
|
|
@@ -10,20 +9,31 @@ export default {
|
|
|
10
9
|
|
|
11
10
|
export const Default = () => <Card>Hello</Card>;
|
|
12
11
|
|
|
13
|
-
export const WithHeader = () => <Card
|
|
12
|
+
export const WithHeader = () => <Card title="Header">This is a card with a header.</Card>;
|
|
13
|
+
|
|
14
|
+
export const WithCustomHeader = () => (
|
|
15
|
+
<Box sx={ { maxWidth: 500 } }>
|
|
16
|
+
<Card
|
|
17
|
+
title="Screenshot of a website"
|
|
18
|
+
renderHeader={ title => (
|
|
19
|
+
<img
|
|
20
|
+
src={ `https://s0.wp.com/mshots/v1/https://google.com/` }
|
|
21
|
+
sx={ { width: '100%' } }
|
|
22
|
+
alt={ title }
|
|
23
|
+
/>
|
|
24
|
+
) }
|
|
25
|
+
>
|
|
26
|
+
This is a card with a customized header content.
|
|
27
|
+
</Card>
|
|
28
|
+
</Box>
|
|
29
|
+
);
|
|
14
30
|
|
|
15
31
|
export const DefaultSecondary = () => <Card variant="secondary">Hello</Card>;
|
|
16
32
|
|
|
17
33
|
export const WithHeaderSecondary = () => (
|
|
18
|
-
<Card
|
|
34
|
+
<Card title="Header" variant="secondary">
|
|
19
35
|
This is a card with a header.
|
|
20
36
|
</Card>
|
|
21
37
|
);
|
|
22
38
|
|
|
23
39
|
export const DefaultIndent = () => <Card variant="indent">Hello</Card>;
|
|
24
|
-
|
|
25
|
-
export const WithHeaderIndent = () => (
|
|
26
|
-
<Card header="Header" variant="indent">
|
|
27
|
-
This is a card with a header.
|
|
28
|
-
</Card>
|
|
29
|
-
);
|
|
@@ -30,8 +30,8 @@ describe( '<Card />', () => {
|
|
|
30
30
|
expect( await axe( container ) ).toHaveNoViolations();
|
|
31
31
|
} );
|
|
32
32
|
|
|
33
|
-
it( 'renders the Card component with a
|
|
34
|
-
const { container } = render( <Card
|
|
33
|
+
it( 'renders the Card component with a title', async () => {
|
|
34
|
+
const { container } = render( <Card title="Card Header">Card text</Card> );
|
|
35
35
|
|
|
36
36
|
expect( screen.getByText( 'Card Header' ) ).toBeInTheDocument();
|
|
37
37
|
|
package/src/system/Card/Card.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import { Box } from '..';
|
|
|
15
15
|
export enum CardVariant {
|
|
16
16
|
'primary',
|
|
17
17
|
'secondary',
|
|
18
|
+
'notice',
|
|
18
19
|
'indent',
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -22,44 +23,48 @@ export interface CardProps {
|
|
|
22
23
|
variant?: keyof typeof CardVariant;
|
|
23
24
|
sx?: BoxProps[ 'sx' ];
|
|
24
25
|
className?: Argument;
|
|
25
|
-
|
|
26
|
+
title?: string;
|
|
26
27
|
children?: React.ReactNode;
|
|
28
|
+
renderHeader?: ( title?: string ) => React.ReactNode;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
type CardBoxProps = CardProps & BoxProps;
|
|
30
32
|
|
|
31
33
|
export const Card = forwardRef< HTMLElement, CardBoxProps >(
|
|
32
34
|
(
|
|
33
|
-
{ variant = 'primary',
|
|
35
|
+
{ variant = 'primary', title, renderHeader, sx = {}, className, children, ...props }: CardProps,
|
|
34
36
|
ref: Ref< HTMLElement >
|
|
35
37
|
) => {
|
|
36
38
|
return (
|
|
37
39
|
<Box
|
|
38
40
|
ref={ ref }
|
|
39
41
|
sx={ {
|
|
40
|
-
// pass variant prop to sx
|
|
41
42
|
variant: `cards.${ variant }`,
|
|
42
|
-
...sx,
|
|
43
43
|
} }
|
|
44
44
|
className={ classNames( 'vip-card-component', className ) }
|
|
45
45
|
{ ...props }
|
|
46
46
|
>
|
|
47
|
-
{
|
|
48
|
-
|
|
47
|
+
{ renderHeader ? renderHeader( title ) : '' }
|
|
48
|
+
{ title && ! renderHeader && (
|
|
49
|
+
<Box
|
|
50
|
+
className={ classNames( 'vip-card-header-component', className ) }
|
|
49
51
|
sx={ {
|
|
50
52
|
variant: `cards.${ variant }.header`,
|
|
51
53
|
} }
|
|
52
54
|
>
|
|
53
|
-
{
|
|
54
|
-
</
|
|
55
|
+
{ title }
|
|
56
|
+
</Box>
|
|
55
57
|
) }
|
|
56
|
-
|
|
58
|
+
|
|
59
|
+
<Box
|
|
60
|
+
className={ classNames( 'vip-card-body-component', className ) }
|
|
57
61
|
sx={ {
|
|
58
62
|
variant: `cards.${ variant }.children`,
|
|
63
|
+
...sx,
|
|
59
64
|
} }
|
|
60
65
|
>
|
|
61
66
|
{ children }
|
|
62
|
-
</
|
|
67
|
+
</Box>
|
|
63
68
|
</Box>
|
|
64
69
|
);
|
|
65
70
|
}
|
|
@@ -31,7 +31,7 @@ type ColorVariants = 'warning' | 'error' | 'alert' | 'success' | 'info';
|
|
|
31
31
|
|
|
32
32
|
const NoticeIcon = ( { color, variant }: NoticeIconProps ) => {
|
|
33
33
|
const sx = { color, flex: '0 0 auto' };
|
|
34
|
-
const size =
|
|
34
|
+
const size = 24;
|
|
35
35
|
|
|
36
36
|
switch ( variant ) {
|
|
37
37
|
case 'info':
|
|
@@ -62,14 +62,16 @@ export const Notice = React.forwardRef< HTMLDivElement, NoticeProps >(
|
|
|
62
62
|
) => {
|
|
63
63
|
return (
|
|
64
64
|
<Card
|
|
65
|
+
variant="notice"
|
|
65
66
|
sx={ {
|
|
66
67
|
boxShadow: 'none',
|
|
67
68
|
borderRadius: 2,
|
|
68
69
|
bg: inline ? 'transparent' : `notice.background.${ variant }`,
|
|
69
|
-
padding: inline ? 0 : 3,
|
|
70
70
|
color: `notice.text.${ variant }`,
|
|
71
|
+
fontSize: 2,
|
|
71
72
|
p: {
|
|
72
73
|
color: `notice.text.${ variant }`,
|
|
74
|
+
fontSize: 2,
|
|
73
75
|
},
|
|
74
76
|
a: {
|
|
75
77
|
color: `notice.link.${ variant }.default`,
|
|
@@ -83,52 +85,49 @@ export const Notice = React.forwardRef< HTMLDivElement, NoticeProps >(
|
|
|
83
85
|
color: `notice.link.${ variant }.hover`,
|
|
84
86
|
},
|
|
85
87
|
},
|
|
88
|
+
ul: {
|
|
89
|
+
pl: 5,
|
|
90
|
+
},
|
|
86
91
|
...sx,
|
|
87
92
|
} }
|
|
88
93
|
className={ classNames( 'vip-notice-component', className ) }
|
|
89
94
|
ref={ forwardRef }
|
|
90
95
|
{ ...props }
|
|
91
96
|
>
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
<Box sx={ { minWidth: '24px' } }>
|
|
98
|
+
<Flex
|
|
99
|
+
sx={ {
|
|
100
|
+
flexDirection: 'column', // the trick here is to have a flex column with the icon at the bottom and an empty div that fills the space
|
|
101
|
+
minHeight: '24px',
|
|
102
|
+
maxHeight: '32px', // we're forcing the max height so that the icon is, at max, aligned between the first and the second line of text
|
|
103
|
+
alignItems: 'flex-end', // we want the icon to be aligned to the bottom
|
|
104
|
+
height: '100%', // specifying the height will allow the box to match the height of the content.
|
|
105
|
+
} }
|
|
106
|
+
>
|
|
107
|
+
<Box
|
|
108
|
+
sx={ {
|
|
109
|
+
flex: '1 100%', // we need this empty div to make the icon align to the bottom
|
|
110
|
+
} }
|
|
111
|
+
></Box>
|
|
112
|
+
<NoticeIcon color={ `notice.icon.${ variant }` } variant={ variant } />
|
|
113
|
+
</Flex>
|
|
114
|
+
</Box>
|
|
115
|
+
<Box>
|
|
116
|
+
{ title && (
|
|
117
|
+
<Heading
|
|
118
|
+
as={ headingVariant }
|
|
99
119
|
sx={ {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
height: '100%', // specifying the height will allow the box to match the height of the content.
|
|
120
|
+
color: `notice.text.${ variant }`,
|
|
121
|
+
mb: 0,
|
|
122
|
+
fontSize: 2,
|
|
123
|
+
fontWeight: 'bold',
|
|
105
124
|
} }
|
|
106
125
|
>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
<NoticeIcon color={ `notice.icon.${ variant }` } variant={ variant } />
|
|
113
|
-
</Flex>
|
|
114
|
-
</Box>
|
|
115
|
-
<Box>
|
|
116
|
-
{ title && (
|
|
117
|
-
<Heading
|
|
118
|
-
as={ headingVariant }
|
|
119
|
-
sx={ {
|
|
120
|
-
color: `notice.text.${ variant }`,
|
|
121
|
-
mb: 0,
|
|
122
|
-
fontSize: 2,
|
|
123
|
-
fontWeight: 'bold',
|
|
124
|
-
} }
|
|
125
|
-
>
|
|
126
|
-
{ title }
|
|
127
|
-
</Heading>
|
|
128
|
-
) }
|
|
129
|
-
{ children }
|
|
130
|
-
</Box>
|
|
131
|
-
</Flex>
|
|
126
|
+
{ title }
|
|
127
|
+
</Heading>
|
|
128
|
+
) }
|
|
129
|
+
{ children }
|
|
130
|
+
</Box>
|
|
132
131
|
</Card>
|
|
133
132
|
);
|
|
134
133
|
}
|
|
@@ -88,7 +88,6 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
|
|
|
88
88
|
sx={ {
|
|
89
89
|
boxShadow: active ? 'low' : 'none',
|
|
90
90
|
borderLeft: '2px solid',
|
|
91
|
-
p: 4,
|
|
92
91
|
backgroundColor: active ? 'background' : 'transparent',
|
|
93
92
|
borderRadius: 0,
|
|
94
93
|
borderBottom: active ? 'none' : '1px solid',
|
|
@@ -250,36 +250,49 @@ export default {
|
|
|
250
250
|
|
|
251
251
|
cards: {
|
|
252
252
|
primary: {
|
|
253
|
-
borderRadius: 2,
|
|
254
253
|
backgroundColor: 'layer.2',
|
|
254
|
+
borderRadius: 2,
|
|
255
255
|
boxShadow: 'low',
|
|
256
256
|
header: {
|
|
257
257
|
backgroundColor: 'layer.1',
|
|
258
258
|
borderTopLeftRadius: 2,
|
|
259
259
|
borderTopRightRadius: 2,
|
|
260
|
-
|
|
260
|
+
py: 3,
|
|
261
|
+
px: 5,
|
|
262
|
+
gap: 2,
|
|
261
263
|
fontWeight: 'bold',
|
|
262
264
|
display: 'flex',
|
|
265
|
+
minHeight: 46,
|
|
263
266
|
},
|
|
264
267
|
children: {
|
|
265
|
-
|
|
268
|
+
padding: 5,
|
|
269
|
+
gap: 6,
|
|
266
270
|
},
|
|
267
271
|
},
|
|
268
272
|
secondary: {
|
|
269
|
-
|
|
270
|
-
boxShadow: 'none',
|
|
273
|
+
variant: 'cards.primary',
|
|
271
274
|
border: '1px solid',
|
|
272
275
|
borderColor: 'borders.2',
|
|
276
|
+
boxShadow: 'none',
|
|
273
277
|
header: {
|
|
274
|
-
|
|
275
|
-
borderTopLeftRadius: 2,
|
|
276
|
-
borderTopRightRadius: 2,
|
|
277
|
-
p: 3,
|
|
278
|
-
fontWeight: 'bold',
|
|
279
|
-
display: 'flex',
|
|
278
|
+
variant: 'cards.primary.header',
|
|
280
279
|
},
|
|
281
280
|
children: {
|
|
282
|
-
|
|
281
|
+
variant: 'cards.primary.children',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
notice: {
|
|
285
|
+
boxShadow: 'none',
|
|
286
|
+
borderRadius: 2,
|
|
287
|
+
fontSize: 2,
|
|
288
|
+
padding: 0,
|
|
289
|
+
children: {
|
|
290
|
+
height: '100%',
|
|
291
|
+
display: 'flex',
|
|
292
|
+
flexDirection: 'row',
|
|
293
|
+
py: 3,
|
|
294
|
+
px: 4,
|
|
295
|
+
gap: 4,
|
|
283
296
|
},
|
|
284
297
|
},
|
|
285
298
|
indent: {
|