@bitrise/bitkit 11.3.1-alpha-chakra.1 → 11.4.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/Accordion/Accordion.tsx +33 -0
- package/src/Components/Accordion/AccordionItem.tsx +38 -0
- package/src/Components/AccordionLegacy/Accordion.theme.ts +89 -41
- package/src/Components/Text/Text.tsx +4 -2
- package/src/Foundations/Typography/Typography.ts +18 -9
- package/src/index.ts +6 -0
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Accordion as ChakraAccordion,
|
|
3
|
+
AccordionProps as ChakraAccordionProps,
|
|
4
|
+
usePrefersReducedMotion,
|
|
5
|
+
} from '@chakra-ui/react';
|
|
6
|
+
|
|
7
|
+
export type AccordionProps = Omit<ChakraAccordionProps, 'onChange' | 'defaultIndex'> & {
|
|
8
|
+
defaultIndex: number[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Accordions display a list of high-level options that can expand/collapse to reveal more information.
|
|
13
|
+
*/
|
|
14
|
+
const Accordion = (props: AccordionProps) => {
|
|
15
|
+
const prefersReducedMotion = usePrefersReducedMotion({ ssr: false });
|
|
16
|
+
const { children, colorScheme, defaultIndex, variant, ...rest } = props;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ChakraAccordion
|
|
20
|
+
allowMultiple
|
|
21
|
+
allowToggle
|
|
22
|
+
colorScheme={colorScheme}
|
|
23
|
+
variant={variant}
|
|
24
|
+
reduceMotion={prefersReducedMotion}
|
|
25
|
+
defaultIndex={defaultIndex}
|
|
26
|
+
{...rest}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</ChakraAccordion>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default Accordion;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AccordionItem as ChakraAccordionItem,
|
|
4
|
+
AccordionItemProps as ChakraAccordionItemProps,
|
|
5
|
+
AccordionButton,
|
|
6
|
+
AccordionPanel,
|
|
7
|
+
AccordionIcon,
|
|
8
|
+
useAccordionStyles,
|
|
9
|
+
} from '@chakra-ui/react';
|
|
10
|
+
|
|
11
|
+
export interface AccordionItemProps {
|
|
12
|
+
buttonContent: ReactNode | ((props: { isExpanded: boolean; isDisabled: boolean }) => ReactNode);
|
|
13
|
+
children?: ReactNode | ((props: { isExpanded: boolean; isDisabled: boolean }) => ReactNode);
|
|
14
|
+
id?: ChakraAccordionItemProps['id'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const AccordionItem = (props: AccordionItemProps) => {
|
|
18
|
+
const { buttonContent, children, id } = props;
|
|
19
|
+
const styles = useAccordionStyles();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<ChakraAccordionItem sx={styles.item} id={id}>
|
|
23
|
+
{(renderProps) => (
|
|
24
|
+
<>
|
|
25
|
+
<AccordionButton sx={styles.button}>
|
|
26
|
+
{typeof buttonContent === 'function' ? buttonContent(renderProps) : buttonContent}
|
|
27
|
+
<AccordionIcon sx={styles.icon} />
|
|
28
|
+
</AccordionButton>
|
|
29
|
+
{!!children && (
|
|
30
|
+
<AccordionPanel>{typeof children === 'function' ? children(renderProps) : children}</AccordionPanel>
|
|
31
|
+
)}
|
|
32
|
+
</>
|
|
33
|
+
)}
|
|
34
|
+
</ChakraAccordionItem>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default AccordionItem;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { StyleFunctionProps } from '@chakra-ui/styled-system';
|
|
1
2
|
import type { ComponentStyleConfig } from '@chakra-ui/theme';
|
|
3
|
+
import { CSSObject } from '@emotion/react';
|
|
2
4
|
|
|
3
5
|
type ColorObj = {
|
|
4
6
|
[key: string]: {
|
|
@@ -15,6 +17,8 @@ type VariantObj = {
|
|
|
15
17
|
[key: string]: {
|
|
16
18
|
borderRadius: string;
|
|
17
19
|
boxShadow: string;
|
|
20
|
+
marginBottom: string;
|
|
21
|
+
border?: string;
|
|
18
22
|
};
|
|
19
23
|
};
|
|
20
24
|
|
|
@@ -64,59 +68,103 @@ const variants: VariantObj = {
|
|
|
64
68
|
legacy: {
|
|
65
69
|
borderRadius: '8',
|
|
66
70
|
boxShadow: 'small',
|
|
71
|
+
marginBottom: '16',
|
|
67
72
|
},
|
|
68
73
|
flat: {
|
|
69
74
|
borderRadius: '0',
|
|
70
75
|
boxShadow: 'none',
|
|
76
|
+
marginBottom: '16',
|
|
71
77
|
},
|
|
72
78
|
};
|
|
73
79
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
enabledButton: {
|
|
87
|
-
...buttonStyle,
|
|
88
|
-
borderColor: colors[colorScheme].border,
|
|
89
|
-
borderRadius: variants[variant].borderRadius,
|
|
90
|
-
background: colors[colorScheme].enabledButton,
|
|
91
|
-
_hover: {
|
|
92
|
-
background: colors[colorScheme].hover,
|
|
93
|
-
},
|
|
94
|
-
_expanded: {
|
|
95
|
-
borderBottomLeftRadius: '0',
|
|
96
|
-
borderBottomRightRadius: '0',
|
|
97
|
-
},
|
|
80
|
+
const LegacyBaseStyle: ({ colorScheme, variant }: Pick<StyleFunctionProps, 'colorScheme' | 'variant'>) => CSSObject = ({
|
|
81
|
+
colorScheme,
|
|
82
|
+
variant,
|
|
83
|
+
}) => ({
|
|
84
|
+
item: {
|
|
85
|
+
border: variants[variant].border ?? '1px solid',
|
|
86
|
+
borderColor: colors[colorScheme].border,
|
|
87
|
+
borderRadius: variants[variant].borderRadius,
|
|
88
|
+
boxShadow: variants[variant].boxShadow,
|
|
89
|
+
marginBottom: variants[variant].marginBottom,
|
|
90
|
+
_last: {
|
|
91
|
+
marginBottom: 0,
|
|
98
92
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
},
|
|
94
|
+
enabledButton: {
|
|
95
|
+
...buttonStyle,
|
|
96
|
+
borderColor: colors[colorScheme].border,
|
|
97
|
+
borderRadius: variants[variant].borderRadius,
|
|
98
|
+
background: colors[colorScheme].enabledButton,
|
|
99
|
+
_hover: {
|
|
100
|
+
background: colors[colorScheme].hover,
|
|
105
101
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
_expanded: {
|
|
103
|
+
borderBottomLeftRadius: '0',
|
|
104
|
+
borderBottomRightRadius: '0',
|
|
109
105
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
},
|
|
107
|
+
disabledButton: {
|
|
108
|
+
...buttonStyle,
|
|
109
|
+
borderRadius: variants[variant].borderRadius,
|
|
110
|
+
background: colors[colorScheme].disabledButton,
|
|
111
|
+
borderColor: colors[colorScheme].border,
|
|
112
|
+
cursor: 'default',
|
|
113
|
+
},
|
|
114
|
+
enabledIcon: {
|
|
115
|
+
...iconStyle,
|
|
116
|
+
color: colors[colorScheme].enabledIcon,
|
|
117
|
+
},
|
|
118
|
+
disabledIcon: {
|
|
119
|
+
...iconStyle,
|
|
120
|
+
opacity: '0.4',
|
|
121
|
+
transform: 'none',
|
|
122
|
+
color: colors[colorScheme].disabledIcon,
|
|
123
|
+
},
|
|
124
|
+
panel: {
|
|
125
|
+
padding: '16',
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const BaseStyle: () => CSSObject = () => ({
|
|
130
|
+
item: {
|
|
131
|
+
borderRadius: 0,
|
|
132
|
+
boxShadow: 'none',
|
|
133
|
+
borderTopStyle: 'solid',
|
|
134
|
+
borderTopWidth: '1px',
|
|
135
|
+
borderTopColor: 'neutral.90',
|
|
136
|
+
},
|
|
137
|
+
button: {
|
|
138
|
+
display: 'flex',
|
|
139
|
+
alignItems: 'center',
|
|
140
|
+
justifyContent: 'space-between',
|
|
141
|
+
width: '100%',
|
|
142
|
+
paddingInline: '16',
|
|
143
|
+
paddingBlock: '20',
|
|
144
|
+
borderColor: 'neutral.93',
|
|
145
|
+
_hover: {
|
|
146
|
+
background: 'neutral.93',
|
|
115
147
|
},
|
|
116
|
-
|
|
117
|
-
|
|
148
|
+
_expanded: {
|
|
149
|
+
borderBottomLeftRadius: '0',
|
|
150
|
+
borderBottomRightRadius: '0',
|
|
151
|
+
background: 'neutral.90',
|
|
118
152
|
},
|
|
119
|
-
}
|
|
153
|
+
},
|
|
154
|
+
icon: {
|
|
155
|
+
width: '24',
|
|
156
|
+
height: '24',
|
|
157
|
+
marginLeft: '16',
|
|
158
|
+
},
|
|
159
|
+
panel: {
|
|
160
|
+
padding: '16',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const AccordionTheme: ComponentStyleConfig = {
|
|
165
|
+
baseStyle: ({ colorScheme, variant }) => {
|
|
166
|
+
return variant === 'legacy' || variant === 'flat' ? LegacyBaseStyle({ colorScheme, variant }) : BaseStyle();
|
|
167
|
+
},
|
|
120
168
|
};
|
|
121
169
|
|
|
122
170
|
export default AccordionTheme;
|
|
@@ -37,6 +37,7 @@ type TextTags =
|
|
|
37
37
|
| 'var';
|
|
38
38
|
|
|
39
39
|
export interface TextProps extends ChakraTextProps {
|
|
40
|
+
align?: ResponsiveValue<'center' | 'justify' | 'left' | 'right'>;
|
|
40
41
|
/**
|
|
41
42
|
* Any valid HTML text tag
|
|
42
43
|
*/
|
|
@@ -44,12 +45,13 @@ export interface TextProps extends ChakraTextProps {
|
|
|
44
45
|
/**
|
|
45
46
|
* Font weight
|
|
46
47
|
*/
|
|
47
|
-
fontWeight?: ResponsiveValue<'bold' | '
|
|
48
|
-
hasEllipsis?: boolean;
|
|
48
|
+
fontWeight?: ResponsiveValue<'bold' | 'normal'>;
|
|
49
49
|
/**
|
|
50
50
|
* Size config (https://www.figma.com/file/grik9mTaJ5DfhydhWhXdP5/Bitkit-Foundations?node-id=211%3A12)
|
|
51
51
|
*/
|
|
52
52
|
size?: ResponsiveValue<TextSizes>;
|
|
53
|
+
textTransform?: ResponsiveValue<'capitalize' | 'lowercase' | 'none' | 'uppercase'>;
|
|
54
|
+
hasEllipsis?: boolean;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
/**
|
|
@@ -15,7 +15,6 @@ const typography = {
|
|
|
15
15
|
},
|
|
16
16
|
fontWeights: {
|
|
17
17
|
normal: 400,
|
|
18
|
-
demiBold: 600,
|
|
19
18
|
bold: 700,
|
|
20
19
|
},
|
|
21
20
|
letterSpacings: {
|
|
@@ -25,41 +24,51 @@ const typography = {
|
|
|
25
24
|
'4': '0.0375rem',
|
|
26
25
|
'5': '0.05rem',
|
|
27
26
|
},
|
|
27
|
+
lineHeights: {
|
|
28
|
+
'1': '1rem',
|
|
29
|
+
'2': '1.25rem',
|
|
30
|
+
'3': '1.5rem',
|
|
31
|
+
'4': '1.75rem',
|
|
32
|
+
'5': '2.25rem',
|
|
33
|
+
'6': '2.5rem',
|
|
34
|
+
'7': '3rem',
|
|
35
|
+
'8': '3.75rem',
|
|
36
|
+
},
|
|
28
37
|
};
|
|
29
38
|
|
|
30
39
|
export const textSizes = {
|
|
31
40
|
sizes: {
|
|
32
41
|
'1': {
|
|
33
42
|
fontSize: '1',
|
|
34
|
-
lineHeight: '
|
|
43
|
+
lineHeight: '1',
|
|
35
44
|
},
|
|
36
45
|
'2': {
|
|
37
46
|
fontSize: '2',
|
|
38
|
-
lineHeight: '
|
|
47
|
+
lineHeight: '2',
|
|
39
48
|
},
|
|
40
49
|
'3': {
|
|
41
50
|
fontSize: '3',
|
|
42
|
-
lineHeight: '
|
|
51
|
+
lineHeight: '3',
|
|
43
52
|
},
|
|
44
53
|
'4': {
|
|
45
54
|
fontSize: '4',
|
|
46
|
-
lineHeight: '
|
|
55
|
+
lineHeight: '4',
|
|
47
56
|
},
|
|
48
57
|
'5': {
|
|
49
58
|
fontSize: '5',
|
|
50
|
-
lineHeight: '
|
|
59
|
+
lineHeight: '5',
|
|
51
60
|
},
|
|
52
61
|
'6': {
|
|
53
62
|
fontSize: '6',
|
|
54
|
-
lineHeight: '
|
|
63
|
+
lineHeight: '6',
|
|
55
64
|
},
|
|
56
65
|
'7': {
|
|
57
66
|
fontSize: '7',
|
|
58
|
-
lineHeight: '
|
|
67
|
+
lineHeight: '7',
|
|
59
68
|
},
|
|
60
69
|
'8': {
|
|
61
70
|
fontSize: '8',
|
|
62
|
-
lineHeight: '
|
|
71
|
+
lineHeight: '8',
|
|
63
72
|
},
|
|
64
73
|
},
|
|
65
74
|
};
|
package/src/index.ts
CHANGED
|
@@ -159,6 +159,12 @@ export { default as Notification } from './Components/Notification/Notification'
|
|
|
159
159
|
|
|
160
160
|
export { BREAKPOINTS } from './Foundations/Breakpoints/Breakpoints';
|
|
161
161
|
|
|
162
|
+
export type { AccordionProps } from './Components/Accordion/Accordion';
|
|
163
|
+
export { default as Accordion } from './Components/Accordion/Accordion';
|
|
164
|
+
|
|
165
|
+
export type { AccordionItemProps } from './Components/Accordion/AccordionItem';
|
|
166
|
+
export { default as AccordionItem } from './Components/Accordion/AccordionItem';
|
|
167
|
+
|
|
162
168
|
export type { LegacyAccordionProps } from './Components/AccordionLegacy/LegacyAccordion';
|
|
163
169
|
export { default as LegacyAccordion } from './Components/AccordionLegacy/LegacyAccordion';
|
|
164
170
|
|