@audira/carbon-react-native
Version:
Build React Native apps with component and shared patterns using Carbon
108 lines (107 loc) • 3.19 kB
JavaScript
"use strict";
import { forwardRef, useContext } from 'react';
import { StyleSheet } from 'react-native';
import { Color, Spacing } from '@audira/carbon-react-native-elements';
import { CarbonStyleSheet } from "../../../carbon-style-sheet/index.js";
import { ThemeContext } from "../../../contexts/index.js";
import { BaseColor } from "../base-color/index.js";
import { jsx as _jsx } from "react/jsx-runtime";
export const Ghost = /*#__PURE__*/forwardRef(function Ghost({
text,
iconProps,
...props
}, ref) {
const themeContext = useContext(ThemeContext);
return /*#__PURE__*/_jsx(BaseColor, {
...props,
ref: ref,
text: text,
android_rippleEffectColor: mapAndroidRippleEffectColor[themeContext.colorScheme],
colorStateStyle: {
background: {
default: backgroundStyleSheet.default,
focused: backgroundStyleSheet.focused,
hovered: backgroundStyleSheet.hovered,
pressed: backgroundStyleSheet.pressed,
disabled: backgroundStyleSheet.disabled
},
text: {
default: textStyleSheet.default,
focused: textStyleSheet.focused,
hovered: textStyleSheet.hovered,
pressed: textStyleSheet.pressed,
disabled: textStyleSheet.disabled
},
icon: mapIconColor[themeContext.colorScheme]
},
iconProps: {
...iconProps,
style: [mapIconPLByText[`${!!text}`], iconProps?.style]
}
});
});
const backgroundStyleSheet = CarbonStyleSheet.create({
default: {
backgroundColor: 'transparent'
},
focused: {
borderWidth: 1,
borderColor: CarbonStyleSheet.color.focus
},
hovered: {
backgroundColor: CarbonStyleSheet.color.background_hover
},
pressed: {
backgroundColor: CarbonStyleSheet.color.background_active
},
disabled: {
backgroundColor: 'transparent'
}
}),
textStyleSheet = CarbonStyleSheet.create({
default: {
color: CarbonStyleSheet.color.link_primary
},
focused: {
color: CarbonStyleSheet.color.link_primary
},
hovered: {
color: CarbonStyleSheet.color.link_primary_hover
},
pressed: {
color: CarbonStyleSheet.color.link_primary
},
disabled: {
color: CarbonStyleSheet.color.text_disabled
}
}),
style = StyleSheet.create({
iconPL8: {
paddingLeft: Spacing.spacing_03
}
}),
mapIconPLByText = {
false: null,
true: style.iconPL8
},
mapIconColor = {
gray_10: {
default: Color.Token.gray_10.link_primary,
focused: Color.Token.gray_10.link_primary,
hovered: Color.Token.gray_10.link_primary_hover,
pressed: Color.Token.gray_10.link_primary,
disabled: Color.Token.gray_10.icon_disabled
},
gray_100: {
default: Color.Token.gray_100.link_primary,
focused: Color.Token.gray_100.link_primary,
hovered: Color.Token.gray_100.link_primary_hover,
pressed: Color.Token.gray_100.link_primary,
disabled: Color.Token.gray_100.icon_disabled
}
},
mapAndroidRippleEffectColor = {
gray_10: Color.Token.gray_10.background_active,
gray_100: Color.Token.gray_100.background_active
};
//# sourceMappingURL=Ghost.js.map