@audira/carbon-react-native
Version:
Build React Native apps with component and shared patterns using Carbon
59 lines (58 loc) • 1.6 kB
JavaScript
;
import { forwardRef } from 'react';
import { StyleSheet } from 'react-native';
import { Spacing } from '@audira/carbon-react-native-elements';
import { VariantContextProvider } from "../../_VariantContextProvider.js";
import { Base } from "../../base/index.js";
import { Subtitle } from "../../subtitle/index.js";
import { jsx as _jsx } from "react/jsx-runtime";
export const ToastVariant = /*#__PURE__*/forwardRef(function ToastVariant({
color,
Icon,
timestamp,
subtitle,
subtitleStyle,
...props
}, ref) {
return /*#__PURE__*/_jsx(VariantContextProvider, {
color: color,
children: /*#__PURE__*/_jsx(Base, {
...props,
inline: false,
Icon: Icon,
iconClose: true,
body: subtitle && (typeof subtitle === 'string' || typeof subtitle === 'number') ? /*#__PURE__*/_jsx(Subtitle, {
style: subtitleStyle,
children: subtitle
}) : subtitle,
nodes: {
beforeContentContainerEnd: timestamp ? /*#__PURE__*/_jsx(Subtitle, {
style: baseStyle.timestamp,
children: timestamp
}) : /*#__PURE__*/_jsx(Timestamp, {})
},
ref: ref
})
});
});
const baseStyle = StyleSheet.create({
timestamp: {
marginTop: Spacing.spacing_06
}
});
function Timestamp({
style,
...props
}) {
return /*#__PURE__*/_jsx(Subtitle, {
...props,
style: [baseStyle.timestamp, style],
children: new Date().toLocaleString('en-US', {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
})
});
}
//# sourceMappingURL=ToastVariant.js.map