@nexara/nativeflow
Version:
Beautiful, responsive, and customizable UI components for React Native – built for performance and seamless experiences.
119 lines (115 loc) • 2.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getButtonColors = void 0;
const getButtonBorderColor = ({
theme,
strokeColor,
disabled,
loading
}) => {
if (disabled || loading) {
return theme.colors.border.default;
}
if (strokeColor) {
return strokeColor;
}
return theme.colors.border.default;
};
const getButtonTextColor = ({
theme,
checkVariant,
titleColor,
disabled,
loading
}) => {
if (disabled || loading) {
return theme.colors.typography.disabled;
} else if (titleColor) {
return titleColor;
} else if (checkVariant('outlined')) {
return theme.colors.typography.primary;
}
return theme.colors.brand.onPrimary;
};
const getButtonBackgroundColor = ({
theme,
checkVariant,
bg,
disabled,
loading
}) => {
if (disabled || loading) {
return theme.colors.states.disabled;
} else if (bg) {
return bg;
} else if (checkVariant('contained')) {
return theme.colors.brand.primary;
} else if (checkVariant('outlined')) {
return 'transparent';
}
return theme.colors.brand.primary;
};
// const getButtonIconColor = ({
// theme,
// checkVariant,
// disabled,
// }: {
// theme: ThemeTypes;
// checkVariant: (variant: ButtonVariant) => boolean;
// disabled: boolean;
// }) => {
// if (disabled) {
// return theme.colors.iconDisable;
// } else if (checkVariant('outlined')) {
// return theme.colors.iconPrimary
// }
// return theme.colors.iconSecondary;
// };
const getButtonColors = ({
theme,
variant,
bg,
titleColor,
strokeColor,
disabled,
loading
}) => {
const checkVariant = variantToCompare => {
return variant === variantToCompare;
};
const backgroundColor = getButtonBackgroundColor({
theme,
checkVariant,
bg,
disabled,
loading
});
const buttonTextColor = getButtonTextColor({
theme,
checkVariant,
titleColor,
disabled,
loading
});
const buttonBorderColor = getButtonBorderColor({
theme,
strokeColor,
disabled,
loading
});
// const buttonIconColor = getButtonIconColor({
// checkVariant,
// theme,
// disabled
// });
return {
backgroundColor,
buttonTextColor,
buttonBorderColor
// buttonIconColor
};
};
exports.getButtonColors = getButtonColors;
//# sourceMappingURL=utils.js.map