@bitrise/bitkit 10.1.0 → 10.2.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/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 +51 -0
- package/src/Components/Breadcrumb/BreadcrumbLink.tsx +34 -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,51 @@
|
|
|
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 { BREAKPOINTS } from '../../Foundations/Breakpoints/Breakpoints';
|
|
11
|
+
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
12
|
+
|
|
13
|
+
export interface BreadcrumbProps extends ChakraBreadcrumbProps {
|
|
14
|
+
hasSeparatorAfterLast?: boolean;
|
|
15
|
+
hasSeparatorBeforeFirst?: boolean;
|
|
16
|
+
separatorIconName?: TypeIconName;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Breadcrumbs is a navigation pattern that helps users understand the hierarchy of a website.
|
|
21
|
+
*/
|
|
22
|
+
const Breadcrumb = forwardRef<BreadcrumbProps, 'nav'>((props, ref) => {
|
|
23
|
+
const { children, hasSeparatorAfterLast, hasSeparatorBeforeFirst, separatorIconName, ...rest } = props;
|
|
24
|
+
const isMobile = !!useBreakpointValue({ [BREAKPOINTS.MOBILE]: true, [BREAKPOINTS.DESKTOP]: false }, 'desktop');
|
|
25
|
+
|
|
26
|
+
const childrenCount = Children.count(children);
|
|
27
|
+
const items = Children.map(children, (child, index) => {
|
|
28
|
+
return (
|
|
29
|
+
<BreadcrumbItem>
|
|
30
|
+
{hasSeparatorBeforeFirst && index === 0 && <BreadcrumbSeparator marginLeft="0" />}
|
|
31
|
+
{child}
|
|
32
|
+
{hasSeparatorAfterLast && index === childrenCount - 1 && <BreadcrumbSeparator />}
|
|
33
|
+
</BreadcrumbItem>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const defaultIconName = isMobile ? 'ChevronLeft' : 'ChevronRight';
|
|
38
|
+
const properties = {
|
|
39
|
+
separator: <Icon name={separatorIconName || defaultIconName} color="neutral.70" size="16" />,
|
|
40
|
+
...rest,
|
|
41
|
+
};
|
|
42
|
+
return (
|
|
43
|
+
<ChakraBreadcrumb {...properties} ref={ref}>
|
|
44
|
+
{items}
|
|
45
|
+
</ChakraBreadcrumb>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
Breadcrumb.defaultProps = {};
|
|
50
|
+
|
|
51
|
+
export default Breadcrumb;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BreadcrumbLink as ChakraBreadcrumbLink,
|
|
3
|
+
BreadcrumbLinkProps as ChakraBreadcrumbLinkProps,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useBreakpointValue,
|
|
6
|
+
} from '@chakra-ui/react';
|
|
7
|
+
import { BREAKPOINTS } from '../../Foundations/Breakpoints/Breakpoints';
|
|
8
|
+
import Avatar from '../Avatar/Avatar';
|
|
9
|
+
|
|
10
|
+
export interface BreadcrumbLinkProps extends ChakraBreadcrumbLinkProps {
|
|
11
|
+
avatarName?: string;
|
|
12
|
+
avatarUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const BreadcrumbLink = forwardRef<BreadcrumbLinkProps, 'a'>((props, ref) => {
|
|
16
|
+
const { avatarName, avatarUrl, children, isCurrentPage, ...rest } = props;
|
|
17
|
+
const isMobile = !!useBreakpointValue({ [BREAKPOINTS.MOBILE]: true, [BREAKPOINTS.DESKTOP]: false }, 'desktop');
|
|
18
|
+
|
|
19
|
+
const properties: ChakraBreadcrumbLinkProps = {
|
|
20
|
+
color: isCurrentPage ? 'neutral.40' : 'inherit',
|
|
21
|
+
isCurrentPage,
|
|
22
|
+
...rest,
|
|
23
|
+
};
|
|
24
|
+
return (
|
|
25
|
+
<ChakraBreadcrumbLink {...properties} color={isCurrentPage ? 'neutral.40' : 'inherit'} ref={ref}>
|
|
26
|
+
{!isMobile && (avatarName || avatarUrl) && (
|
|
27
|
+
<Avatar name={avatarName || children?.toString()} src={avatarUrl} borderRadius="4" />
|
|
28
|
+
)}
|
|
29
|
+
{children}
|
|
30
|
+
</ChakraBreadcrumbLink>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export default BreadcrumbLink;
|
package/src/index.ts
CHANGED
|
@@ -133,4 +133,10 @@ export { default as RadioGroup } from './Components/Form/Radio/RadioGroup';
|
|
|
133
133
|
export type { ImageProps } from './Components/Image/Image';
|
|
134
134
|
export { default as Image } from './Components/Image/Image';
|
|
135
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';
|
|
141
|
+
|
|
136
142
|
export { BREAKPOINTS } from './Foundations/Breakpoints/Breakpoints';
|
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,
|