@spaced-out/ui-design-system 0.1.48-beta.1 → 0.1.49
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/.cspell/custom-words.txt +2 -1
- package/CHANGELOG.md +14 -0
- package/lib/components/Breadcrumbs/BreadcrumbLink/BreadcrumbLink.js +43 -0
- package/lib/components/Breadcrumbs/BreadcrumbLink/BreadcrumbLink.js.flow +58 -0
- package/lib/components/Breadcrumbs/BreadcrumbLink/BreadcrumbLink.module.css +28 -0
- package/lib/components/Breadcrumbs/BreadcrumbLink/index.js +16 -0
- package/lib/components/Breadcrumbs/BreadcrumbLink/index.js.flow +3 -0
- package/lib/components/Breadcrumbs/Breadcrumbs.js +43 -0
- package/lib/components/Breadcrumbs/Breadcrumbs.js.flow +59 -0
- package/lib/components/Breadcrumbs/Breadcrumbs.module.css +14 -0
- package/lib/components/Breadcrumbs/index.js +27 -0
- package/lib/components/Breadcrumbs/index.js.flow +4 -0
- package/lib/components/Chip/Chip.js +2 -1
- package/lib/components/Chip/Chip.js.flow +1 -0
- package/lib/components/Chip/Chip.module.css +10 -6
- package/lib/components/Link/Link.js +39 -3
- package/lib/components/Link/Link.js.flow +76 -10
- package/lib/components/PageTitle/PageTitle.js +6 -0
- package/lib/components/PageTitle/PageTitle.js.flow +6 -0
- package/lib/components/index.js +11 -0
- package/lib/components/index.js.flow +1 -0
- package/package.json +1 -1
package/.cspell/custom-words.txt
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.49](https://github.com/spaced-out/ui-design-system/compare/v0.1.48...v0.1.49) (2023-09-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* breadcrumbs component and link accessibility fixes ([#141](https://github.com/spaced-out/ui-design-system/issues/141)) ([609762e](https://github.com/spaced-out/ui-design-system/commit/609762e55cddb1a50fb56d17e4dcc31fdbcf1cd1))
|
|
11
|
+
|
|
12
|
+
### [0.1.48](https://github.com/spaced-out/ui-design-system/compare/v0.1.48-beta.1...v0.1.48) (2023-09-12)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* added jobs page name in PageTitle component ([#143](https://github.com/spaced-out/ui-design-system/issues/143)) ([904a124](https://github.com/spaced-out/ui-design-system/commit/904a1244af6863b70b39e5c07aa6295b09f0e434))
|
|
18
|
+
|
|
5
19
|
### [0.1.48-beta.1](https://github.com/spaced-out/ui-design-system/compare/v0.1.48-beta.0...v0.1.48-beta.1) (2023-09-11)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BreadcrumbLink = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../../utils/classify"));
|
|
9
|
+
var _Link = require("../../Link");
|
|
10
|
+
var _BreadcrumbLinkModule = _interopRequireDefault(require("./BreadcrumbLink.module.css"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
const BreadcrumbLink = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
16
|
+
let {
|
|
17
|
+
id,
|
|
18
|
+
className,
|
|
19
|
+
as,
|
|
20
|
+
underline = false,
|
|
21
|
+
isActive,
|
|
22
|
+
onClick,
|
|
23
|
+
href,
|
|
24
|
+
to,
|
|
25
|
+
...props
|
|
26
|
+
} = _ref;
|
|
27
|
+
return /*#__PURE__*/React.createElement(_Link.Link, _extends({}, props, {
|
|
28
|
+
to: to ?? href,
|
|
29
|
+
"data-testid": "BreadcrumbLink",
|
|
30
|
+
ref: ref,
|
|
31
|
+
as: as || 'subTitleExtraSmall',
|
|
32
|
+
underline: underline,
|
|
33
|
+
disabled: isActive,
|
|
34
|
+
className: (0, _classify.default)(_BreadcrumbLinkModule.default.breadcrumbLink, {
|
|
35
|
+
[_BreadcrumbLinkModule.default.active]: isActive ?? window.location.href.includes(to ?? href)
|
|
36
|
+
}, className),
|
|
37
|
+
onClick: e => {
|
|
38
|
+
onClick?.(e, id);
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
exports.BreadcrumbLink = BreadcrumbLink;
|
|
43
|
+
BreadcrumbLink.displayName = 'BreadcrumbLink';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../../utils/classify';
|
|
6
|
+
import type {LinkProps} from '../../Link';
|
|
7
|
+
import {Link} from '../../Link';
|
|
8
|
+
|
|
9
|
+
import css from './BreadcrumbLink.module.css';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export type BreadcrumbLinkProps = {
|
|
13
|
+
...LinkProps,
|
|
14
|
+
isActive?: boolean,
|
|
15
|
+
id: string,
|
|
16
|
+
onClick?: (SyntheticEvent<HTMLElement>, id: string) => mixed,
|
|
17
|
+
...
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const BreadcrumbLink: React$AbstractComponent<
|
|
21
|
+
BreadcrumbLinkProps,
|
|
22
|
+
?HTMLAnchorElement,
|
|
23
|
+
> = React.forwardRef<BreadcrumbLinkProps, ?HTMLAnchorElement>(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
id,
|
|
27
|
+
className,
|
|
28
|
+
as,
|
|
29
|
+
underline = false,
|
|
30
|
+
isActive,
|
|
31
|
+
onClick,
|
|
32
|
+
href,
|
|
33
|
+
to,
|
|
34
|
+
...props
|
|
35
|
+
}: BreadcrumbLinkProps,
|
|
36
|
+
ref,
|
|
37
|
+
) => (
|
|
38
|
+
<Link
|
|
39
|
+
{...props}
|
|
40
|
+
to={to ?? href}
|
|
41
|
+
data-testid="BreadcrumbLink"
|
|
42
|
+
ref={ref}
|
|
43
|
+
as={as || 'subTitleExtraSmall'}
|
|
44
|
+
underline={underline}
|
|
45
|
+
disabled={isActive}
|
|
46
|
+
className={classify(
|
|
47
|
+
css.breadcrumbLink,
|
|
48
|
+
{[css.active]: isActive ?? window.location.href.includes(to ?? href)},
|
|
49
|
+
className,
|
|
50
|
+
)}
|
|
51
|
+
onClick={(e) => {
|
|
52
|
+
onClick?.(e, id);
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
BreadcrumbLink.displayName = 'BreadcrumbLink';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@value (
|
|
2
|
+
colorTextSecondary,
|
|
3
|
+
colorTextPrimary,
|
|
4
|
+
colorTextClickable
|
|
5
|
+
) from '../../../styles/variables/_color.css';
|
|
6
|
+
|
|
7
|
+
.breadcrumbLink {
|
|
8
|
+
display: flex;
|
|
9
|
+
color: colorTextSecondary;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.breadcrumbLink:hover {
|
|
13
|
+
color: colorTextClickable;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.breadcrumbLink:focus,
|
|
17
|
+
.active {
|
|
18
|
+
color: colorTextPrimary;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.active {
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
cursor: initial;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.active:hover {
|
|
27
|
+
color: colorTextPrimary;
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _BreadcrumbLink = require("./BreadcrumbLink");
|
|
7
|
+
Object.keys(_BreadcrumbLink).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _BreadcrumbLink[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _BreadcrumbLink[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Breadcrumbs = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
9
|
+
var _Icon = require("../Icon");
|
|
10
|
+
var _BreadcrumbsModule = _interopRequireDefault(require("./Breadcrumbs.module.css"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
|
|
15
|
+
const BreadcrumbSeparator = () => /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
16
|
+
className: _BreadcrumbsModule.default.separator,
|
|
17
|
+
name: "chevron-right",
|
|
18
|
+
size: "small",
|
|
19
|
+
color: "secondary"
|
|
20
|
+
});
|
|
21
|
+
const Breadcrumbs = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
22
|
+
let {
|
|
23
|
+
classNames,
|
|
24
|
+
children,
|
|
25
|
+
linkComponent
|
|
26
|
+
} = _ref;
|
|
27
|
+
const total = React.Children.count(children);
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
ref: ref,
|
|
30
|
+
"data-testid": "Breadcrumbs",
|
|
31
|
+
className: (0, _classify.default)(_BreadcrumbsModule.default.wrapper, classNames?.wrapper)
|
|
32
|
+
}, React.Children.map(children, (child, idx) =>
|
|
33
|
+
/*#__PURE__*/
|
|
34
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
35
|
+
React.createElement(React.Fragment, {
|
|
36
|
+
key: `crumb-${idx}`
|
|
37
|
+
}, /*#__PURE__*/React.isValidElement(child) && child?.type?.displayName === 'BreadcrumbLink' ? /*#__PURE__*/React.cloneElement(child, {
|
|
38
|
+
linkComponent
|
|
39
|
+
}) : child, idx < total - 1 && /*#__PURE__*/React.createElement(BreadcrumbSeparator, {
|
|
40
|
+
"aria-hidden": true
|
|
41
|
+
}))));
|
|
42
|
+
});
|
|
43
|
+
exports.Breadcrumbs = Breadcrumbs;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import classify from '../../utils/classify';
|
|
6
|
+
import {Icon} from '../Icon';
|
|
7
|
+
import type {BaseLinkProps} from '../Link';
|
|
8
|
+
|
|
9
|
+
import css from './Breadcrumbs.module.css';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
13
|
+
|
|
14
|
+
export type BreadcrumbsProps = {
|
|
15
|
+
classNames?: ClassNames,
|
|
16
|
+
children: React.Node,
|
|
17
|
+
linkComponent?: React.AbstractComponent<BaseLinkProps, ?HTMLAnchorElement>,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const BreadcrumbSeparator = (): React.Node => (
|
|
21
|
+
<Icon
|
|
22
|
+
className={css.separator}
|
|
23
|
+
name="chevron-right"
|
|
24
|
+
size="small"
|
|
25
|
+
color="secondary"
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const Breadcrumbs: React$AbstractComponent<
|
|
30
|
+
BreadcrumbsProps,
|
|
31
|
+
HTMLDivElement,
|
|
32
|
+
> = React.forwardRef<BreadcrumbsProps, HTMLDivElement>(
|
|
33
|
+
({classNames, children, linkComponent}: BreadcrumbsProps, ref) => {
|
|
34
|
+
const total = React.Children.count(children);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
ref={ref}
|
|
39
|
+
data-testid="Breadcrumbs"
|
|
40
|
+
className={classify(css.wrapper, classNames?.wrapper)}
|
|
41
|
+
>
|
|
42
|
+
{React.Children.map(children, (child, idx) => (
|
|
43
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
44
|
+
<React.Fragment key={`crumb-${idx}`}>
|
|
45
|
+
{/*add linkComponent to BreadcrumbLinks only,
|
|
46
|
+
otherwise return original element */}
|
|
47
|
+
{React.isValidElement(child) &&
|
|
48
|
+
child?.type?.displayName === 'BreadcrumbLink'
|
|
49
|
+
? React.cloneElement(child, {linkComponent})
|
|
50
|
+
: child}
|
|
51
|
+
|
|
52
|
+
{/*Add Separator*/}
|
|
53
|
+
{idx < total - 1 && <BreadcrumbSeparator aria-hidden />}
|
|
54
|
+
</React.Fragment>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _BreadcrumbLink = require("./BreadcrumbLink");
|
|
7
|
+
Object.keys(_BreadcrumbLink).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _BreadcrumbLink[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _BreadcrumbLink[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _Breadcrumbs = require("./Breadcrumbs");
|
|
18
|
+
Object.keys(_Breadcrumbs).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _Breadcrumbs[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _Breadcrumbs[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -53,7 +53,8 @@ const Chip = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
53
53
|
[_ChipModule.default.small]: size === 'small',
|
|
54
54
|
[_ChipModule.default.dismissable]: dismissable,
|
|
55
55
|
[_ChipModule.default.withIcon]: !!iconName && size !== 'small',
|
|
56
|
-
[_ChipModule.default.disabled]: disabled
|
|
56
|
+
[_ChipModule.default.disabled]: disabled,
|
|
57
|
+
[_ChipModule.default.noHoverState]: showStatusIndicator
|
|
57
58
|
}, classNames?.wrapper),
|
|
58
59
|
onClick: onClick
|
|
59
60
|
}), showStatusIndicator && size !== 'small' && /*#__PURE__*/React.createElement(_StatusIndicator.StatusIndicator, {
|
|
@@ -91,6 +91,7 @@ export const Chip: React$AbstractComponent<ChipProps, HTMLDivElement> =
|
|
|
91
91
|
[css.dismissable]: dismissable,
|
|
92
92
|
[css.withIcon]: !!iconName && size !== 'small',
|
|
93
93
|
[css.disabled]: disabled,
|
|
94
|
+
[css.noHoverState]: showStatusIndicator,
|
|
94
95
|
},
|
|
95
96
|
classNames?.wrapper,
|
|
96
97
|
)}
|
|
@@ -55,7 +55,11 @@
|
|
|
55
55
|
background-color: colorNeutralLightest;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
.
|
|
58
|
+
.noHoverState {
|
|
59
|
+
cursor: initial;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.primary:not(.noHoverState):hover {
|
|
59
63
|
background-color: colorNeutralLight;
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -63,7 +67,7 @@
|
|
|
63
67
|
background-color: colorInformationLightest;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
.information:hover {
|
|
70
|
+
.information:not(.noHoverState):hover {
|
|
67
71
|
background-color: colorInformationLight;
|
|
68
72
|
}
|
|
69
73
|
|
|
@@ -71,7 +75,7 @@
|
|
|
71
75
|
background-color: colorSuccessLightest;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
.success:hover {
|
|
78
|
+
.success:not(.noHoverState):hover {
|
|
75
79
|
background-color: colorSuccessLight;
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -79,7 +83,7 @@
|
|
|
79
83
|
background-color: colorWarningLightest;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
.warning:hover {
|
|
86
|
+
.warning:not(.noHoverState):hover {
|
|
83
87
|
background-color: colorWarningLight;
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -87,7 +91,7 @@
|
|
|
87
91
|
background-color: colorDangerLightest;
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
.danger:hover {
|
|
94
|
+
.danger:not(.noHoverState):hover {
|
|
91
95
|
background-color: colorDangerLight;
|
|
92
96
|
}
|
|
93
97
|
|
|
@@ -96,7 +100,7 @@
|
|
|
96
100
|
background-color: colorFillNone;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
.secondary:hover {
|
|
103
|
+
.secondary:not(.noHoverState):hover {
|
|
100
104
|
background-color: colorGrayLightest;
|
|
101
105
|
}
|
|
102
106
|
|
|
@@ -63,6 +63,8 @@ const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
63
63
|
underline = true,
|
|
64
64
|
tabIndex = 0,
|
|
65
65
|
disabled,
|
|
66
|
+
onClick,
|
|
67
|
+
linkComponent: LinkComponent = DefaultLink,
|
|
66
68
|
...props
|
|
67
69
|
} = _ref;
|
|
68
70
|
const linkRef = React.useRef(null);
|
|
@@ -72,14 +74,48 @@ const Link = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
72
74
|
linkRef.current?.blur();
|
|
73
75
|
}
|
|
74
76
|
}, [disabled]);
|
|
75
|
-
|
|
77
|
+
const handleClick = event => {
|
|
78
|
+
if (disabled) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
onClick?.(event);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* By spec anchor tag wont call onClick on enter key press when the element is focussed
|
|
87
|
+
* as a workaround we would need to listen to key press event and call onClick
|
|
88
|
+
* manually, one workaround to avoid this is to have empty href along with onClick
|
|
89
|
+
* but that would break accessibility
|
|
90
|
+
*/
|
|
91
|
+
const handleKeyPress = event => {
|
|
92
|
+
if (event.key === 'Enter' && onClick) {
|
|
93
|
+
handleClick(event);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return /*#__PURE__*/React.createElement(LinkComponent, _extends({}, props, {
|
|
76
97
|
tabIndex: disabled ? -1 : tabIndex,
|
|
77
98
|
ref: linkRef,
|
|
78
99
|
"data-testid": "Link",
|
|
79
100
|
className: (0, _classify.default)(_typographyModule.default.link, _typographyModule.default[as], _typographyModule.default[color], {
|
|
80
101
|
[_typographyModule.default.underline]: underline,
|
|
81
102
|
[_typographyModule.default.disabled]: disabled
|
|
82
|
-
}, className)
|
|
103
|
+
}, className),
|
|
104
|
+
onClick: handleClick,
|
|
105
|
+
onKeyPress: handleKeyPress
|
|
83
106
|
}), children);
|
|
84
107
|
});
|
|
85
|
-
exports.Link = Link;
|
|
108
|
+
exports.Link = Link;
|
|
109
|
+
const DefaultLink = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
110
|
+
let {
|
|
111
|
+
children,
|
|
112
|
+
href,
|
|
113
|
+
to,
|
|
114
|
+
...props
|
|
115
|
+
} = _ref2;
|
|
116
|
+
const resolvedHref = to ?? href;
|
|
117
|
+
return /*#__PURE__*/React.createElement("a", _extends({}, props, {
|
|
118
|
+
href: resolvedHref,
|
|
119
|
+
ref: ref
|
|
120
|
+
}), children);
|
|
121
|
+
});
|
|
@@ -57,23 +57,52 @@ export const ANCHOR_TARGET = Object.freeze({
|
|
|
57
57
|
|
|
58
58
|
export type AnchorTarget = $Values<typeof ANCHOR_TARGET>;
|
|
59
59
|
|
|
60
|
-
export type
|
|
61
|
-
color?: ColorTypes,
|
|
60
|
+
export type BaseLinkProps = {
|
|
62
61
|
children: React.Node,
|
|
62
|
+
onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
63
|
+
tabIndex?: number,
|
|
64
|
+
disabled?: boolean,
|
|
63
65
|
className?: string,
|
|
64
66
|
as?: LinkAs,
|
|
65
67
|
rel?: AnchorRel,
|
|
66
|
-
underline?: boolean,
|
|
67
68
|
target?: AnchorTarget,
|
|
69
|
+
/**
|
|
70
|
+
* IMPORTANT: If you are using `to` make sure to provide link component from your router
|
|
71
|
+
* if you want to prevent full page reloads in a Single Page Application (SPA).
|
|
72
|
+
*
|
|
73
|
+
* Using `href` in anchor tags causes the browser to navigate to a new URL,
|
|
74
|
+
* resulting in a full page reload. However, in a Single Page Application (SPA), we aim to provide a seamless
|
|
75
|
+
* user experience without such reloads.
|
|
76
|
+
*
|
|
77
|
+
* To achieve client-side navigation and prevent page reloads, use client-side routing libraries
|
|
78
|
+
* (e.g., React Router) and their navigation components (e.g., <Link> or <a> with an onClick handler)
|
|
79
|
+
* to handle navigation within your SPA. These components work without triggering full page reloads
|
|
80
|
+
* and maintain the SPA's performance and user experience.
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
to?: string,
|
|
68
84
|
href?: string,
|
|
69
|
-
onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
70
|
-
tabIndex?: number,
|
|
71
|
-
disabled?: boolean,
|
|
72
85
|
...
|
|
73
86
|
};
|
|
74
87
|
|
|
75
|
-
export
|
|
76
|
-
|
|
88
|
+
export type LinkProps = {
|
|
89
|
+
...BaseLinkProps,
|
|
90
|
+
color?: ColorTypes,
|
|
91
|
+
underline?: boolean,
|
|
92
|
+
/**
|
|
93
|
+
* Provide your router's link component
|
|
94
|
+
*
|
|
95
|
+
* import {Link} from 'src/rerouter';
|
|
96
|
+
* import {Link as GenesisLink} from '@spaced-out/ui-design-system/lib/components/Link';
|
|
97
|
+
*
|
|
98
|
+
* <GenesisLink linkComponent={Link} to="/pages" />
|
|
99
|
+
*/
|
|
100
|
+
linkComponent?: React.AbstractComponent<BaseLinkProps, ?HTMLAnchorElement>,
|
|
101
|
+
...
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const Link: React$AbstractComponent<LinkProps, ?HTMLAnchorElement> =
|
|
105
|
+
React.forwardRef<LinkProps, ?HTMLAnchorElement>(
|
|
77
106
|
(
|
|
78
107
|
{
|
|
79
108
|
color = TEXT_COLORS.clickable,
|
|
@@ -83,6 +112,8 @@ export const Link: React$AbstractComponent<LinkProps, HTMLAnchorElement> =
|
|
|
83
112
|
underline = true,
|
|
84
113
|
tabIndex = 0,
|
|
85
114
|
disabled,
|
|
115
|
+
onClick,
|
|
116
|
+
linkComponent: LinkComponent = DefaultLink,
|
|
86
117
|
...props
|
|
87
118
|
}: LinkProps,
|
|
88
119
|
ref,
|
|
@@ -95,8 +126,29 @@ export const Link: React$AbstractComponent<LinkProps, HTMLAnchorElement> =
|
|
|
95
126
|
}
|
|
96
127
|
}, [disabled]);
|
|
97
128
|
|
|
129
|
+
const handleClick = (event: SyntheticEvent<HTMLElement>) => {
|
|
130
|
+
if (disabled) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
onClick?.(event);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* By spec anchor tag wont call onClick on enter key press when the element is focussed
|
|
140
|
+
* as a workaround we would need to listen to key press event and call onClick
|
|
141
|
+
* manually, one workaround to avoid this is to have empty href along with onClick
|
|
142
|
+
* but that would break accessibility
|
|
143
|
+
*/
|
|
144
|
+
const handleKeyPress = (event) => {
|
|
145
|
+
if (event.key === 'Enter' && onClick) {
|
|
146
|
+
handleClick(event);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
98
150
|
return (
|
|
99
|
-
<
|
|
151
|
+
<LinkComponent
|
|
100
152
|
{...props}
|
|
101
153
|
tabIndex={disabled ? -1 : tabIndex}
|
|
102
154
|
ref={linkRef}
|
|
@@ -111,9 +163,23 @@ export const Link: React$AbstractComponent<LinkProps, HTMLAnchorElement> =
|
|
|
111
163
|
},
|
|
112
164
|
className,
|
|
113
165
|
)}
|
|
166
|
+
onClick={handleClick}
|
|
167
|
+
onKeyPress={handleKeyPress}
|
|
114
168
|
>
|
|
115
169
|
{children}
|
|
116
|
-
</
|
|
170
|
+
</LinkComponent>
|
|
117
171
|
);
|
|
118
172
|
},
|
|
119
173
|
);
|
|
174
|
+
|
|
175
|
+
const DefaultLink = React.forwardRef<BaseLinkProps, HTMLAnchorElement>(
|
|
176
|
+
({children, href, to, ...props}, ref) => {
|
|
177
|
+
const resolvedHref = to ?? href;
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<a {...props} href={resolvedHref} ref={ref}>
|
|
181
|
+
{children}
|
|
182
|
+
</a>
|
|
183
|
+
);
|
|
184
|
+
},
|
|
185
|
+
);
|
|
@@ -92,6 +92,12 @@ const PAGE_NAME_LIST = Object.freeze({
|
|
|
92
92
|
iconType: 'duotone',
|
|
93
93
|
iconSwapOpacity: true
|
|
94
94
|
},
|
|
95
|
+
jobs: {
|
|
96
|
+
title: 'Jobs',
|
|
97
|
+
iconName: 'briefcase',
|
|
98
|
+
iconType: 'duotone',
|
|
99
|
+
iconSwapOpacity: true
|
|
100
|
+
},
|
|
95
101
|
contacts: {
|
|
96
102
|
title: 'Contacts',
|
|
97
103
|
iconName: 'address-card',
|
|
@@ -100,6 +100,12 @@ export const PAGE_NAME_LIST = Object.freeze({
|
|
|
100
100
|
iconType: 'duotone',
|
|
101
101
|
iconSwapOpacity: true,
|
|
102
102
|
},
|
|
103
|
+
jobs: {
|
|
104
|
+
title: 'Jobs',
|
|
105
|
+
iconName: 'briefcase',
|
|
106
|
+
iconType: 'duotone',
|
|
107
|
+
iconSwapOpacity: true,
|
|
108
|
+
},
|
|
103
109
|
contacts: {
|
|
104
110
|
title: 'Contacts',
|
|
105
111
|
iconName: 'address-card',
|
package/lib/components/index.js
CHANGED
|
@@ -47,6 +47,17 @@ Object.keys(_Banner).forEach(function (key) {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
var _Breadcrumbs = require("./Breadcrumbs");
|
|
51
|
+
Object.keys(_Breadcrumbs).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _Breadcrumbs[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _Breadcrumbs[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
50
61
|
var _Button = require("./Button");
|
|
51
62
|
Object.keys(_Button).forEach(function (key) {
|
|
52
63
|
if (key === "default" || key === "__esModule") return;
|