@whitemordred/react-native-bootstrap5
Version:
A complete React Native library that replicates Bootstrap 5.3 with 100% feature parity, full theming support, CSS variables, and dark/light mode
72 lines (71 loc) • 2.8 kB
JavaScript
;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FigureCaption = exports.Figure = exports.Image = void 0;
const react_1 = __importDefault(require("react"));
const react_native_1 = require("react-native");
const ThemeProvider_1 = require("../theme/ThemeProvider");
const Image = (_a) => {
var { fluid = false, rounded = false, roundedCircle = false, thumbnail = false, style, containerStyle } = _a, props = __rest(_a, ["fluid", "rounded", "roundedCircle", "thumbnail", "style", "containerStyle"]);
const { theme } = (0, ThemeProvider_1.useTheme)();
const getImageStyle = () => {
const baseStyle = {};
if (fluid) {
baseStyle.width = '100%';
baseStyle.height = undefined;
}
if (rounded) {
baseStyle.borderRadius = theme.borderRadius.base;
}
if (roundedCircle) {
baseStyle.borderRadius = 1000; // Large value for circular
}
if (thumbnail) {
baseStyle.borderWidth = 1;
baseStyle.borderColor = theme.colors.gray[300];
baseStyle.borderRadius = theme.borderRadius.base;
baseStyle.padding = 4;
baseStyle.backgroundColor = theme.colors.white;
}
return baseStyle;
};
return (<react_native_1.Image {...props} style={[getImageStyle(), style]} resizeMode={fluid ? 'contain' : props.resizeMode}/>);
};
exports.Image = Image;
const Figure = ({ children, style }) => {
return (<react_native_1.View style={[styles.figure, style]}>
{children}
</react_native_1.View>);
};
exports.Figure = Figure;
const FigureCaption = ({ children, style }) => {
const { theme } = (0, ThemeProvider_1.useTheme)();
return (<react_native_1.Text style={[styles.figureCaption, { color: theme.colors.gray[600] }, style]}>
{children}
</react_native_1.Text>);
};
exports.FigureCaption = FigureCaption;
const styles = react_native_1.StyleSheet.create({
figure: {
marginBottom: 16,
},
figureCaption: {
fontSize: 14,
marginTop: 8,
textAlign: 'center',
},
});
exports.default = exports.Image;