@bitrise/bitkit 9.41.0-alpha-chakra.1 → 9.41.0-alpha-chakra.2
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitrise/bitkit",
|
|
3
3
|
"description": "Bitrise React component library",
|
|
4
|
-
"version": "9.41.0-alpha-chakra.
|
|
4
|
+
"version": "9.41.0-alpha-chakra.2",
|
|
5
5
|
"repository": "git@github.com:bitrise-io/bitkit.git",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
const Template: ComponentStory<typeof Breadcrumb> = (props) => (
|
|
12
12
|
<Breadcrumb {...props}>
|
|
13
13
|
<BreadcrumbLink
|
|
14
|
-
|
|
14
|
+
avatarUrl="https://bitrise-public-content-production.s3.amazonaws.com/org-icons/default_avatar-02.png"
|
|
15
15
|
href="#"
|
|
16
16
|
>
|
|
17
17
|
Bitrise #Core
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
BreadcrumbItem,
|
|
6
6
|
BreadcrumbSeparator,
|
|
7
7
|
forwardRef,
|
|
8
|
+
useBreakpointValue,
|
|
8
9
|
} from '@chakra-ui/react';
|
|
9
10
|
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
10
11
|
|
|
@@ -18,13 +19,9 @@ export interface BreadcrumbProps extends ChakraBreadcrumbProps {
|
|
|
18
19
|
* Breadcrumbs is a navigation pattern that helps users understand the hierarchy of a website.
|
|
19
20
|
*/
|
|
20
21
|
const Breadcrumb = forwardRef<BreadcrumbProps, 'nav'>((props, ref) => {
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
hasSeparatorBeforeFirst,
|
|
25
|
-
separatorIconName = 'ChevronRight',
|
|
26
|
-
...rest
|
|
27
|
-
} = props;
|
|
22
|
+
const { children, hasSeparatorAfterLast, hasSeparatorBeforeFirst, separatorIconName, ...rest } = props;
|
|
23
|
+
const isMobile = !!useBreakpointValue({ mobile: true, desktop: false }, 'desktop');
|
|
24
|
+
|
|
28
25
|
const childrenCount = Children.count(children);
|
|
29
26
|
const items = Children.map(children, (child, index) => {
|
|
30
27
|
return (
|
|
@@ -36,8 +33,9 @@ const Breadcrumb = forwardRef<BreadcrumbProps, 'nav'>((props, ref) => {
|
|
|
36
33
|
);
|
|
37
34
|
});
|
|
38
35
|
|
|
36
|
+
const defaultIconName = isMobile ? 'ChevronLeft' : 'ChevronRight';
|
|
39
37
|
const properties = {
|
|
40
|
-
separator: <Icon name={separatorIconName}
|
|
38
|
+
separator: <Icon name={separatorIconName || defaultIconName} color="neutral.70" size="16" />,
|
|
41
39
|
...rest,
|
|
42
40
|
};
|
|
43
41
|
return (
|
|
@@ -47,8 +45,6 @@ const Breadcrumb = forwardRef<BreadcrumbProps, 'nav'>((props, ref) => {
|
|
|
47
45
|
);
|
|
48
46
|
});
|
|
49
47
|
|
|
50
|
-
Breadcrumb.defaultProps = {
|
|
51
|
-
separatorIconName: 'ChevronRight',
|
|
52
|
-
};
|
|
48
|
+
Breadcrumb.defaultProps = {};
|
|
53
49
|
|
|
54
50
|
export default Breadcrumb;
|
|
@@ -2,16 +2,19 @@ import {
|
|
|
2
2
|
BreadcrumbLink as ChakraBreadcrumbLink,
|
|
3
3
|
BreadcrumbLinkProps as ChakraBreadcrumbLinkProps,
|
|
4
4
|
forwardRef,
|
|
5
|
+
useBreakpointValue,
|
|
5
6
|
} from '@chakra-ui/react';
|
|
6
7
|
import Avatar from '../Avatar/Avatar';
|
|
7
8
|
|
|
8
9
|
export interface BreadcrumbLinkProps extends ChakraBreadcrumbLinkProps {
|
|
9
10
|
avatarName?: string;
|
|
10
|
-
|
|
11
|
+
avatarUrl?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const Breadcrumb = forwardRef<BreadcrumbLinkProps, 'a'>((props, ref) => {
|
|
14
|
-
const { avatarName,
|
|
15
|
+
const { avatarName, avatarUrl, children, isCurrentPage, ...rest } = props;
|
|
16
|
+
const isMobile = !!useBreakpointValue({ mobile: true, desktop: false }, 'desktop');
|
|
17
|
+
|
|
15
18
|
const properties: ChakraBreadcrumbLinkProps = {
|
|
16
19
|
color: isCurrentPage ? 'neutral.40' : 'inherit',
|
|
17
20
|
isCurrentPage,
|
|
@@ -19,8 +22,8 @@ const Breadcrumb = forwardRef<BreadcrumbLinkProps, 'a'>((props, ref) => {
|
|
|
19
22
|
};
|
|
20
23
|
return (
|
|
21
24
|
<ChakraBreadcrumbLink {...properties} color={isCurrentPage ? 'neutral.40' : 'inherit'} ref={ref}>
|
|
22
|
-
{(avatarName ||
|
|
23
|
-
<Avatar name={avatarName || children?.toString()} src={
|
|
25
|
+
{!isMobile && (avatarName || avatarUrl) && (
|
|
26
|
+
<Avatar name={avatarName || children?.toString()} src={avatarUrl} borderRadius="4" />
|
|
24
27
|
)}
|
|
25
28
|
{children}
|
|
26
29
|
</ChakraBreadcrumbLink>
|