@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
137 lines (135 loc) • 6.74 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomGrid = exports.GridItem = exports.Grid = exports.ContentCustomGridItem = exports.CustomGridItem = exports.CustomGridStyled = exports.GridItemStyled = exports.GridStyled = void 0;
const styled_components_1 = __importStar(require("styled-components"));
const breakpoints_1 = require("../../types/breakpoints/breakpoints");
const getStyles_1 = require("../../utils/getStyles/getStyles");
const grid_utils_1 = require("./utils/grid.utils");
exports.GridStyled = styled_components_1.default.div `
display: grid;
margin: auto;
${props => ({ styles, theme: { MEDIA_QUERIES: { onlyTablet, onlyMobile, onlyDesktop }, BREAKPOINTS, }, }) => (0, styled_components_1.css) `
${onlyDesktop} {
${(0, grid_utils_1.getGridConfiguration)(props.config?.[breakpoints_1.DeviceBreakpointsType.DESKTOP])};
${!props.isFullWidth &&
BREAKPOINTS?.XL &&
(0, grid_utils_1.getMaxWidth)(BREAKPOINTS?.XL, props.config?.[breakpoints_1.DeviceBreakpointsType.DESKTOP]?.margin, props.config?.[breakpoints_1.DeviceBreakpointsType.DESKTOP]?.gap, props.addPaddingForLayout)};
padding: 0
${props.addPaddingForLayout ? props.config?.[breakpoints_1.DeviceBreakpointsType.DESKTOP]?.gap : 0};
${(0, getStyles_1.getStyles)(styles)}
}
${onlyTablet} {
${(0, grid_utils_1.getGridConfiguration)(props.config?.[breakpoints_1.DeviceBreakpointsType.TABLET])};
margin: 0 ${props.config?.[breakpoints_1.DeviceBreakpointsType.TABLET]?.margin}rem;
${(0, getStyles_1.getStyles)(styles)}
}
${onlyMobile} {
${(0, grid_utils_1.getGridConfiguration)(props.config?.[breakpoints_1.DeviceBreakpointsType.MOBILE])};
margin: 0 ${props.config?.[breakpoints_1.DeviceBreakpointsType.MOBILE]?.margin}rem;
${(0, getStyles_1.getStyles)(styles)}
}
`};
`;
exports.Grid = exports.GridStyled;
exports.GridItemStyled = styled_components_1.default.div `
${props => (0, grid_utils_1.getItemGridConfiguration)(props.desktop)};
${props => ({ theme: { MEDIA_QUERIES: { onlyTablet, onlyMobile }, }, }) => (0, styled_components_1.css) `
${onlyTablet} {
${(0, grid_utils_1.getItemGridConfiguration)(props.tablet)};
}
${onlyMobile} {
${(0, grid_utils_1.getItemGridConfiguration)(props.mobile)};
}
`}
`;
exports.GridItem = exports.GridItemStyled;
// It is a Grid without margins and paddings to allow differents containers and make width calculations in the children
exports.CustomGridStyled = styled_components_1.default.div `
display: grid;
${props => ({ theme: { MEDIA_QUERIES: { onlyTablet, onlyMobile, onlyDesktop }, }, }) => (0, styled_components_1.css) `
${onlyDesktop} {
${(0, grid_utils_1.getGridConfiguration)(props.config?.[breakpoints_1.DeviceBreakpointsType.DESKTOP])};
}
${onlyTablet} {
${(0, grid_utils_1.getGridConfiguration)(props.config?.[breakpoints_1.DeviceBreakpointsType.TABLET])};
margin: 0 ${props.config?.[breakpoints_1.DeviceBreakpointsType.TABLET]?.margin}rem;
}
${onlyMobile} {
${(0, grid_utils_1.getGridConfiguration)(props.config?.[breakpoints_1.DeviceBreakpointsType.MOBILE])};
margin: 0 ${props.config?.[breakpoints_1.DeviceBreakpointsType.MOBILE]?.margin}rem;
}
`};
`;
exports.CustomGrid = exports.CustomGridStyled;
exports.CustomGridItem = styled_components_1.default.div `
/* we can apply a background color for each container */
background: ${({ containerColor }) => containerColor};
${props => (0, grid_utils_1.getItemGridConfiguration)(props.desktop)};
${props => ({ theme: { MEDIA_QUERIES: { onlyDesktop, onlyTablet, onlyMobile }, }, paddingRight, paddingLeft, height, }) => {
return (0, styled_components_1.css) `
${onlyDesktop} {
/* These are the paddings for the GridItem container and his content */
padding-right: ${paddingRight};
padding-left: ${paddingLeft};
height: ${height};
}
${onlyTablet} {
${(0, grid_utils_1.getItemGridConfiguration)(props.tablet)};
}
${onlyMobile} {
${(0, grid_utils_1.getItemGridConfiguration)(props.mobile)};
}
`;
}}
`;
exports.ContentCustomGridItem = styled_components_1.default.div `
${props => ({ theme: { MEDIA_QUERIES: { onlyDesktop }, }, isMainContainer, containerWidth, marginsContainer, paddingRight, paddingLeft, }) => {
return (0, styled_components_1.css) `
${onlyDesktop} {
//We need the property margin with "getMaxWidth" to make the margins increase and decrease when you resize the screen.
${isMainContainer ? 'margin-left: auto' : 'margin-right: auto'};
/* We have to make "/2" because the function getMaxWidth make "margin x 2" (left and right), so we need to apply just the the half for each one in the same row.
if we had 3 containers in the same line it is neccesary to make another function */
${(0, grid_utils_1.getMaxWidth)(Number(containerWidth), (marginsContainer ?? 0) / 2, props.minMarginRightAndLeft, true)};
padding-top: 0;
padding-bottom: 0;
padding-left: ${paddingLeft};
padding-right: ${paddingRight};
}
`;
}}
`;
//# sourceMappingURL=grid.styled.js.map