@bitrise/bitkit 13.230.0 → 13.231.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,45 @@
|
|
|
1
|
+
import { forwardRef } from '@chakra-ui/react';
|
|
2
|
+
import IconButton, { IconButtonProps } from '../IconButton/IconButton';
|
|
3
|
+
|
|
4
|
+
export interface ToggleButtonProps extends Omit<IconButtonProps, 'iconSize' | 'variant'> {
|
|
5
|
+
isSelected?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const ToggleButton = forwardRef<ToggleButtonProps, 'button'>((props, ref) => {
|
|
9
|
+
const { isDanger, isSelected, size = 'sm', ...rest } = props;
|
|
10
|
+
|
|
11
|
+
const COLORS = {
|
|
12
|
+
color: isSelected ? 'icon/interactive' : 'button/secondary/fg',
|
|
13
|
+
backgroundColor: isSelected ? 'background/selected' : 'button/secondary/background',
|
|
14
|
+
borderColor: isSelected ? 'border/selected' : 'button/secondary/border',
|
|
15
|
+
_hover: {
|
|
16
|
+
backgroundColor: isSelected ? 'background/selected-hover' : 'button/tertiary/bg-hover',
|
|
17
|
+
color: isSelected ? 'icon/interactive-hover' : 'button/secondary/fg-hover',
|
|
18
|
+
},
|
|
19
|
+
_active: {
|
|
20
|
+
backgroundColor: isSelected ? 'background/selected' : 'button/tertiary/bg-active',
|
|
21
|
+
color: isSelected ? 'icon/interactive' : 'button/secondary/fg-active',
|
|
22
|
+
},
|
|
23
|
+
_disabled: {
|
|
24
|
+
backgroundColor: 'button/tertiary/bg-disabled',
|
|
25
|
+
color: 'button/tertiary/fg-disabled',
|
|
26
|
+
cursor: 'not-allowed',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const colors = Object.assign(!isDanger ? COLORS : {});
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<IconButton
|
|
34
|
+
iconSize={size === 'lg' ? '24' : '16'}
|
|
35
|
+
isDanger={isDanger}
|
|
36
|
+
ref={ref}
|
|
37
|
+
size={size}
|
|
38
|
+
variant="secondary"
|
|
39
|
+
{...colors}
|
|
40
|
+
{...rest}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default ToggleButton;
|
package/src/index.ts
CHANGED
|
@@ -366,6 +366,9 @@ export { default as Label } from './Components/Label/Label';
|
|
|
366
366
|
export type { FormLabelProps } from './Components/Form/FormLabel';
|
|
367
367
|
export { default as FormLabel } from './Components/Form/FormLabel';
|
|
368
368
|
|
|
369
|
+
export type { ToggleButtonProps } from './Components/ToggleButton/ToggleButton';
|
|
370
|
+
export { default as ToggleButton } from './Components/ToggleButton/ToggleButton';
|
|
371
|
+
|
|
369
372
|
export {
|
|
370
373
|
default as SettingsCard,
|
|
371
374
|
SettingsCardData,
|