@bitrise/bitkit 9.40.0 → 9.41.0-alpha-chakra.1
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 +54 -0
- package/src/Components/Breadcrumb/BreadcrumbLink.tsx +30 -0
- package/src/Components/Form/Checkbox/CheckboxGroup.tsx +1 -1
- package/src/Components/Form/Radio/RadioGroup.tsx +1 -1
- 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
|
+
avatarSrc="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,54 @@
|
|
|
1
|
+
import { Children } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Breadcrumb as ChakraBreadcrumb,
|
|
4
|
+
BreadcrumbProps as ChakraBreadcrumbProps,
|
|
5
|
+
BreadcrumbItem,
|
|
6
|
+
BreadcrumbSeparator,
|
|
7
|
+
forwardRef,
|
|
8
|
+
} from '@chakra-ui/react';
|
|
9
|
+
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
10
|
+
|
|
11
|
+
export interface BreadcrumbProps extends ChakraBreadcrumbProps {
|
|
12
|
+
hasSeparatorAfterLast?: boolean;
|
|
13
|
+
hasSeparatorBeforeFirst?: boolean;
|
|
14
|
+
separatorIconName?: TypeIconName;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Breadcrumbs is a navigation pattern that helps users understand the hierarchy of a website.
|
|
19
|
+
*/
|
|
20
|
+
const Breadcrumb = forwardRef<BreadcrumbProps, 'nav'>((props, ref) => {
|
|
21
|
+
const {
|
|
22
|
+
children,
|
|
23
|
+
hasSeparatorAfterLast,
|
|
24
|
+
hasSeparatorBeforeFirst,
|
|
25
|
+
separatorIconName = 'ChevronRight',
|
|
26
|
+
...rest
|
|
27
|
+
} = props;
|
|
28
|
+
const childrenCount = Children.count(children);
|
|
29
|
+
const items = Children.map(children, (child, index) => {
|
|
30
|
+
return (
|
|
31
|
+
<BreadcrumbItem>
|
|
32
|
+
{hasSeparatorBeforeFirst && index === 0 && <BreadcrumbSeparator />}
|
|
33
|
+
{child}
|
|
34
|
+
{hasSeparatorAfterLast && index === childrenCount - 1 && <BreadcrumbSeparator />}
|
|
35
|
+
</BreadcrumbItem>
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const properties = {
|
|
40
|
+
separator: <Icon name={separatorIconName} textColor="neutral.70" size="16" />,
|
|
41
|
+
...rest,
|
|
42
|
+
};
|
|
43
|
+
return (
|
|
44
|
+
<ChakraBreadcrumb {...properties} ref={ref}>
|
|
45
|
+
{items}
|
|
46
|
+
</ChakraBreadcrumb>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
Breadcrumb.defaultProps = {
|
|
51
|
+
separatorIconName: 'ChevronRight',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default Breadcrumb;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BreadcrumbLink as ChakraBreadcrumbLink,
|
|
3
|
+
BreadcrumbLinkProps as ChakraBreadcrumbLinkProps,
|
|
4
|
+
forwardRef,
|
|
5
|
+
} from '@chakra-ui/react';
|
|
6
|
+
import Avatar from '../Avatar/Avatar';
|
|
7
|
+
|
|
8
|
+
export interface BreadcrumbLinkProps extends ChakraBreadcrumbLinkProps {
|
|
9
|
+
avatarName?: string;
|
|
10
|
+
avatarSrc?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Breadcrumb = forwardRef<BreadcrumbLinkProps, 'a'>((props, ref) => {
|
|
14
|
+
const { avatarName, avatarSrc, children, isCurrentPage, ...rest } = props;
|
|
15
|
+
const properties: ChakraBreadcrumbLinkProps = {
|
|
16
|
+
color: isCurrentPage ? 'neutral.40' : 'inherit',
|
|
17
|
+
isCurrentPage,
|
|
18
|
+
...rest,
|
|
19
|
+
};
|
|
20
|
+
return (
|
|
21
|
+
<ChakraBreadcrumbLink {...properties} color={isCurrentPage ? 'neutral.40' : 'inherit'} ref={ref}>
|
|
22
|
+
{(avatarName || avatarSrc) && (
|
|
23
|
+
<Avatar name={avatarName || children?.toString()} src={avatarSrc} borderRadius="4" />
|
|
24
|
+
)}
|
|
25
|
+
{children}
|
|
26
|
+
</ChakraBreadcrumbLink>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export default Breadcrumb;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CheckboxGroup as ChakraCheckboxGroup, CheckboxGroupProps as ChakraCheckboxGroupProps } from '@chakra-ui/react';
|
|
2
2
|
import Box, { BoxProps } from '../../Box/Box';
|
|
3
3
|
|
|
4
|
-
export type CheckboxGroupProps = ChakraCheckboxGroupProps & BoxProps
|
|
4
|
+
export type CheckboxGroupProps = ChakraCheckboxGroupProps & Omit<BoxProps, 'onChange'>;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* CheckboxGroup component to help manage the checked state of its children Checkbox components and conveniently pass a few shared style props to each.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RadioGroup as ChakraRadioGroup, RadioGroupProps as ChakraRadioGroupProps } from '@chakra-ui/react';
|
|
2
2
|
import Box, { BoxProps } from '../../Box/Box';
|
|
3
3
|
|
|
4
|
-
export type RadioGroupProps = ChakraRadioGroupProps & BoxProps
|
|
4
|
+
export type RadioGroupProps = ChakraRadioGroupProps & Omit<BoxProps, 'onChange'>;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* RadioGroup component to help manage Radio components and conveniently pass a few shared style props to each.
|
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,
|