@cap3/capitano-components
Version:
# <div style="color: crimson;">ALPHA DISCLAIMER</div>
51 lines • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const capitano_theme_1 = require("@cap3/capitano-theme");
const assertNever_1 = require("../../utils/assertNever");
const defaultSize = 'medium';
exports.getFormElementBorderRadius = (radius = 'medium', height, theme) => {
switch (radius) {
case 'round':
return height / 2;
case 'sharp':
case 'small':
case 'medium':
return theme.spacing.borderRadiusFactor[radius] * theme.spacing.baseUnit;
default:
return assertNever_1.default(radius);
}
};
exports.formElementWidth = ({ fixed }) => {
const width = fixed ? 120 : 'auto'; // TODO fixed form element size as theme constant
return { width };
};
exports.formElementBaseStyle = ({ radius, size, outlined, fixed, theme, }) => {
const height = exports.formElementHeight(size, theme);
const borderRadius = outlined ? exports.getFormElementBorderRadius(radius, height, theme) : 0;
return Object.assign({ borderRadius, height }, exports.formElementWidth({ fixed }));
};
exports.formElementHeight = (size = defaultSize, theme) => theme.spacing.formElementFactor[size || 'medium'] * theme.spacing.baseUnit;
exports.fontSizeForElementSize = (size = defaultSize, theme) => {
return theme.typography.fontSize[size];
};
exports.formElementInputBaseStyle = ({ theme, size = defaultSize, }) => ({
boxSizing: 'border-box',
minWidth: '65px',
paddingLeft: capitano_theme_1.spacingAbsolute.spx8,
paddingRight: capitano_theme_1.spacingAbsolute.spx8,
height: theme.spacing.formElementFactor[size] * theme.spacing.baseUnit,
fontSize: exports.fontSizeForElementSize(size, theme),
color: theme.colors.textOnBackground,
backgroundColor: theme.colors.layout.base,
fontFamily: theme.typography.fontFamily.base,
outline: 'none',
});
exports.formElementBorderStyle = ({ outlined = false, theme, }) => {
const base = {
borderColor: theme.colors.layout.M30,
borderWidth: 1,
};
return outlined
? Object.assign({}, base, { borderStyle: 'solid' }) : Object.assign({}, base, { borderStyle: 'none', borderBottomStyle: 'solid', borderWidth: 1 });
};
//# sourceMappingURL=formElementHelpers.js.map