@bitrise/bitkit 9.40.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 +1 -1
- package/src/Components/Breadcrumb/Breadcrumb.stories.tsx +30 -0
- package/src/Components/Breadcrumb/Breadcrumb.theme.ts +25 -0
- package/src/Components/Breadcrumb/Breadcrumb.tsx +50 -0
- package/src/Components/Breadcrumb/BreadcrumbLink.tsx +33 -0
- package/src/index.ts +6 -0
- package/src/theme.ts +2 -0
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import Breadcrumb from './Breadcrumb';
|
|
3
|
+
import BreadcrumbLink from './BreadcrumbLink';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Breadcrumb',
|
|
7
|
+
component: Breadcrumb,
|
|
8
|
+
subcomponents: { BreadcrumbLink },
|
|
9
|
+
} as ComponentMeta<typeof Breadcrumb>;
|
|
10
|
+
|
|
11
|
+
const Template: ComponentStory<typeof Breadcrumb> = (props) => (
|
|
12
|
+
<Breadcrumb {...props}>
|
|
13
|
+
<BreadcrumbLink
|
|
14
|
+
avatarUrl="https://bitrise-public-content-production.s3.amazonaws.com/org-icons/default_avatar-02.png"
|
|
15
|
+
href="#"
|
|
16
|
+
>
|
|
17
|
+
Bitrise #Core
|
|
18
|
+
</BreadcrumbLink>
|
|
19
|
+
<BreadcrumbLink avatarName="Bitkit" href="#">
|
|
20
|
+
bitkit
|
|
21
|
+
</BreadcrumbLink>
|
|
22
|
+
<BreadcrumbLink isCurrentPage>settings</BreadcrumbLink>
|
|
23
|
+
</Breadcrumb>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const WithProps = Template.bind({});
|
|
27
|
+
WithProps.args = {
|
|
28
|
+
hasSeparatorAfterLast: false,
|
|
29
|
+
hasSeparatorBeforeFirst: false,
|
|
30
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SystemStyleObject } from '@chakra-ui/theme-tools';
|
|
2
|
+
|
|
3
|
+
const BreadcrumbTheme: SystemStyleObject = {
|
|
4
|
+
baseStyle: {
|
|
5
|
+
container: {
|
|
6
|
+
'> ol': {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
link: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
gap: '8',
|
|
15
|
+
'[aria-current]': {
|
|
16
|
+
color: 'red',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
separator: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default BreadcrumbTheme;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Children } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Breadcrumb as ChakraBreadcrumb,
|
|
4
|
+
BreadcrumbProps as ChakraBreadcrumbProps,
|
|
5
|
+
BreadcrumbItem,
|
|
6
|
+
BreadcrumbSeparator,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useBreakpointValue,
|
|
9
|
+
} from '@chakra-ui/react';
|
|
10
|
+
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
11
|
+
|
|
12
|
+
export interface BreadcrumbProps extends ChakraBreadcrumbProps {
|
|
13
|
+
hasSeparatorAfterLast?: boolean;
|
|
14
|
+
hasSeparatorBeforeFirst?: boolean;
|
|
15
|
+
separatorIconName?: TypeIconName;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Breadcrumbs is a navigation pattern that helps users understand the hierarchy of a website.
|
|
20
|
+
*/
|
|
21
|
+
const Breadcrumb = forwardRef<BreadcrumbProps, 'nav'>((props, ref) => {
|
|
22
|
+
const { children, hasSeparatorAfterLast, hasSeparatorBeforeFirst, separatorIconName, ...rest } = props;
|
|
23
|
+
const isMobile = !!useBreakpointValue({ mobile: true, desktop: false }, 'desktop');
|
|
24
|
+
|
|
25
|
+
const childrenCount = Children.count(children);
|
|
26
|
+
const items = Children.map(children, (child, index) => {
|
|
27
|
+
return (
|
|
28
|
+
<BreadcrumbItem>
|
|
29
|
+
{hasSeparatorBeforeFirst && index === 0 && <BreadcrumbSeparator />}
|
|
30
|
+
{child}
|
|
31
|
+
{hasSeparatorAfterLast && index === childrenCount - 1 && <BreadcrumbSeparator />}
|
|
32
|
+
</BreadcrumbItem>
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const defaultIconName = isMobile ? 'ChevronLeft' : 'ChevronRight';
|
|
37
|
+
const properties = {
|
|
38
|
+
separator: <Icon name={separatorIconName || defaultIconName} color="neutral.70" size="16" />,
|
|
39
|
+
...rest,
|
|
40
|
+
};
|
|
41
|
+
return (
|
|
42
|
+
<ChakraBreadcrumb {...properties} ref={ref}>
|
|
43
|
+
{items}
|
|
44
|
+
</ChakraBreadcrumb>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
Breadcrumb.defaultProps = {};
|
|
49
|
+
|
|
50
|
+
export default Breadcrumb;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BreadcrumbLink as ChakraBreadcrumbLink,
|
|
3
|
+
BreadcrumbLinkProps as ChakraBreadcrumbLinkProps,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useBreakpointValue,
|
|
6
|
+
} from '@chakra-ui/react';
|
|
7
|
+
import Avatar from '../Avatar/Avatar';
|
|
8
|
+
|
|
9
|
+
export interface BreadcrumbLinkProps extends ChakraBreadcrumbLinkProps {
|
|
10
|
+
avatarName?: string;
|
|
11
|
+
avatarUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Breadcrumb = forwardRef<BreadcrumbLinkProps, 'a'>((props, ref) => {
|
|
15
|
+
const { avatarName, avatarUrl, children, isCurrentPage, ...rest } = props;
|
|
16
|
+
const isMobile = !!useBreakpointValue({ mobile: true, desktop: false }, 'desktop');
|
|
17
|
+
|
|
18
|
+
const properties: ChakraBreadcrumbLinkProps = {
|
|
19
|
+
color: isCurrentPage ? 'neutral.40' : 'inherit',
|
|
20
|
+
isCurrentPage,
|
|
21
|
+
...rest,
|
|
22
|
+
};
|
|
23
|
+
return (
|
|
24
|
+
<ChakraBreadcrumbLink {...properties} color={isCurrentPage ? 'neutral.40' : 'inherit'} ref={ref}>
|
|
25
|
+
{!isMobile && (avatarName || avatarUrl) && (
|
|
26
|
+
<Avatar name={avatarName || children?.toString()} src={avatarUrl} borderRadius="4" />
|
|
27
|
+
)}
|
|
28
|
+
{children}
|
|
29
|
+
</ChakraBreadcrumbLink>
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export default Breadcrumb;
|
package/src/index.ts
CHANGED
|
@@ -132,3 +132,9 @@ export { default as RadioGroup } from './Components/Form/Radio/RadioGroup';
|
|
|
132
132
|
|
|
133
133
|
export type { ImageProps } from './Components/Image/Image';
|
|
134
134
|
export { default as Image } from './Components/Image/Image';
|
|
135
|
+
|
|
136
|
+
export type { BreadcrumbProps } from './Components/Breadcrumb/Breadcrumb';
|
|
137
|
+
export { default as Breadcrumb } from './Components/Breadcrumb/Breadcrumb';
|
|
138
|
+
|
|
139
|
+
export type { BreadcrumbLinkProps } from './Components/Breadcrumb/BreadcrumbLink';
|
|
140
|
+
export { default as BreadcrumbLink } from './Components/Breadcrumb/BreadcrumbLink';
|
package/src/theme.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Avatar from './Components/Avatar/Avatar.theme';
|
|
2
2
|
import Badge from './Components/Badge/Badge.theme';
|
|
3
|
+
import Breadcrumb from './Components/Breadcrumb/Breadcrumb.theme';
|
|
3
4
|
import Button from './Components/Button/Button.theme';
|
|
4
5
|
import Card from './Components/Card/Card.theme';
|
|
5
6
|
import Checkbox from './Components/Form/Checkbox/Checkbox.theme';
|
|
@@ -65,6 +66,7 @@ const theme = {
|
|
|
65
66
|
components: {
|
|
66
67
|
Avatar,
|
|
67
68
|
Badge,
|
|
69
|
+
Breadcrumb,
|
|
68
70
|
Button,
|
|
69
71
|
Card,
|
|
70
72
|
Checkbox,
|