@bitrise/bitkit 10.11.0-alpha-chakra.1 → 10.11.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
CHANGED
|
@@ -25,18 +25,18 @@ const onButtonClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
|
25
25
|
e.stopPropagation();
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const ButtonContentElement = () => {
|
|
28
|
+
const ButtonContentElement = ({ title }: { title: string }) => {
|
|
29
29
|
return (
|
|
30
30
|
<Box display="flex" alignItems="center" flexGrow={1}>
|
|
31
31
|
<Icon name="Doc" />
|
|
32
32
|
<Text as="p" align="left" size="3" margin="0 auto 0 1rem">
|
|
33
|
-
|
|
33
|
+
{title}
|
|
34
34
|
<br />
|
|
35
35
|
<Text as="span" size="2" textColor="neutral.40">
|
|
36
36
|
Generated by clone-build workflow
|
|
37
37
|
</Text>
|
|
38
38
|
</Text>
|
|
39
|
-
<Button as="a" size="small" onClick={onButtonClick} leftIconName="Download">
|
|
39
|
+
<Button as="a" href="#" size="small" onClick={onButtonClick} leftIconName="Download">
|
|
40
40
|
Download
|
|
41
41
|
</Button>
|
|
42
42
|
</Box>
|
|
@@ -48,9 +48,13 @@ export const DefaultVariant: ComponentStory<typeof Accordion> = (props) => (
|
|
|
48
48
|
<AccordionItem buttonContent="The buttonContent is a string" fontSize="2" id="first">
|
|
49
49
|
Content - you can use any style prop on AccordionItem
|
|
50
50
|
</AccordionItem>
|
|
51
|
-
<AccordionItem
|
|
51
|
+
<AccordionItem
|
|
52
|
+
buttonContent={<ButtonContentElement title="The buttonContent is a React element" />}
|
|
53
|
+
fontSize="2"
|
|
54
|
+
id="second"
|
|
55
|
+
>
|
|
52
56
|
Content - you can use any style prop on AccordionItem
|
|
53
57
|
</AccordionItem>
|
|
54
|
-
<AccordionItem buttonContent="Without children
|
|
58
|
+
<AccordionItem buttonContent={<ButtonContentElement title="Without children" />} id="third" />
|
|
55
59
|
</Accordion>
|
|
56
60
|
);
|
|
@@ -7,21 +7,24 @@ const AccordionTheme: ComponentStyleConfig = {
|
|
|
7
7
|
borderColor: 'neutral.93',
|
|
8
8
|
borderRadius: '8',
|
|
9
9
|
boxShadow: 'small',
|
|
10
|
-
overflow: 'hidden',
|
|
11
10
|
marginBottom: '16',
|
|
12
11
|
},
|
|
13
12
|
button: {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
justifyContent: 'space-between',
|
|
14
16
|
width: '100%',
|
|
15
17
|
padding: '16',
|
|
16
18
|
background: colorScheme === 'gray' ? 'neutral.95' : 'neutral.100',
|
|
17
19
|
borderBottom: '1px solid',
|
|
18
20
|
borderColor: 'neutral.93',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
borderRadius: '8',
|
|
22
|
+
'&[type="button"]:hover': {
|
|
21
23
|
background: 'purple.95',
|
|
22
24
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
'&[aria-expanded="true"]': {
|
|
26
|
+
borderBottomLeftRadius: '0',
|
|
27
|
+
borderBottomRightRadius: '0',
|
|
25
28
|
},
|
|
26
29
|
},
|
|
27
30
|
icon: {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
export interface AccordionProps extends Omit<ChakraAccordionProps, 'onChange'> {
|
|
10
10
|
colorScheme?: 'white' | 'gray';
|
|
11
|
-
onChange
|
|
11
|
+
onChange?: (ids: string[], indexes: number[]) => void;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const getItemIds = (props: AccordionProps) => {
|
|
@@ -20,17 +20,22 @@ const getItemIds = (props: AccordionProps) => {
|
|
|
20
20
|
return ids;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Accordions display a list of high-level options that can expand/collapse to reveal more information.
|
|
25
|
+
*/
|
|
23
26
|
const Accordion = (props: AccordionProps) => {
|
|
24
27
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
25
28
|
const { children, colorScheme, onChange, ...rest } = props;
|
|
26
29
|
const itemIds = getItemIds(props);
|
|
27
30
|
|
|
28
31
|
const onAccordionChange = (indexes: ExpandedIndex) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
if (onChange) {
|
|
33
|
+
const indexArray = Object.values(indexes).sort();
|
|
34
|
+
onChange(
|
|
35
|
+
indexArray.map((i: number) => itemIds[i]),
|
|
36
|
+
indexArray,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
return (
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
AccordionIcon,
|
|
9
9
|
useMultiStyleConfig,
|
|
10
10
|
} from '@chakra-ui/react';
|
|
11
|
+
import Box from '../Box/Box';
|
|
11
12
|
import Text from '../Text/Text';
|
|
12
13
|
|
|
13
14
|
export interface AccordionItemProps extends AccordionPanelProps {
|
|
@@ -20,12 +21,14 @@ const AccordionItem = (props: AccordionItemProps) => {
|
|
|
20
21
|
const { buttonContent, children, id, ...rest } = props;
|
|
21
22
|
const styles = useMultiStyleConfig('Accordion');
|
|
22
23
|
|
|
24
|
+
const ButtonComponent = children ? AccordionButton : Box;
|
|
25
|
+
|
|
23
26
|
return (
|
|
24
|
-
<ChakraAccordionItem sx={styles.item} id={id}
|
|
25
|
-
<
|
|
27
|
+
<ChakraAccordionItem sx={styles.item} id={id}>
|
|
28
|
+
<ButtonComponent sx={styles.button}>
|
|
26
29
|
{isValidElement(buttonContent) ? buttonContent : <Text as="span">{buttonContent}</Text>}
|
|
27
|
-
<AccordionIcon />
|
|
28
|
-
</
|
|
30
|
+
<AccordionIcon opacity={children ? 1 : 0.4} />
|
|
31
|
+
</ButtonComponent>
|
|
29
32
|
{!!children && <AccordionPanel {...rest}>{children}</AccordionPanel>}
|
|
30
33
|
</ChakraAccordionItem>
|
|
31
34
|
);
|