@bitrise/bitkit 12.44.2 → 12.46.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
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defineStyle, defineStyleConfig } from '@chakra-ui/styled-system';
|
|
2
|
+
|
|
3
|
+
const baseStyle = defineStyle(({ isCopiable }) => {
|
|
4
|
+
const style = {
|
|
5
|
+
fontFamily: 'mono',
|
|
6
|
+
py: '4',
|
|
7
|
+
px: '8',
|
|
8
|
+
borderRadius: '2',
|
|
9
|
+
bg: 'neutral.95',
|
|
10
|
+
width: 'fit-content',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
if (isCopiable) {
|
|
14
|
+
return {
|
|
15
|
+
...style,
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
_hover: {
|
|
18
|
+
background: 'neutral.93',
|
|
19
|
+
},
|
|
20
|
+
_active: {
|
|
21
|
+
background: 'neutral.90',
|
|
22
|
+
},
|
|
23
|
+
_focusVisible: {
|
|
24
|
+
boxShadow: 'outline',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return style;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default defineStyleConfig({
|
|
33
|
+
baseStyle,
|
|
34
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useClipboard, useStyleConfig } from '@chakra-ui/react';
|
|
3
|
+
import Box from '../Box/Box';
|
|
4
|
+
import Tooltip from '../Tooltip/Tooltip';
|
|
5
|
+
|
|
6
|
+
export interface CodeSnippetProps {
|
|
7
|
+
children: string;
|
|
8
|
+
isCopiable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const CodeSnippet = (props: CodeSnippetProps) => {
|
|
12
|
+
const { children, isCopiable } = props;
|
|
13
|
+
const css = useStyleConfig('CodeSnippet', { isCopiable });
|
|
14
|
+
const { onCopy, hasCopied } = useClipboard(children);
|
|
15
|
+
|
|
16
|
+
const [isTooltipOpen, setTooltipOpen] = useState(false);
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Tooltip isOpen={isTooltipOpen} label={hasCopied ? 'Copied to clipboard' : 'Copy to clipboard'}>
|
|
20
|
+
<Box
|
|
21
|
+
__css={css}
|
|
22
|
+
as="code"
|
|
23
|
+
tabIndex={0}
|
|
24
|
+
onClick={isCopiable ? onCopy : undefined}
|
|
25
|
+
onMouseEnter={() => (isCopiable ? setTooltipOpen(true) : undefined)}
|
|
26
|
+
onMouseLeave={() => (isCopiable ? setTooltipOpen(false) : undefined)}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</Box>
|
|
30
|
+
</Tooltip>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default CodeSnippet;
|
|
@@ -21,13 +21,14 @@ const decorationColor = {
|
|
|
21
21
|
success: 'green.50',
|
|
22
22
|
};
|
|
23
23
|
const NoteTheme = {
|
|
24
|
-
parts: ['container', 'icon', 'body'],
|
|
25
|
-
baseStyle({ status }: { status: Status }) {
|
|
24
|
+
parts: ['container', 'icon', 'body', 'buttonContainer'],
|
|
25
|
+
baseStyle({ isExpanded, status }: { isExpanded: boolean; status: Status }) {
|
|
26
26
|
return {
|
|
27
27
|
wrapper: {
|
|
28
28
|
display: 'flex',
|
|
29
29
|
boxShadow: 'medium',
|
|
30
30
|
borderRadius: '8',
|
|
31
|
+
position: 'relative',
|
|
31
32
|
},
|
|
32
33
|
decoration: {
|
|
33
34
|
color: decorationColor[status],
|
|
@@ -46,13 +47,30 @@ const NoteTheme = {
|
|
|
46
47
|
flexGrow: 1,
|
|
47
48
|
paddingTop: '24',
|
|
48
49
|
paddingRight: '24',
|
|
49
|
-
paddingBottom: '32',
|
|
50
|
+
paddingBottom: ['80', '32'],
|
|
50
51
|
paddingLeft: '16',
|
|
51
52
|
borderTopRightRadius: '8',
|
|
52
53
|
borderBottomRightRadius: '8',
|
|
53
54
|
borderWidth: '1px',
|
|
54
55
|
borderLeft: 'none',
|
|
55
56
|
borderColor: borderColor[status],
|
|
57
|
+
overflow: 'hidden',
|
|
58
|
+
},
|
|
59
|
+
buttonContainer: {
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
left: isExpanded ? 'auto' : '40px',
|
|
62
|
+
right: 1,
|
|
63
|
+
bottom: 1,
|
|
64
|
+
textAlign: 'right',
|
|
65
|
+
paddingX: '24',
|
|
66
|
+
paddingTop: '80',
|
|
67
|
+
paddingBottom: '16',
|
|
68
|
+
background: isExpanded ? undefined : 'linear-gradient(0deg, #FFF 12.57%, rgba(255, 255, 255, 0.00) 100%)',
|
|
69
|
+
borderBottomRadius: '8',
|
|
70
|
+
svg: {
|
|
71
|
+
transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
72
|
+
transition: '300ms',
|
|
73
|
+
},
|
|
56
74
|
},
|
|
57
75
|
};
|
|
58
76
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { useState, ReactNode } from 'react';
|
|
2
2
|
import { useMultiStyleConfig } from '@chakra-ui/react';
|
|
3
3
|
import Box from '../Box/Box';
|
|
4
|
+
import Collapse from '../Collapse/Collapse';
|
|
4
5
|
import Icon from '../Icon/Icon';
|
|
6
|
+
import Button from '../Button/Button';
|
|
5
7
|
|
|
6
8
|
export type Status = 'info' | 'success' | 'error' | 'warning';
|
|
7
9
|
const iconNames = {
|
|
@@ -10,14 +12,54 @@ const iconNames = {
|
|
|
10
12
|
error: 'ErrorGeneral',
|
|
11
13
|
warning: 'Warning',
|
|
12
14
|
} as const;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
export type NoteProps = {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
startingHeight?: number;
|
|
19
|
+
status: Status;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type ContainerProps = { children: ReactNode; isExpanded: boolean; startingHeight?: number };
|
|
23
|
+
|
|
24
|
+
const Container = ({ children, isExpanded, startingHeight }: ContainerProps) => {
|
|
25
|
+
if (startingHeight) {
|
|
26
|
+
return (
|
|
27
|
+
<Collapse
|
|
28
|
+
in={isExpanded}
|
|
29
|
+
startingHeight={startingHeight}
|
|
30
|
+
transition={{ enter: { duration: 0.5 }, exit: { duration: 0.5 } }}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</Collapse>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return <>{children}</>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const Note = ({ children, startingHeight, status }: NoteProps) => {
|
|
40
|
+
const [isExpanded, setExpanded] = useState(false);
|
|
41
|
+
const { buttonContainer, container, decoration, wrapper } = useMultiStyleConfig('Note', {
|
|
42
|
+
isExpanded,
|
|
43
|
+
status,
|
|
44
|
+
});
|
|
45
|
+
|
|
15
46
|
return (
|
|
16
47
|
<Box __css={wrapper}>
|
|
17
48
|
<Box __css={decoration}>
|
|
18
49
|
<Icon size="24" name={iconNames[status]} />
|
|
19
50
|
</Box>
|
|
20
|
-
<Box __css={container}>
|
|
51
|
+
<Box __css={container}>
|
|
52
|
+
<Container isExpanded={isExpanded} startingHeight={startingHeight}>
|
|
53
|
+
{children}
|
|
54
|
+
</Container>
|
|
55
|
+
</Box>
|
|
56
|
+
{!!startingHeight && (
|
|
57
|
+
<Box __css={buttonContainer}>
|
|
58
|
+
<Button leftIconName="ChevronDown" onClick={() => setExpanded(!isExpanded)} size="small" variant="secondary">
|
|
59
|
+
{isExpanded ? 'Show less' : 'Show more'}
|
|
60
|
+
</Button>
|
|
61
|
+
</Box>
|
|
62
|
+
)}
|
|
21
63
|
</Box>
|
|
22
64
|
);
|
|
23
65
|
};
|
package/src/index.ts
CHANGED
|
@@ -283,9 +283,11 @@ export { default as SelectableRow } from './Components/Table/SelectableRow';
|
|
|
283
283
|
export type { TagProps } from './Components/Tag/Tag';
|
|
284
284
|
export { default as Tag } from './Components/Tag/Tag';
|
|
285
285
|
|
|
286
|
+
export type { NoteProps } from './Components/Note/Note';
|
|
286
287
|
export { default as Note } from './Components/Note/Note';
|
|
287
288
|
export { default as MarkdownContent } from './Components/Note/NoteMarkdownContent';
|
|
288
289
|
export { default as CodeBlock } from './Components/CodeBlock/CodeBlock';
|
|
290
|
+
export { default as CodeSnippet } from './Components/CodeSnippet/CodeSnippet';
|
|
289
291
|
|
|
290
292
|
export type { DefinitionTooltipProps } from './Components/DefinitionTooltip/DefinitionTooltip';
|
|
291
293
|
export { default as DefinitionTooltip } from './Components/DefinitionTooltip/DefinitionTooltip';
|
package/src/theme.ts
CHANGED
|
@@ -38,6 +38,7 @@ import SegmentedControl from './Components/SegmentedControl/SegmentedControl.the
|
|
|
38
38
|
import Tag from './Components/Tag/Tag.theme';
|
|
39
39
|
import Note from './Components/Note/Note.theme';
|
|
40
40
|
import CodeBlock from './Components/CodeBlock/CodeBlock.theme';
|
|
41
|
+
import CodeSnippet from './Components/CodeSnippet/CodeSnippet.theme';
|
|
41
42
|
import DefinitionTooltip from './Components/DefinitionTooltip/DefinitionTooltip.theme';
|
|
42
43
|
import ExpandableCard from './Components/ExpandableCard/ExpandableCard.theme';
|
|
43
44
|
import FileInput from './Components/Form/FileInput/FileInput.theme';
|
|
@@ -127,6 +128,7 @@ const theme = {
|
|
|
127
128
|
Tag,
|
|
128
129
|
Note,
|
|
129
130
|
CodeBlock,
|
|
131
|
+
CodeSnippet,
|
|
130
132
|
DefinitionTooltip,
|
|
131
133
|
Toggletip,
|
|
132
134
|
ExpandableCard,
|