@automattic/vip-design-system 0.21.0 → 0.22.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/ScreenReaderText/ScreenReaderText.js +16 -13
- package/build/system/Table/Table.js +22 -4
- package/build/system/Table/Table.stories.js +5 -1
- package/package.json +1 -1
- package/src/system/ScreenReaderText/ScreenReaderText.js +14 -17
- package/src/system/Table/Table.js +25 -10
- package/src/system/Table/Table.stories.jsx +4 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.ScreenReaderText = void 0;
|
|
6
|
+
exports.screenReaderTextClass = exports.ScreenReaderText = void 0;
|
|
7
7
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
|
|
@@ -22,21 +22,24 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
22
22
|
/**
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
|
+
var screenReaderTextClass = {
|
|
26
|
+
border: 'none',
|
|
27
|
+
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
28
|
+
clipPath: 'inset(50%)',
|
|
29
|
+
height: '1px',
|
|
30
|
+
margin: '-1px',
|
|
31
|
+
overflow: 'hidden',
|
|
32
|
+
padding: '0',
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
width: '1px',
|
|
35
|
+
wordWrap: 'normal !important'
|
|
36
|
+
};
|
|
37
|
+
exports.screenReaderTextClass = screenReaderTextClass;
|
|
38
|
+
|
|
25
39
|
var ScreenReaderText = /*#__PURE__*/_react["default"].forwardRef(function (props, forwardRef) {
|
|
26
40
|
return (0, _jsxRuntime.jsx)("span", (0, _extends2["default"])({
|
|
27
41
|
className: "screen-reader-text",
|
|
28
|
-
sx:
|
|
29
|
-
border: 'none',
|
|
30
|
-
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
31
|
-
clipPath: 'inset(50%)',
|
|
32
|
-
height: '1px',
|
|
33
|
-
margin: '-1px',
|
|
34
|
-
overflow: 'hidden',
|
|
35
|
-
padding: '0',
|
|
36
|
-
position: 'absolute',
|
|
37
|
-
width: '1px',
|
|
38
|
-
wordWrap: 'normal !important'
|
|
39
|
-
}
|
|
42
|
+
sx: screenReaderTextClass
|
|
40
43
|
}, props, {
|
|
41
44
|
ref: forwardRef,
|
|
42
45
|
children: props.children
|
|
@@ -15,15 +15,26 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
17
|
|
|
18
|
+
var _ScreenReaderText = require("../ScreenReaderText/ScreenReaderText");
|
|
19
|
+
|
|
18
20
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
19
21
|
|
|
20
|
-
var _excluded = ["sx", "className"];
|
|
22
|
+
var _excluded = ["sx", "className", "children", "caption"];
|
|
21
23
|
|
|
22
24
|
var Table = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef) {
|
|
23
25
|
var sx = _ref.sx,
|
|
24
26
|
className = _ref.className,
|
|
27
|
+
children = _ref.children,
|
|
28
|
+
_ref$caption = _ref.caption,
|
|
29
|
+
caption = _ref$caption === void 0 ? null : _ref$caption,
|
|
25
30
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
26
|
-
|
|
31
|
+
|
|
32
|
+
if (!caption) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.warn('[A11Y] Please, add a caption to your table.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (0, _jsxRuntime.jsxs)("table", (0, _extends2["default"])({
|
|
27
38
|
sx: (0, _extends2["default"])({
|
|
28
39
|
width: '100%',
|
|
29
40
|
minWidth: 1024
|
|
@@ -32,12 +43,19 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef
|
|
|
32
43
|
cellSpacing: 0,
|
|
33
44
|
className: (0, _classnames["default"])('vip-table-component', className),
|
|
34
45
|
ref: forwardRef
|
|
35
|
-
}, props
|
|
46
|
+
}, props, {
|
|
47
|
+
children: [caption && (0, _jsxRuntime.jsx)("caption", {
|
|
48
|
+
sx: _ScreenReaderText.screenReaderTextClass,
|
|
49
|
+
children: caption
|
|
50
|
+
}), children]
|
|
51
|
+
}));
|
|
36
52
|
});
|
|
37
53
|
|
|
38
54
|
exports.Table = Table;
|
|
39
55
|
Table.displayName = 'Table';
|
|
40
56
|
Table.propTypes = {
|
|
41
57
|
sx: _propTypes["default"].object,
|
|
42
|
-
className: _propTypes["default"].any
|
|
58
|
+
className: _propTypes["default"].any,
|
|
59
|
+
children: _propTypes["default"].any,
|
|
60
|
+
caption: _propTypes["default"].string.isRequired
|
|
43
61
|
};
|
|
@@ -7,6 +7,8 @@ var _ = require("..");
|
|
|
7
7
|
|
|
8
8
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
9
|
|
|
10
|
+
/** @jsxImportSource theme-ui */
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Internal dependencies
|
|
12
14
|
*/
|
|
@@ -18,6 +20,7 @@ exports["default"] = _default;
|
|
|
18
20
|
|
|
19
21
|
var Default = function Default() {
|
|
20
22
|
return (0, _jsxRuntime.jsxs)(_.Table, {
|
|
23
|
+
caption: "Storybook Example",
|
|
21
24
|
children: [(0, _jsxRuntime.jsx)("thead", {
|
|
22
25
|
children: (0, _jsxRuntime.jsx)(_.TableRow, {
|
|
23
26
|
head: true,
|
|
@@ -55,7 +58,8 @@ var Default = function Default() {
|
|
|
55
58
|
color: 'muted'
|
|
56
59
|
},
|
|
57
60
|
children: "11th Mar 2020, 16:49:22"
|
|
58
|
-
}, "time")]
|
|
61
|
+
}, "time")],
|
|
62
|
+
gbc: true
|
|
59
63
|
}), (0, _jsxRuntime.jsxs)(_.TableRow, {
|
|
60
64
|
children: [(0, _jsxRuntime.jsx)(_.TableCell, {
|
|
61
65
|
sx: {
|
package/package.json
CHANGED
|
@@ -10,24 +10,21 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
export const screenReaderTextClass = {
|
|
14
|
+
border: 'none',
|
|
15
|
+
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
16
|
+
clipPath: 'inset(50%)',
|
|
17
|
+
height: '1px',
|
|
18
|
+
margin: '-1px',
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
padding: '0',
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
width: '1px',
|
|
23
|
+
wordWrap: 'normal !important',
|
|
24
|
+
};
|
|
25
|
+
|
|
13
26
|
export const ScreenReaderText = React.forwardRef( ( props, forwardRef ) => (
|
|
14
|
-
<span
|
|
15
|
-
className="screen-reader-text"
|
|
16
|
-
sx={ {
|
|
17
|
-
border: 'none',
|
|
18
|
-
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
19
|
-
clipPath: 'inset(50%)',
|
|
20
|
-
height: '1px',
|
|
21
|
-
margin: '-1px',
|
|
22
|
-
overflow: 'hidden',
|
|
23
|
-
padding: '0',
|
|
24
|
-
position: 'absolute',
|
|
25
|
-
width: '1px',
|
|
26
|
-
wordWrap: 'normal !important',
|
|
27
|
-
} }
|
|
28
|
-
{ ...props }
|
|
29
|
-
ref={ forwardRef }
|
|
30
|
-
>
|
|
27
|
+
<span className="screen-reader-text" sx={ screenReaderTextClass } { ...props } ref={ forwardRef }>
|
|
31
28
|
{ props.children }
|
|
32
29
|
</span>
|
|
33
30
|
) );
|
|
@@ -6,23 +6,38 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
+
import { screenReaderTextClass } from '../ScreenReaderText/ScreenReaderText';
|
|
9
10
|
|
|
10
|
-
const Table = React.forwardRef(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const Table = React.forwardRef(
|
|
12
|
+
( { sx, className, children, caption = null, ...props }, forwardRef ) => {
|
|
13
|
+
if ( ! caption ) {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn( '[A11Y] Please, add a caption to your table.' );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<table
|
|
20
|
+
sx={ { width: '100%', minWidth: 1024, ...sx } }
|
|
21
|
+
cellPadding={ 0 }
|
|
22
|
+
cellSpacing={ 0 }
|
|
23
|
+
className={ classNames( 'vip-table-component', className ) }
|
|
24
|
+
ref={ forwardRef }
|
|
25
|
+
{ ...props }
|
|
26
|
+
>
|
|
27
|
+
{ caption && <caption sx={ screenReaderTextClass }>{ caption }</caption> }
|
|
28
|
+
{ children }
|
|
29
|
+
</table>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
20
33
|
|
|
21
34
|
Table.displayName = 'Table';
|
|
22
35
|
|
|
23
36
|
Table.propTypes = {
|
|
24
37
|
sx: PropTypes.object,
|
|
25
38
|
className: PropTypes.any,
|
|
39
|
+
children: PropTypes.any,
|
|
40
|
+
caption: PropTypes.string.isRequired,
|
|
26
41
|
};
|
|
27
42
|
|
|
28
43
|
export { Table };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Internal dependencies
|
|
3
5
|
*/
|
|
@@ -9,7 +11,7 @@ export default {
|
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
export const Default = () => (
|
|
12
|
-
<Table>
|
|
14
|
+
<Table caption="Storybook Example">
|
|
13
15
|
<thead>
|
|
14
16
|
<TableRow head cells={ [ 'User', 'Command', 'Duration', 'Time' ] } />
|
|
15
17
|
</thead>
|
|
@@ -35,6 +37,7 @@ export const Default = () => (
|
|
|
35
37
|
11th Mar 2020, 16:49:22
|
|
36
38
|
</Text>,
|
|
37
39
|
] }
|
|
40
|
+
gbc
|
|
38
41
|
/>
|
|
39
42
|
<TableRow>
|
|
40
43
|
<TableCell sx={ { backgroundColor: 'lightgray' } }>
|